Skip to content

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 with 422.
  • Unit counts (product stock, planned and produced units) are integers.
  • Status values are text. More values may be added.
  • PATCH changes only the fields sent. What null does depends on the entry: for raw materials, lots, recipes and packaging, null clears an optional field. For goods receipt (deliveries and items), null keeps the current value, as in the app. For products, null clears only packaging_id, mwst_rate_id and stage_template_id; other fields answer 422.

Raw materials and lots

EndpointContent
GET /api/v1/production/raw-materialsRaw 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}/lotsCreate 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}/auditA 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.

Terminal window
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

EndpointPurpose
GET, POST /api/v1/production/goods-in/deliveriesDeliveries 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/recordsSingle 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}/approveApprove (all required tests passed)
POST …/records/{record_id}/rejectReject, optionally with a reason
POST …/records/{record_id}/finalizeComplete + 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}/attachmentsAttach 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-typesThe 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

EndpointPurpose
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/productsCreate 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}/variantsA new variant in the same group
POST …/{product_id}/move-to-group, POST …/{product_id}/leave-groupMove 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-adjustmentsStock 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

EndpointContent
/api/v1/production/categoriesCategories: edit name and order. The SKU range is numbering and stays in the app.
/api/v1/production/packagingEdit Packaging
/api/v1/production/variant-labelsEdit Variant Labels
/api/v1/production/aroma-tagsThe raw materials’ aroma tags
/api/v1/production/originsRead and create origins
GET /api/v1/production/vat-rates, /material-states, /bbf-rules, /stage-templates, /field-templatesSettings, 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: status in_progress, with current_stage and is_paused
  • Yield: units_actual divided by units_planned
  • Time per stage: started_at to completed_at in the stage log
  • Cost per unit: cost_per_unit
  • Missing raw materials in a running batch: items with qty_consumed null

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

StatusCodeMeaning
409goods_in_not_draftThe item is no longer a draft and can no longer be changed.
409goods_in_wrong_statusApprove, reject or complete does not fit the status (for example tests still open).
409lot_already_usedThe item’s lot was already used.
409raw_material_in_useA recipe or batch uses the raw material.
409product_in_useA recipe, batch or bundle uses the product.
409recipe_in_useBatches were made from the recipe.
409product_has_recipeThe product already has a recipe.
409sku_takenThe SKU is already used.
409name_takenThe name is already used (category, variant label).
403plan_limit_reachedThe plan allows no more products or raw materials.
422use_stock_correctionChange stock only through a stock correction.
422attachment_type_not_allowed, attachment_too_largeA file is not a PDF or image, empty, or larger than 10 MB (15 MB raw upload).
413storage_fullThe business’s storage is full.
422validation_errorInvalid request, for example a quantity as a JSON number or a missing reason.
404not_foundThe entry or a linked entry does not exist (also: belongs to another business).

What’s next