Links are relationships between object types, such as related variants, related assets, cross-selling, collections, etc. If your data model is similar to Data Model B (Reference → ColorReference → Variant), you'll need to create links between your Reference and your ColorReference(s). | ||
Create Links
To create a link between two objects (documents or assets), you must include the document's code, the link type's code, and define the link's mode (behavior).
URL Parameters | |||
Endpoint | /documents/{{document_code}}/links/{{link_type_code}} | API v4 endpoint | |
HTTP Method | POST | ||
Query Parameters | |||
{{document_code}} | string | The unique code of the parent document. | |
{{link_type_code}} | string | The unique code of the link type between the parent document? (Reference) and the child document? (ColorReference). | |
Request Body | |||
Required Attributes | items | array(objects) | Array of objects to link. Each object is composed of:
|
mode | string | You must choose one of the following two behaviors:
|
Example
Here is an example of a Reference -> ColorReference (ref_refCol) link type:
import requests
url= "https://{{YOUR-PIM}}.quable.com.quable.com/api_1.php/documents/suede_shoe/links/ref_refCol"
payload= {
"mode" : "update", // or replace
"items": [{
"sequence" : 1,
"target_code" : "blue_suede_shoe"
},{
"sequence" : 2,
"target_code" : "red_suede_shoe"
}]
}
headers= {
'Content-Type': 'application/json',
'Authorization': 'Bearer ...'
}
response= requests.request("POST", url, headers=headers, data=payload)
The example demonstrates the addition of two links between the Reference parent document ("suede_shoe") and the ColorReference documents ("blue_suede_shoe" and "red_suede_shoe"). If one or both of these links already exists, nothing is changed. |
Edit Links - To edit existing links, use the
mode
:update
(see previous code example).Delete Links - To delete links, you can push an empty
items
array withmode
:replace
. This will replace the current links with the items in the payload (i.e., none).