Choose the right endpoint
If you are using the Product Experience Manager (EP PXM) services, use the pcm/products
endpoints instead of the v2/products
endpoints. For details about the pcm/products
endpoints, see the topics in the EP PXM Products section.
POST
Create Collection Relationships
https://api.moltin.com/v2/products/:productId/relationships/collections
Create a product relationship to one or many collections. If any relationships already exist, the ones made in the request are added to them.
Parameters
Path parameters
Name Required Type Description
productId
Required string
The ID of the product you want to relate to the collections.
Headers
Name Required Type Description
Authorization
Required string
The Bearer token required to get access to the API.
Body
Name Required Type Description
data[].type
Required string
Represents the type of object (should be collection ).
data[].id
Required string
The ID of the collection.
Request Examples
Curl
curl -X POST https://api.moltin.com/v2/products/:productId/relationships/collections \
-H "Authorization: Bearer XXXX" \
-H "Content-Type: application/json" \
-d $'{
"data": [
{
"type": "collection",
"id": "5ab3deca-1f11-47b7-a409-24ea3234d72c"
},
{
"type": "collection",
"id": "2c740aa0-7fb7-4bd6-9347-78988cf60f9a"
}
]
}'
JavaScript SDK
const MoltinGateway = require ('@moltin/sdk' ).gateway
const Moltin = MoltinGateway({
client_id : 'X' ,
client_secret : 'X'
})
const productId = 'XXXX'
const collectionIds = [
'5ab3deca-1f11-47b7-a409-24ea3234d72c' ,
'2c740aa0-7fb7-4bd6-9347-78988cf60f9a'
]
Moltin.Products.CreateRelationships(productId, 'collection' , collectionIds).then((relationships ) => {
})
Response Example
200 OK
{
"data" : [
{
"type" : "collection" ,
"id" : "5ab3deca-1f11-47b7-a409-24ea3234d72c"
},
{
"type" : "collection" ,
"id" : "2c740aa0-7fb7-4bd6-9347-78988cf60f9a"
}
]
}
PUT
Update Collection Relationships
https://api.moltin.com/v2/products/:productId/relationships/collections
Replace the relationships between a Product and a Collection. Unlike a POST
to this endpoint, a PUT
overrides any existing relationships.
Parameters
Path parameters
Name Required Type Description
productId
Required string
The ID of the product you want to relate to the collections.
Headers
Name Required Type Description
Authorization
Required string
The Bearer token required to get access to the API.
Body
Name Required Type Description
data[].type
Required string
Represents the type of object (should be collection ).
data[].id
Required string
The ID of the collection.
Request Examples
Curl
curl -X PUT https://api.moltin.com/v2/products/{PRODUCT_ID}/relationships/collections \
-H "Authorization: Bearer XXXX" \
-H "Content-Type: application/json" \
-d $'{
"data": [
{
"type": "collection",
"id": "2c740aa0-7fb7-4bd6-9347-78988cf60f9a"
}
]
}'
JavaScript SDK
const MoltinGateway = require ('@moltin/sdk' ).gateway
const Moltin = MoltinGateway({
client_id : 'X' ,
client_secret : 'X'
})
const productId = 'XXXX'
var collectionIds = [
'2c740aa0-7fb7-4bd6-9347-78988cf60f9a'
];
Moltin.Products.UpdateRelationships(productId, 'collection' , collectionIds).then((relationships ) => {
});
Response Example
200 OK
{
"data" : [
{
"type" : "collection" ,
"id" : "2c740aa0-7fb7-4bd6-9347-78988cf60f9a"
}
]
}
DELETE
Delete Collection Relationships
https://api.moltin.com/v2/products/:productId/relationships/collections
Remove a relationship between a product and a collection(s). This deletes the relationship specified in the payload.
Parameters
Path parameters
Name Required Type Description
productId
Required string
The ID of the product you want to relate to the collections.
Headers
Name Required Type Description
Authorization
Required string
The Bearer token required to get access to the API.
Body
Name Required Type Description
data[].type
Required string
Represents the type of object (should be collection ).
data[].id
Required string
The ID of the collection.
Request Examples
Curl
curl -X DELETE https://api.moltin.com/v2/products/:productId/relationships/collections \
-H "Authorization: Bearer XXXX" \
-H "Content-Type: application/json" \
-d $'{
"data": [
{
"type": "collection",
"id": "2c740aa0-7fb7-4bd6-9347-78988cf60f9a"
}
]
}'
JavaScript SDK
const MoltinGateway = require ('@moltin/sdk' ).gateway
const Moltin = MoltinGateway({
client_id : 'X' ,
client_secret : 'X'
})
const productId = 'XXXX'
var collectionIds = [
'2c740aa0-7fb7-4bd6-9347-78988cf60f9a'
];
Moltin.Products.DeleteRelationships(productId, 'collection' , collectionIds).then((relationships ) => {
});
Response Example
200 OK