Category Relationship

post
Create Category Relationship(s)

https://api.moltin.com/v2/products/:productId/relationships/categories
Create a Product relationship to on or more Categories. 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 category(s).
Headers
Authorization
required
string
The Bearer used to access the API.
Body Parameters
data[].type
required
string
Represents the type of object (should be category).
data[].id
required
string
The ID of the category.
200: OK
{
"data": [
{
"type": "category",
"id": "39a13b7e-f2d3-47a5-9bc5-1e98b198748c"
},
{
"type": "category",
"id": "0c108707-bb4a-4eda-95e3-f51b35122cb4"
}
]
}
cURL
JavaScript SDK
curl -X "POST" https://api.moltin.com/v2/products/:productId/relationships/categories \
-H "Authorization: Bearer XXXX" \
-H "Content-Type: application/json" \
-d $'{
"data": [
{
"type": "category",
"id": "39a13b7e-f2d3-47a5-9bc5-1e98b198748c"
},
{
"type": "category",
"id": "0c108707-bb4a-4eda-95e3-f51b35122cb4"
}
]
}'
const MoltinGateway = require('@moltin/sdk').gateway
const Moltin = MoltinGateway({
client_id: 'X',
client_secret: 'X'
})
const productId = 'XXXX'
const categoryIds = [
'39a13b7e-f2d3-47a5-9bc5-1e98b198748c',
'0c108707-bb4a-4eda-95e3-f51b35122cb4'
]
Moltin.Products.CreateRelationships(productId, 'category', categoryIds).then((relationships) => {
// Do something
})

put
Update Category Relationship(s)

https://api.moltin.com/v2/products/:productId/relationships/categories
Replace the relationships between a Product and a Category. 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 category(s).
Headers
Authorization
required
string
The Bearer used to access the API.
Body Parameters
data[].type
required
string
Represents the type of objects (should be category).
data[].id
required
string
The ID of the category.
200: OK
{
"data": [
{
"type": "category",
"id": "d7290481-8d03-4fe0-a7df-23fc05498a46"
}
]
}
cURL
JavaScript SDK
curl -X "PUT" https://api.moltin.com/v2/products/:productId/relationships/categories \
-H "Authorization: Bearer XXXX" \
-H "Content-Type: application/json" \
-d $'{
"data": [
{
"type": "category",
"id": "d7290481-8d03-4fe0-a7df-23fc05498a46"
}
]
}'
const MoltinGateway = require('@moltin/sdk').gateway
const Moltin = MoltinGateway({
client_id: 'X',
client_secret: 'X'
})
const productId = 'XXXX'
const categoryIds = [
'd7290481-8d03-4fe0-a7df-23fc05498a46'
]
Moltin.Products.UpdateRelationships(productId, 'category', categoryIds).then((relationships) => {
// Do something
})

delete
Delete Category Relationship(s)

https://api.moltin.com/v2/products/:productId/relationships/categories
Removing a relationships between a Product and Category(s) deletes the relationships specified in the payload.
Request
Response
Path Parameters
productId
required
string
The ID of the product you wish to delete.
Headers
Authorization
required
string
The Bearer token used to access the API.
Body Parameters
data[].type
required
string
Represents the type of object (should be category).
data[].id
required
string
The ID of the category.
204: No Content
cURL
JavaScript SDK
curl -X "DELETE" https://api.moltin.com/v2/products/:productId/relationships/categories \
-H "Authorization: Bearer XXXX" \
-H "Content-Type: application/json" \
-d $'{
"data": [
{
"type": "category",
"id": "0c108707-bb4a-4eda-95e3-f51b35122cb4"
}
]
}'
const MoltinGateway = require('@moltin/sdk').gateway
const Moltin = MoltinGateway({
client_id: 'X',
client_secret: 'X'
})
const productId = 'XXXX'
const categoryIds = [
'0c108707-bb4a-4eda-95e3-f51b35122cb4
]
Moltin.Products.DeleteRelationships(productId, 'category', categoryIds).then((relationships) => {
// Do something
})