Create a Collection
Choose the right endpoint
If you are using the Product Experience Manager (EP PXM) services, use the pcm/hierarchies
endpoints instead of the v2/collections
endpoints. For details about the pcm/hierarchies
endpoints, see the topics in the EP PXM Hierarchies section.
POST
Create a Collection
https://api.moltin.com/v2/collections
Parameters
Headers
Name | Required | Type | Description |
---|---|---|---|
Authorization | Required | string | The Bearer token required to get access to the API. |
Body
Name | Required | Type | Description |
---|---|---|---|
type | Required | string | Represents the type of object being returned. |
name | Required | string | The name of the collection. |
slug | Required | string | A unique slug identifier for the collection. |
description | Optional | string | Any description for this collection. |
status | Optional | string | live , or draft depending on the collection status. (defaults to draft). |
Request Examples
Curl
curl -X POST https://api.moltin.com/v2/collections \
-H "Authorization: Bearer XXXX" \
-H "Content-Type: application/json" \
-d $'{
"data": {
"type": "collection",
"name": "Winter Season",
"slug": "winter-season",
"description": "Our Winter Season is now live!",
"status": "live"
}
}'
JavaScript SDK
const MoltinGateway = require('@moltin/sdk').gateway
const Moltin = MoltinGateway({
client_id: 'XXXX'
})
const collection = {
name: "Winter Season",
slug: "winter-season",
description: "Our Winter Season is now live!",
status: "live"
}
Moltin.Collections.Create(collection).then((response) => {
// Do something
});
Response Example
201 Created
{
"data": {
"id": "a276571c-321e-4c48-af2a-5a3895394b08",
"type": "collection",
"status": "live",
"name": "Winter Season",
"slug": "winter-season",
"description": "Our Winter Season is now live!",
"relationships": {}
}
}