File Relationships

post
Create File Relationship(s)

https://api.moltin.com/v2/products/:productId/relationships/files
Create a product relationship to one or more Files. 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 file(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 file).
data[].id
required
string
The ID of the file.
200: OK
{
"data": [
{
"type": "file",
"id": "2c51711-35f9-403e-aa73-8e6c80c2258b"
},
{
"type": "file",
"id": "2C090e3c8-0206-4243-9a3b-f28175f7e9de"
}
]
}
cURL
JavaScript SDK
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"
}
]
}'
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) => {
// Do something
})

put
Update File Relationship(s)

https://api.moltin.com/v2/products/:productId/relationships/file
Replace the relationships between a Product and a File. 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 file(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 file).
data[].id
required
string
The ID of the file.
200: OK
{
"data": [
{
"type": "file",
"id": "2c51711-35f9-403e-aa73-8e6c80c2258b"
}
}
cURL
JavaScript SDK
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"
}
]
}
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) => {
// Do something
})

delete
Delete File Relationships(s)

https://api.moltin.com/v2/products/:productId/relationships/file
Remove a relationship between a Product and File(s). This deletes the relationships specified in the payload.
Request
Response
Path Parameters
productId
required
string
The ID of the product you wish to delete the relationship with file(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 file).
data[].id
required
string
The ID of the file.
200: OK
cURL
JavaScript SDK
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"
}
]
}'
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) => {
// Do something
})