5. Links

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 (ReferenceColorReferenceVariant), 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 MethodPOST
Query Parameters
{{document_code}}stringThe unique code of the parent document.
{{link_type_code}}stringThe unique code of the link type between the parent document? (Reference) and the child document? (ColorReference).
Request Body
Required Attributesitemsarray(objects) Array of objects to link. Each object is composed of:

  • target_code: the unique identifier of the target to link
  • sequence: the position you want to create the link
mode stringYou must choose one of the following two behaviors:

  • update - Default. Add the supplied elements to the parent document's existing links on the given link type.

  • replace - Replace all of the parent document's existing links on the given link type.

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 with mode: replace. This will replace the current links with the items in the payload (i.e., none).