Variations Relationship

post
Create Variations Relationship(s)

https://api.moltin.com/v2/products/:productId/relationships/variations
Request
Response
Path Parameters
productId
required
string
The ID of the product you wish to relate to the variation(s).
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 product-variation).
data[].id
required
string
The ID of the product-variation.
200: OK
{
"data": [
{
"type": "product-variation",
"id": "3ab3deca-1f11-47b7-a409-24ea3234d72c"
},
{
"type": "product-variation",
"id": "7c740aa0-7fb7-4bd6-9347-78988cf60f9a"
}
]
}
cURL
JavaScript SDK
curl -X POST https://api.moltin.com/v2/products/:productId/relationships/variations \
-H "Authorization: Bearer XXXX" \
-H "Content-Type: application/json" \
-d $'{
"data": [
{
"type": "product-variation",
"id": "3ab3deca-1f11-47b7-a409-24ea3234d72c"
},
{
"type": "product-variation",
"id": "7c740aa0-7fb7-4bd6-9347-78988cf60f9a"
}
]
}'
const MoltinGateway = require('@moltin/sdk').gateway
const Moltin = MoltinGateway({
client_id: 'X',
client_secret: 'X'
})
const productId = 'XXXX'
const variationIds = [
'5ab3deca-1f11-47b7-a409-24ea3234d72c',
'2c740aa0-7fb7-4bd6-9347-78988cf60f9a'
]
Moltin.Products.CreateRelationships(productId, 'product-variation', variationIds).then((relationships) => {
// Do something
})

put
Update Variation Relationship(s)

https://api.moltin.com/v2/products/:productId/relationships/variations
Replace the relationships between a product and a variation. 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 variation(s).
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 product-variation).
data[].id
required
string
The ID of the variation.
200: OK
{
"data": [
{
"type": "product-variation",
"id": "2c740aa0-7fb7-4bd6-9347-78988cf60f9a"
}
]
}
cURL
JavaScript SDK
url -X PUT https://api.moltin.com/v2/products/:productId/relationships/variations \
-H "Authorization: Bearer XXXX" \
-H "Content-Type: application/json" \
-d $'{
"data": [
{
"type": "product-variation",
"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 variationIds = [
'2c740aa0-7fb7-4bd6-9347-78988cf60f9a'
]
Moltin.Products.UpdateRelationships(productId, 'variation', variationIds).then((relationships) => {
// Do something
})

delete
Delete Variation Relationship(s)

https://api.moltin.com/v2/products/:productId/relationships/variations
Remove a relationship between a Product and a Variation(s). This deletes the relationships specified in the payload.
Request
Response
Path Parameters
productId
required
string
The ID of the product you wish to relate to the variations(s)
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 product-variation).
data[].id
required
string
The ID of the variation.
200: OK
cURL
JavaScript SDK
curl -X DELETE https://api.moltin.com/v2/products/:productId/relationships/variations \
-H "Authorization: Bearer XXXX" \
-H "Content-Type: application/json" \
-d $'{
"data": [
{
"type": "product-variation",
"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 variationIds = [
'2c740aa0-7fb7-4bd6-9347-78988cf60f9a'
]
Moltin.Products.DeleteRelationships(productId, 'variation', variationIds).then((relationships) => {
// Do something
})