Create a Relationship between a Product with one or more Products
POST/pcm/products/:productID/custom-relationships/:customRelationshipSlug
- You can associate a product with up to 2000 other products.
- You do not need to attach a custom relationship to products beforehand, this will be done automatically by this endpoint.
- This is a partial update, so if you make a request to this endpoint multiple times with different products in each request, they will not be overwritten but will be appended to the related products list.
If you want to remove a relationship between products, see Delete a Relationship between a product with one or more products.
Prerequisites
- A Custom Relationship has been created, see create a Custom Relationship.
- A Product has been created for the relationship to be based from.
- One or many Product have been created for the product to relate to.
Request
Path Parameters
A unique identifier for the product.
A custom relationship slug.
- application/json
Body
- Array [
- ]
data object[]required
The ID of the product you want to relate.
Possible values: [product
]
This represents the type of resource being returned. Always product
.
attributes object
The order in which the product to product should be displayed in relation to others. A lower value represents a higher priority in the display order. If set to NULL, the sort order will be removed.
Responses
- 201
- 400
- 403
- 404
- 409
- 422
- 500
Returns information related to associated products.
- application/json
- Schema
- Example (from schema)
- create-product-association
Schema
- Array [
- ]
meta object
A list of product IDs that have been successfully associated with this custom relationship.
products_not_associated object[]
A list of products that could not be associated, including the reasons why.
The ID of the product that could not be associated.
Details about why the product could not be associated.
The owner of the resource.
timestamps object
The date and time the resource was created.
The date and time the resource was last updated.
{
"meta": {
"associated_products": [
"68c48149-0e94-4ef2-93d5-8d5f3774980a",
"ab4826d1-4a5a-4951-a2a5-98058899f891"
],
"products_not_associated": [
{
"ID": "97b7fac2-91dd-4755-81b0-bdffe8e7eabd",
"Details": "could not find product"
},
{
"ID": "a0ef3291-2ec1-4d7d-9d6d-1705ae01bb99",
"Details": "product already has 5 custom relationships, cannot associate more as it has reached the limit of 5 custom relationships"
},
{
"ID": "bde79675-4783-40b7-8a7e-ac6df41459c6",
"Details": "product already has 5 custom relationships, cannot associate more as it has reached the limit of 5 custom relationships"
},
{
"ID": "aaddd5f4-a5f8-42e8-be9a-097986f22e58",
"Details": "exceeded maximum allowed associations (2000). Please review and try again"
}
],
"owner": "store",
"timestamps": {
"created_at": "2024-08-08T09:29:08.295Z",
"updated_at": "2024-08-08T09:29:08.295Z"
}
}
}
{
"meta": {
"associated_products": [
"68c48149-0e94-4ef2-93d5-8d5f3774980a",
"ab4826d1-4a5a-4951-a2a5-98058899f891"
],
"products_not_associated": [
{
"ID": "97b7fac2-91dd-4755-81b0-bdffe8e7eabd",
"Details": "could not find product"
},
{
"ID": "a0ef3291-2ec1-4d7d-9d6d-1705ae01bb99",
"Details": "product already has 5 custom relationships, cannot associate more as it has reached the limit of 5 custom relationships"
},
{
"ID": "bde79675-4783-40b7-8a7e-ac6df41459c6",
"Details": "product already has 5 custom relationships, cannot associate more as it has reached the limit of 5 custom relationships"
},
{
"ID": "aaddd5f4-a5f8-42e8-be9a-097986f22e58",
"Details": "product exceeds the maximum limit of associated products (2000). Please review and try again"
}
],
"owner": "store",
"timestamps": {
"created_at": "2024-08-08T09:29:08.295Z",
"updated_at": "2024-08-08T09:29:08.295Z"
}
}
}
Bad request. The request failed validation.
- application/json
- Schema
- Example (from schema)
- bad-request
Schema
- Array [
- ]
errors undefined[]required
The HTTP response code of the error.
A brief summary of the error.
Optional additional detail about the error.
Internal request ID.
Additional supporting meta data for the error.
{
"errors": [
{
"status": "500",
"title": "Internal server error",
"detail": "An internal error has occurred.",
"request_id": "00000000-0000-0000-0000-000000000000",
"meta": {
"missing_ids": [
"e7d50bd5-1833-43c0-9848-f9d325b08be8"
]
}
}
]
}
{
"errors": [
{
"title": "Bad Request",
"detail": "Could not parse the supplied filter",
"status": "400"
}
]
}
Forbidden
- application/json
- Schema
- Example (from schema)
- internal-server-error
Schema
- Array [
- ]
errors undefined[]required
The HTTP response code of the error.
A brief summary of the error.
Optional additional detail about the error.
Internal request ID.
Additional supporting meta data for the error.
{
"errors": [
{
"status": "500",
"title": "Internal server error",
"detail": "An internal error has occurred.",
"request_id": "00000000-0000-0000-0000-000000000000",
"meta": {
"missing_ids": [
"e7d50bd5-1833-43c0-9848-f9d325b08be8"
]
}
}
]
}
{
"errors": [
{
"title": "Forbidden",
"status": "403",
"detail": "entity owned by organization"
}
]
}
Bad Request. Not Found.
- application/json
- Schema
- Example (from schema)
- internal-server-error
Schema
- Array [
- ]
errors undefined[]required
The HTTP response code of the error.
A brief summary of the error.
Optional additional detail about the error.
Internal request ID.
Additional supporting meta data for the error.
{
"errors": [
{
"status": "500",
"title": "Internal server error",
"detail": "An internal error has occurred.",
"request_id": "00000000-0000-0000-0000-000000000000",
"meta": {
"missing_ids": [
"e7d50bd5-1833-43c0-9848-f9d325b08be8"
]
}
}
]
}
{
"errors": [
{
"title": "Not Found",
"status": "404"
}
]
}
Write conflict detected
- application/json
- Schema
- Example (from schema)
- internal-server-error
Schema
- Array [
- ]
errors undefined[]required
The HTTP response code of the error.
A brief summary of the error.
Optional additional detail about the error.
Internal request ID.
Additional supporting meta data for the error.
{
"errors": [
{
"status": "500",
"title": "Internal server error",
"detail": "An internal error has occurred.",
"request_id": "00000000-0000-0000-0000-000000000000",
"meta": {
"missing_ids": [
"e7d50bd5-1833-43c0-9848-f9d325b08be8"
]
}
}
]
}
{
"errors": [
{
"title": "Conflict",
"status": "409",
"detail": "write conflict detected"
}
]
}
Bad request. The request failed validation.
- application/json
- Schema
- Example (from schema)
- failed-validation
Schema
- Array [
- ]
errors undefined[]required
The HTTP response code of the error.
A brief summary of the error.
Optional additional detail about the error.
Internal request ID.
Additional supporting meta data for the error.
{
"errors": [
{
"status": "500",
"title": "Internal server error",
"detail": "An internal error has occurred.",
"request_id": "00000000-0000-0000-0000-000000000000",
"meta": {
"missing_ids": [
"e7d50bd5-1833-43c0-9848-f9d325b08be8"
]
}
}
]
}
{
"errors": [
{
"title": "Failed Validation",
"status": "422",
"detail": "<XYZ> can not be empty"
}
]
}
Internal server error. There was a system failure in the platform.
- application/json
- Schema
- Example (from schema)
- internal-server-error
Schema
- Array [
- ]
errors undefined[]required
The HTTP response code of the error.
A brief summary of the error.
Optional additional detail about the error.
Internal request ID.
Additional supporting meta data for the error.
{
"errors": [
{
"status": "500",
"title": "Internal server error",
"detail": "An internal error has occurred.",
"request_id": "00000000-0000-0000-0000-000000000000",
"meta": {
"missing_ids": [
"e7d50bd5-1833-43c0-9848-f9d325b08be8"
]
}
}
]
}
{
"errors": [
{
"status": "500",
"title": "Internal Server Error",
"detail": "There was an internal server error, you can report with your request id.",
"request_id": "635da56d-75a1-43cd-b696-7ab119756b3a"
}
]
}