How to manage variants using Management API
The variant concept in Bluestone PIM involves a variant group product with link to one or more variant products. Some systems call this mother and child or product and item.
The advantage of working with variants is that common attributes can be managed on the variant group level and inherited by the variants.
This article does not contain details about creating products, see this article for more information about that.
Create a variant group product
URL
POST https://api.bluestonepim.com/pim/products
Request body
{
"type": "GROUP",
"name": "Shirt",
"number": "shirt-1",
"description": "This is a description of a shirt"
}
Response
If successful, this will result in a 201 - Created response.
The response headers will include a resource-id with the GUID of the newly created product.
Create a variant product
Create the variants as SINGLE products. PIM will automatically change them to VARIANT once they have been added to a group.
URL
POST https://api.bluestonepim.com/pim/products
Request body
{
"type": "SINGLE",
"name": "Red shirt",
"number": "shirt-1-red",
"description": ""
}
Response
If successful, this will result in a 201 - Created response.
The response headers will include a resource-id with the GUID of the newly created product.
Assign variant to variant group
This endpoint must be called for each variant in the group.
URL
PUT https://api.bluestonepim.com/pim/products/{id}/variants/{variantProductId}
- id: Variant group id
- variantProductId: Variant product id
Request body
No request body
Response
Returns "204 - No content" if successful
Unassign variant from variant group
This endpoint must be called for each variant in the group.
Note! A variant unassigned from a group will be changed to type 'Single'.
URL
DELETE
https://api.bluestonepim.com/pim/products/{id}/variants/{variantProductId}
- id: Variant group's ID
- variantProductId: Variant product's ID
Request body
No request body
Response
Returns "204 - No content" if successful