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 File Relationships
https://api.moltin.com/v2/products/:productId/relationships/files
Create a product relationship to one or more Files . 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 file(s).
Headers
Name Required Type Description
Authorization
Required string
The Bearer used to access the API.
Body
Name Required Type Description
data[].type
Required string
Represents the type of object (should be file).
data[].id
Required string
The ID of the file.
Request Examples
Curl
curl -X POST https://api.moltin.com/v2/products/:productId/relationships/files \
-H "Authorization: Bearer XXXX" \
-H "Content-Type: application/json" \
-d $'{
"data": [
{
"type": "file",
"id": "82c51711-35f9-403e-aa73-8e6c80c2258b"
},
{
"type": "file",
"id": "c090e3c8-0206-4243-9a3b-f28175f7e9de"
}
]
}'
JavaScript SDK
const MoltinGateway = require ('@moltin/sdk' ).gateway
const Moltin = MoltinGateway({
client_id : 'X' ,
client_secret : 'X'
})
const productId = 'XXXX'
const fileIds = [
'82c51711-35f9-403e-aa73-8e6c80c2258b' ,
'c090e3c8-0206-4243-9a3b-f28175f7e9de'
]
Moltin.Products.CreateRelationships(productId, 'file' , fileIds).then((relationships ) => {
})
Response Example
200 OK
{
"data" : [
{
"type" : "file" ,
"id" : "2c51711-35f9-403e-aa73-8e6c80c2258b"
},
{
"type" : "file" ,
"id" : "2C090e3c8-0206-4243-9a3b-f28175f7e9de"
}
]
}
PUT
Update File Relationships
https://api.moltin.com/v2/products/:productId/relationships/files
Replace the relationships between a Product and a File. 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 file(s).
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 file).
data[].id
Required string
The ID of the file.
Request Examples
Curl
curl -X PUT https://api.moltin.com/v2/products/:productId/relationships/files \
-H "Authorization: Bearer XXXX" \
-H "Content-Type: application/json" \
-d $'{
"data": [
{
"type": "file",
"id": "82c51711-35f9-403e-aa73-8e6c80c2258b"
}
]
}'
JavaScript SDK
const MoltinGateway = require ('@moltin/sdk' ).gateway
const Moltin = MoltinGateway({
client_id : 'X' ,
client_secret : 'X'
})
const productId = 'XXXX'
const fileIds = [
'82c51711-35f9-403e-aa73-8e6c80c2258b'
]
Moltin.Products.UpdateRelationships(productId, 'file' , fileIds).then((relationships ) => {
})
Response Example
200 OK
{
"data" : [
{
"type" : "file" ,
"id" : "2c51711-35f9-403e-aa73-8e6c80c2258b"
}
]
}
DELETE
Delete File Relationshipss
https://api.moltin.com/v2/products/:productId/relationships/files
Remove a relationship between a Product and Files. This deletes the relationships specified in the payload.
Parameters
Path parameters
Name Required Type Description
productId
Required string
The ID of the product you want to delete the relationship with files.
Headers
Name Required Type Description
Authorization
Required string
The Bearer used to access the API.
Body
Name Required Type Description
data[].type
Required string
Represents the type of object (should be file ).
data[].id
Required string
The ID of the file.
Request Examples
Curl
curl -X DELETE https://api.moltin.com/v2/products/:productId/relationships/files \
-H "Authorization: Bearer XXXX" \
-H "Content-Type: application/json" \
-d $'{
"data": [
{
"type": "file",
"id": "82c51711-35f9-403e-aa73-8e6c80c2258b"
}
]
}'
JavaScript SDK
const MoltinGateway = require ('@moltin/sdk' ).gateway
const Moltin = MoltinGateway({
client_id : 'X' ,
client_secret : 'X'
})
const productId = 'XXXX'
const fileIds = [
'82c51711-35f9-403e-aa73-8e6c80c2258b'
]
Moltin.Products.DeleteRelationships(productId, 'file' , fileIds).then((relationships ) => {
})
Response Example
200 OK