Saltar al contenido principal

Postman / cURL - Production Formulas & Production Runs

Use these cURL commands in Postman. You can ImportRaw text → paste a cURL, or create requests manually.

Base URL: http://localhost:4000 (or your VITE_PUBLIC_API_URL)

Auth: Bearer token (Firebase ID token) in the Authorization header.

Variables to replace:

  • {{BASE_URL}} – e.g. http://localhost:4000
  • {{TOKEN}} – Firebase ID token
  • {{BUSINESS_ID}} – UUID of your business
  • {{USER_ID}} – UUID of the user (createdBy)
  • {{LOCATION_ID}} – UUID of the location
  • {{PRODUCT_ID}} – UUID of a product
  • {{FORMULA_ID}} – UUID of a production formula (from create/list response)

Production Formulas

1. Create Production Formula

curl -X POST "{{BASE_URL}}/production-formulas" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer {{TOKEN}}" \
-d '{
"businessId": "{{BUSINESS_ID}}",
"createdBy": "{{USER_ID}}",
"name": "Bicycle Assembly",
"description": "Assemble 1 bicycle from frame and wheels",
"outputProductId": "{{PRODUCT_ID}}",
"outputQuantityPerBatch": 1,
"outputUomId": null,
"productionRunType": "assembly",
"inputs": [
{
"productId": "{{PRODUCT_ID}}",
"quantity": 1,
"uomId": null,
"sortOrder": 0
}
]
}'

productionRunType values: collection, processing, mixing, baking, packing, assembly, harvest, transfer


2. List Production Formulas

curl -X GET "{{BASE_URL}}/production-formulas?businessId={{BUSINESS_ID}}&page=1&size=50" \
-H "Authorization: Bearer {{TOKEN}}"

Optional query params: search (string), page (number), size (number)


3. Get Production Formula by ID

curl -X GET "{{BASE_URL}}/production-formulas/{{FORMULA_ID}}?businessId={{BUSINESS_ID}}" \
-H "Authorization: Bearer {{TOKEN}}"

4. Update Production Formula

curl -X PATCH "{{BASE_URL}}/production-formulas/{{FORMULA_ID}}?businessId={{BUSINESS_ID}}" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer {{TOKEN}}" \
-d '{
"updatedBy": "{{USER_ID}}",
"name": "Bicycle Assembly (Updated)",
"description": "Updated description",
"outputProductId": "{{PRODUCT_ID}}",
"outputQuantityPerBatch": 2,
"outputUomId": null,
"productionRunType": "assembly",
"inputs": [
{
"productId": "{{PRODUCT_ID}}",
"quantity": 2,
"uomId": null,
"sortOrder": 0
}
]
}'

All body fields are optional except updatedBy. Omitted fields keep their current values.


5. Expand Formula to Run Inputs/Outputs

Returns inputs and outputs for a given planned quantity and location.

curl -X GET "{{BASE_URL}}/production-formulas/{{FORMULA_ID}}/expand?businessId={{BUSINESS_ID}}&plannedOutputQuantity=10&locationId={{LOCATION_ID}}" \
-H "Authorization: Bearer {{TOKEN}}"

Production Runs

6. Create Production Run (manual inputs/outputs)

curl -X POST "{{BASE_URL}}/production-runs" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer {{TOKEN}}" \
-d '{
"businessId": "{{BUSINESS_ID}}",
"locationId": "{{LOCATION_ID}}",
"createdBy": "{{USER_ID}}",
"productionRunType": "assembly",
"runDate": "2026-02-17T00:00:00.000Z",
"status": "draft",
"notes": "",
"inputs": [
{
"productId": "{{PRODUCT_ID}}",
"locationId": "{{LOCATION_ID}}",
"quantity": 2,
"unitCost": 0,
"uomId": null,
"sortOrder": 0
}
],
"outputs": [
{
"productId": "{{PRODUCT_ID}}",
"quantity": 1,
"unitCost": 0,
"uomId": null,
"sortOrder": 0
}
]
}'

7. Create Production Run (from formula)

When productionFormulaId and plannedOutputQuantity are set, inputs and outputs are optional; the server expands the formula.

curl -X POST "{{BASE_URL}}/production-runs" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer {{TOKEN}}" \
-d '{
"businessId": "{{BUSINESS_ID}}",
"locationId": "{{LOCATION_ID}}",
"createdBy": "{{USER_ID}}",
"productionRunType": "assembly",
"runDate": "2026-02-17T00:00:00.000Z",
"status": "draft",
"productionFormulaId": "{{FORMULA_ID}}",
"plannedOutputQuantity": 10
}'

8. List Production Runs

curl -X GET "{{BASE_URL}}/production-runs?businessId={{BUSINESS_ID}}&locationId={{LOCATION_ID}}&page=1&size=20" \
-H "Authorization: Bearer {{TOKEN}}"

Optional query params:

  • statusdraft, in_progress, completed, cancelled
  • productionRunTypeassembly, mixing, etc.
  • runDateFrom, runDateTo – ISO date strings
  • createdAtFrom, createdAtTo – ISO date strings
  • search – text search

9. Get Production Run by ID

curl -X GET "{{BASE_URL}}/production-runs/{{RUN_ID}}" \
-H "Authorization: Bearer {{TOKEN}}"

10. Update Production Run

curl -X PATCH "{{BASE_URL}}/production-runs/{{RUN_ID}}" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer {{TOKEN}}" \
-d '{
"updatedBy": "{{USER_ID}}",
"status": "in_progress",
"notes": "Updated notes"
}'

11. Delete Production Run

curl -X DELETE "{{BASE_URL}}/production-runs/{{RUN_ID}}" \
-H "Authorization: Bearer {{TOKEN}}"

Getting a Firebase Token

  1. Log in to the PWA and open DevTools (F12).

  2. In the console:

    firebase.auth().currentUser.getIdToken().then(t => console.log(t))
  3. Or use the Firebase Auth REST API to exchange email/password for an ID token.


Postman Collection Variables

In Postman, set these collection/environment variables:

VariableExampleDescription
BASE_URLhttp://localhost:4000API base URL
TOKENeyJhbGciOiJSUzI1NiIs...Firebase ID token
BUSINESS_IDxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxBusiness UUID
USER_IDxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxUser UUID
LOCATION_IDxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxLocation UUID
PRODUCT_IDxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxProduct UUID
FORMULA_IDxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxFormula UUID
RUN_IDxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxRun UUID

Then use {{VARIABLE_NAME}} in the URL and body.