V1 and V2Products (V1)
Add products to a relationship
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.
| field | type | description |
|---|---|---|
| product_relationships | Array of objects | list with product and quantities |
A product_relationship object is defined by:
| field | type | description |
|---|---|---|
| product_id | string | product identifier |
| quantity | number | relationship quantity |
Response format
Successful responses will be returned in "data" array and will be in the form:
| field | type | description |
|---|---|---|
| relationship_id | string | relationship identifier |
| relationship_label | string | relationship label |
| related_products | array of object | related products |
A related_product object is defined by:
| field | type | description |
|---|---|---|
| product_id | string | related product identifier |
| quantity | number | current quantity |
| last_modified | date | last 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" } ]}