Production reference
Reference for the Production endpoints. All paths start with https://<your-instance>/api/v1. Every request carries Authorization: Bearer hek_…. Formats, paging, deletion lists and error codes are on Conventions.
Reading needs read permission on the Production module, every writing request needs write permission (otherwise 403 with no_write_permission).
What the API may do here
- Edit: Raw materials, lots (the stock of one delivery), Goods receipt up to completion, products with variants and bundles, product stock, recipes and the master data Categories, Packaging, Variant Labels, aroma tags and origins.
- Read: every batch with its items, stages, scans, pauses, output and cost, plus the settings (VAT rates, material states, best-before rules, stage templates, custom fields).
Production itself runs in the app. Planning, starting, scanning, weighing, pausing and completing batches happens in the app and the companion. Through the API, batches are read only: enough for a KPI screen on the production floor or your own app that helps next to the companion. Shopify and Galaxus sync, labels and settings also stay in the app.
Formats in this module
- Quantities, weights, prices, costs and nutrition values are decimal strings without trailing zeros (
"9.5","0.4235"). Numbers sent as JSON numbers are refused with422. - Unit counts (product stock, planned and produced units) are integers.
- Status values are text. More values may be added.
PATCHchanges only the fields sent. Whatnulldoes depends on the entry: for raw materials, lots, recipes and packaging,nullclears an optional field. For goods receipt (deliveries and items),nullkeeps the current value, as in the app. For products,nullclears onlypackaging_id,mwst_rate_idandstage_template_id; other fields answer422.
Raw materials and lots
| Endpoint | Content |
|---|---|
GET /api/v1/production/raw-materials | Raw materials with unit, stock, threshold, below_threshold, nutrition values and aroma tags. Parameters: in_use, stock_tracked, below_threshold=true, name. |
POST, PATCH, DELETE /api/v1/production/raw-materials/{raw_material_id} | Create, change, delete. Aroma tags as a list of names (aroma_tags); the list replaces the previous one. |
GET /api/v1/production/lots and /{lot_id} | Lots with label id, supplier lot, amount, stock, cost, best-before and certificates. Parameters: raw_material_id, in_use, has_stock, best_before_before, best_before_after. |
GET /api/v1/production/lots/by-ghid/{ghid} | The lot for a scanned label id, as in the companion |
POST /api/v1/production/raw-materials/{raw_material_id}/lots | Create a lot by hand, as in the app (stock rises by its amount) |
PATCH, DELETE /api/v1/production/lots/{lot_id} | Change a lot (not its stock) or delete it |
GET /api/v1/production/lots/{lot_id}/audit | A lot’s audit log |
A raw material’s stock is the sum of its lots, converted to its unit. It is never written directly: a deleted lot leaves the stock, and a new unit converts the stock.
Correcting stock
Every stock change through the API needs a reason and is recorded in the audit log, with the key’s name.
curl -X POST "https://<your-instance>/api/v1/production/lots/7c1e…/stock-corrections" \ -H "Authorization: Bearer hek_…" \ -H "Content-Type: application/json" \ -d '{"new_stock": "1.5", "reason": "November stocktake"}'Response: the lot with its new current_stock. The raw material’s stock is recalculated (a lot in kg on a material kept in g counts correctly). current_stock in a normal PATCH is refused with 422 and use_stock_correction.
Goods receipt
| Endpoint | Purpose |
|---|---|
GET, POST /api/v1/production/goods-in/deliveries | Deliveries with their items. POST creates a delivery and a draft per item. |
GET, PATCH, DELETE /api/v1/production/goods-in/deliveries/{delivery_id} | One delivery |
GET, POST /api/v1/production/goods-in/records | Single items. Parameters: status, raw_material_id, delivery_id, received_from, received_to. |
PATCH, DELETE /api/v1/production/goods-in/records/{record_id} | Change an item in draft; delete as in the app |
PUT /api/v1/production/goods-in/records/{record_id}/tests/{test_type_id} | Enter a test result: pass, fail or na |
POST …/records/{record_id}/approve | Approve (all required tests passed) |
POST …/records/{record_id}/reject | Reject, optionally with a reason |
POST …/records/{record_id}/finalize | Complete + create lot: the item is booked, the lot is created and the raw material’s stock rises, exactly as in the app |
POST …/records/{record_id}/attachments | Attach photos or PDFs (field files, at most 20 files, PDFs at most 10 MB, images reduced to 1600 px and then at most 10 MB, PDF, JPEG, PNG, TIFF, WebP or HEIC) |
GET /api/v1/production/goods-in/attachments/{attachment_id} | Download an attachment |
GET /api/v1/production/goods-in/test-types | The test types |
Deleting a completed item takes its lot back out of stock, as in the app. If the lot was already used, the API answers 409 with lot_already_used.
Products
| Endpoint | Purpose |
|---|---|
GET /api/v1/production/products and /{product_id} | Products with every field of the app: the variant (SKU, GTIN, weights, prices, stock) and its group’s texts, nutrition values, ingredients, images and custom fields. Parameters: status, sku, gtin, category_id, is_bundle, variant_group_id. |
POST /api/v1/production/products | Create a product (sku and title_de required). New products start as draft. |
PATCH /api/v1/production/products/{product_id} | Change it. Group texts change for every variant of the group. null clears only packaging_id, mwst_rate_id and stage_template_id. |
POST …/{product_id}/variants | A new variant in the same group |
POST …/{product_id}/move-to-group, POST …/{product_id}/leave-group | Move a variant into another group or take it out of its group |
POST …/{product_id}/components, DELETE …/components/{component_id} | A bundle’s components |
GET, POST …/{product_id}/stock-adjustments | Stock history and correcting stock (new_stock, reason) |
DELETE /api/v1/production/products/{product_id} | Delete, as long as no recipe, batch or bundle uses the product |
A stock correction is not sent to Shopify automatically, exactly as in the app: the app syncs shop stock when a batch is completed. As in the app, the plan’s product limit applies (403 with plan_limit_reached), for raw materials too.
Recipes
GET, POST /api/v1/production/recipes and GET, PATCH, DELETE /api/v1/production/recipes/{recipe_id}
A recipe has a yield (yield_amount, yield_unit) and items (raw material, quantity, unit, optional stage_code). stage_code is the code of a process step from the product’s stage template; null means no step. A code the product doesn’t have answers 422. Every change raises version by one; items sent replace the previous ones. A product has at most one recipe (409 with product_has_recipe). A recipe batches were made from cannot be deleted (409 with recipe_in_use).
Master data and settings
| Endpoint | Content |
|---|---|
/api/v1/production/categories | Categories: edit name and order. The SKU range is numbering and stays in the app. |
/api/v1/production/packaging | Edit Packaging |
/api/v1/production/variant-labels | Edit Variant Labels |
/api/v1/production/aroma-tags | The raw materials’ aroma tags |
/api/v1/production/origins | Read and create origins |
GET /api/v1/production/vat-rates, /material-states, /bbf-rules, /stage-templates, /field-templates | Settings, read only |
Batches (read only)
GET /api/v1/production/batches and GET /api/v1/production/batches/{batch_id}
Parameters: status (planned, in_progress, on_hold, completed, cancelled), product_id, current_stage, production_date_from, production_date_to, completed_from, completed_to (days in the company time zone), limit, cursor, updated_since.
Each batch shows product, status, current stage, planned and produced units (units_planned, units_actual), start, end, pauses (is_paused, total_pause_seconds), raw material cost and cost per unit, plus its items (planned and consumed, lot), stage log and scans.
KPI screen
A screen on the production floor calls GET /api/v1/production/batches?updated_since=… every 30 to 60 seconds and computes, for example:
- Running batches:
statusin_progress, withcurrent_stageandis_paused - Yield:
units_actualdivided byunits_planned - Time per stage:
started_attocompleted_atin the stage log - Cost per unit:
cost_per_unit - Missing raw materials in a running batch: items with
qty_consumednull
A scan or a stage change in the companion counts as a change to the batch and shows up on the next call. Materials running low in stock: GET /api/v1/production/raw-materials?below_threshold=true.
Error codes in this module
| Status | Code | Meaning |
|---|---|---|
409 | goods_in_not_draft | The item is no longer a draft and can no longer be changed. |
409 | goods_in_wrong_status | Approve, reject or complete does not fit the status (for example tests still open). |
409 | lot_already_used | The item’s lot was already used. |
409 | raw_material_in_use | A recipe or batch uses the raw material. |
409 | product_in_use | A recipe, batch or bundle uses the product. |
409 | recipe_in_use | Batches were made from the recipe. |
409 | product_has_recipe | The product already has a recipe. |
409 | sku_taken | The SKU is already used. |
409 | name_taken | The name is already used (category, variant label). |
403 | plan_limit_reached | The plan allows no more products or raw materials. |
422 | use_stock_correction | Change stock only through a stock correction. |
422 | attachment_type_not_allowed, attachment_too_large | A file is not a PDF or image, empty, or larger than 10 MB (15 MB raw upload). |
413 | storage_full | The business’s storage is full. |
422 | validation_error | Invalid request, for example a quantity as a JSON number or a missing reason. |
404 | not_found | The entry or a linked entry does not exist (also: belongs to another business). |