V1 and V2Products (V1)

Add products to a relationship

POST
/api/v1/products/{product_id}/relationships/{relationship_id}

Assign products to an existing relationship

Behaviour

  • If any of the given products already exists in the relationship, its quantity will be updated
  • If any of the given products does not exist in the relationship, it will be inserted

A 201 Created status code is returned upon success

A 200 OK status code is returned if no updates in the requested relationships were performed

Request format

To assing a product to any relationship, the id of the product to be related along with its quantity must be provided.

fieldtypedescription
product_relationshipsArray of objectslist with product and quantities

A product_relationship object is defined by:

fieldtypedescription
product_idstringproduct identifier
quantitynumberrelationship quantity

Response format

Successful responses will be returned in "data" array and will be in the form:

fieldtypedescription
relationship_idstringrelationship identifier
relationship_labelstringrelationship label
related_productsarray of objectrelated products

A related_product object is defined by:

fieldtypedescription
product_idstringrelated product identifier
quantitynumbercurrent quantity
last_modifieddatelast modification date

Example:

{    "data": [        {            "related_products": [                {                    "last_modified": "2019-09-24T17:28:07.329000+00:00",                    "product_id": "5d6cfa8ae36dc76b0e5df8dd",                    "quantity": 1                },                {                    "last_modified": "2019-09-24T17:28:07.329000+00:00",                    "product_id": "5d6cfa8aedd44295ac5df8de",                    "quantity": 3                }            ],            "relationship_id": "5d8a50b547397aea2a603079",            "relationship_label": "contains"        }    ]}

Authorization

bearerAuth
AuthorizationBearer <token>

Obtain a token via POST /auth/api/get-token (15 minute lifetime), then send it as Authorization: Bearer <token>.

In: header

Path Parameters

product_id*string
relationship_id*string

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

Response Body

application/json

application/json

application/json

curl -X POST 'https://example.com/api/v1/products/string/relationships/string' \  -H 'Content-Type: application/json' \  --data-raw '{  "product_relationships": [    {      "quantity": 1,      "product_id": "5d0baf07d4bf5513d190245f"    },    {      "quantity": 9,      "product_id": "5d0baf07d4bf5513d1902460"    },    {      "quantity": 6,      "product_id": "5d0baf07d4bf5513d1902461"    },    {      "quantity": 1,      "product_id": "5d0baf07d4bf5513d1902462"    }  ]}'
{  "data": [    {      "related_products": [        {          "last_modified": "2023-08-22T10:06:56.535000+00:00",          "product_id": "64df58d393861834c7ffcacb",          "quantity": 1        },        {          "last_modified": "2023-08-22T10:05:07.255000+00:00",          "product_id": "64df58d34f8bba397effcacd",          "quantity": 1        }      ],      "relationship_id": "64e485f90fc35b27e41c2367",      "relationship_label": "relationship"    }  ]}