E087: Create BOM
POST /api/boms
Creates the recipe linking input materials and input SKUs to an output SKU. Triggered from the BOM page or from BOM Detail for a SKU that doesn't yet have a recipe. The header and items are inserted atomically.
Authentication
Standard tenant route. Requires Authorization: Bearer <firebase-id-token> and X-Org-Id: <org-id>. Access: Member.
Request
{
"outputSkuId": "uuid",
"items": [
{ "materialId": "uuid", "quantity": 2.0 },
{ "inputSkuId": "uuid", "quantity": 1 }
]
}
Each item is a material input (materialId) or a sub-assembly SKU input (inputSkuId) — exactly one, never both — with quantity > 0. Multi-level BOMs are supported: a sub-SKU input has its own BOM, which the cost cascade recurses through.
Response — 201 Created
{
"outputSkuId": "uuid",
"items": [ BomItem ]
}
Each BomItem is { "id", "orgId", "skuId", "materialId", "inputSkuId", "quantity", "createdAt" } (one of materialId / inputSkuId is null).
Errors
| HTTP | code | Condition |
|---|---|---|
| 404 | not_found | Output SKU, or an input material/SKU, not found. |
| 422 | validation_failed | SKU already has a BOM (duplicate), or shape invalid (item not exactly one of materialId / inputSkuId, quantity <= 0, self-reference where input SKU equals output SKU). |
Workflow
Calls W087 Create BOM.