Collection Relationships

post
Create Collection Relationship(s)

https://api.moltin.com/v2/products/:productId/relationships/collections
Create a product relationship to one or many Collections. If any relationships already exist, the one's made in the request will be added to them.
Request
Response
Path Parameters
productId
required
string
The ID of the product you wish to relate to the collection(s).
Headers
Authorization
required
string
The Bearer token to grant access to the API.
Body Parameters
data[].type
required
string
Represents the type of object (should be collection).
data[].id
required
string
The ID of the collection.
200: OK
{
"data": [
{
"type": "collection",
"id": "5ab3deca-1f11-47b7-a409-24ea3234d72c"
},
{
"type": "collection",
"id": "2c740aa0-7fb7-4bd6-9347-78988cf60f9a"
}
]
}
cURL
JavaScript SDK
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"
}
]
}'
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) => {
// Do something
})

put
Update Collection Relationship(s)

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.
Request
Response
Path Parameters
productId
required
string
The ID of the product you wish to relate to the collection(s).
Headers
Authorization
required
string
The Bearer token to grant access to the API.
Body Parameters
data[].type
required
string
Represents the type of object (should be collection).
data[].id
required
string
The ID of the collection.
200: OK
{
"data": [
{
"type": "collection",
"id": "2c740aa0-7fb7-4bd6-9347-78988cf60f9a"
}
]
}
cURL
JavaScriptSDK
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"
}
]
}'
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) => {
// Do something
});

delete
Delete Collection Relationship(s)

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.
Request
Response
Path Parameters
productId
required
string
The ID of the product you wish to relate to the collection(s).
Headers
Authorization
required
string
The Bearer token to grant access to the API.
Body Parameters
data[].type
required
string
Represents the type of object (should be collection).
data[].id
required
string
The ID of the collection.
200: OK
cURL
JavaScript SDK
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"
}
]
}'
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) => {
// Do something
});