Creating Composite Products
Creating Composite Products
To create a composite product via the API, products need to exist to use as the composite components. For this example, we will create two new products. You can use any existing products in your account. It's important to remember you can not nest composite products.
Creating new simple products
To create a new product, you send a POST
request to the https://<<domain_prefix>>.retail.lightspeed.app/api/2.0/products
endpoint with the following payload:
NOTE: This is the minimal payload required for creating a new product:
{
"name": "Composite Component 1",
}
Here is the response that you will receive after this request:
{
"data": [
"7cea940d-28fb-4088-822b-d20b098095fc"
]
}
You send a similar request for a second product.
{
"name": "Composite Component 2",
}
and its response:
{
"data": [
"42ca6417-e0eb-4190-a5a7-e6047151396b"
]
}
Creating the composite product
Now that we have products to use as components, we can make the request to create the composite.
Just like in a case of simple products, a composite is created by sending a POST
request to the https://<<domain_prefix>>.retail.lightspeed.app/api/2.0/products
endpoint. The minimal payload should look like this:
{
"name": "Composite Product",
"composite": [{
"product_id": "7cea940d-28fb-4088-822b-d20b098095fc",
"quantity": 2
},{
"product_id": "42ca6417-e0eb-4190-a5a7-e6047151396b",
"quantity": 1
}]
}
The API will respond with the following payload:
{
"data": [
"765d2013-216d-45d9-aa33-613eabd5f4f0"
]
}
As you've noticed, these APIs only return the IDs of the created products. You can hit the other product endpoints to get the full representation. GET
https://<<domain_prefix>>.retail.lightspeed.app/api/3.0/products/765d2013-216d-45d9-aa33-613eabd5f4f0
{
"data": {
"id": "765d2013-216d-45d9-aa33-613eabd5f4f0",
"classification": "composite",
"name": "Composite Product",
"description": "",
"is_active": true,
"tracks_inventory": true,
"version": 27791249177,
"created_at": "2023-02-24T03:02:05Z",
"updated_at": "2023-02-24T03:02:05Z",
"deleted_at": null,
"product_type_id": null,
"brand_id": null,
"tag_ids": [],
"suppliers": [],
"sku_number": "12084",
"product_codes": [
{
"id": "585988a6-1a93-4935-b712-9aed231884f3",
"type": "CUSTOM",
"code": "12084"
}
],
"account_code_sales": null,
"account_code_purchase": null,
"attributes": {},
"price_standard": null,
"price_outlet": {
"tax_exclusive": "0",
"loyalty_amount": null,
"outlets": [
{
"tax_id": "06c2f1bf-e9ca-11e9-efcf-bfc9d7444ac2",
"is_default": true,
"tax_inclusive": "0"
},
{
"tax_id": "06564c2b-6841-11eb-f2da-cd4d779bcf1a",
"is_default": true,
"tax_inclusive": "0"
}
]
},
"images": [],
"composite_bom": {
"42ca6417-e0eb-4190-a5a7-e6047151396b": "1",
"7cea940d-28fb-4088-822b-d20b098095fc": "2"
},
"variants": []
}
}
WARNING: An important thing to remember, related to composite products is that a product used as a composite child, cannot be deleted. Before that product can be deleted, it needs to be removed from all composites it is in, or those composites need to be deleted.
Updated 6 months ago