Returns the raw materials consumed (or planned) for a specific production order, including planned vs actual quantities and variance tracking.
GET/api/v1/orders/{order_id}/consumption
| Parameter | Type | Description |
|---|
order_id | string | The production order ID (UUID) |
curl -X GET "https://api.prediko.io/api/v1/orders/822417ae-8511-41dc-8b3a-18789a600414/consumption" \
-H "Authorization: Bearer YOUR_API_KEY"
order_id = "822417ae-8511-41dc-8b3a-18789a600414"
f"https://api.prediko.io/api/v1/orders/{order_id}/consumption",
headers={"Authorization": "Bearer YOUR_API_KEY"}
consumption = response.json()
const orderId = "822417ae-8511-41dc-8b3a-18789a600414";
const response = await fetch(
`https://api.prediko.io/api/v1/orders/${orderId}/consumption`,
headers: { "Authorization": "Bearer YOUR_API_KEY" }
const consumption = await response.json();
"order_id": "822417ae-8511-41dc-8b3a-18789a600414",
"raw_material_name": "DB-GD-DST",
"raw_material_id": "51510c11-d106-4771-8aca-a1aac99c1600",
"planned_quantity": 10.0,
"actual_quantity_used": 8.5,
"quantity_variance": -1.5,
"warehouse_name": "Main Warehouse"
| Field | Type | Description |
|---|
order_id | string | The production order ID |
data | array | List of raw material consumption entries |
| Field | Type | Description |
|---|
raw_material_name | string | Name of the raw material SKU |
raw_material_id | string | Unique identifier of the raw material SKU |
planned_quantity | number | Planned consumption quantity (recipe ratio x ordered qty) |
actual_quantity_used | number | Actual consumption quantity (auto-calculated or manually overridden) |
quantity_variance | number | actual_quantity_used - planned_quantity. Positive = loss/waste, negative = better yield, zero = exact match |
unit_cost | number | null | Cost per unit of the raw material |
total_cost | number | null | Total cost for this raw material in the order |
warehouse_name | string | null | Warehouse where the raw material is stored |
The quantity_variance field is computed automatically:
| Variance | Meaning | Example |
|---|
| Positive | Over-consumption (loss/waste: spillage, evaporation, defect) | Planned 100, used 108 → variance = +8 |
| Negative | Under-consumption (better yield than expected) | Planned 100, used 95 → variance = -5 |
| Zero | Production matched the recipe exactly | Planned 100, used 100 → variance = 0 |
Override the auto-calculated actual_quantity_used with the real measured value. This is required for accurate yield/waste tracking.
PUT/api/v1/orders/{order_id}/consumption
| Parameter | Type | Description |
|---|
order_id | string | The production order ID (UUID) |
| Field | Type | Required | Description |
|---|
raw_material_ids | array | Yes | List of raw material SKU IDs to update |
actual_quantity_used | number | Yes | Actual quantity consumed (must be > 0) |
curl -X PUT "https://api.prediko.io/api/v1/orders/822417ae-8511-41dc-8b3a-18789a600414/consumption" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
"raw_material_ids": ["51510c11-d106-4771-8aca-a1aac99c1600"],
"actual_quantity_used": 12.5
order_id = "822417ae-8511-41dc-8b3a-18789a600414"
f"https://api.prediko.io/api/v1/orders/{order_id}/consumption",
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json"
"raw_material_ids": ["51510c11-d106-4771-8aca-a1aac99c1600"],
"actual_quantity_used": 12.5
updated_consumption = response.json()
Returns the updated consumption data for the order (same format as GET).
"order_id": "822417ae-8511-41dc-8b3a-18789a600414",
"raw_material_name": "DB-GD-DST",
"raw_material_id": "51510c11-d106-4771-8aca-a1aac99c1600",
"planned_quantity": 10.0,
"actual_quantity_used": 12.5,
"quantity_variance": 2.5,
"warehouse_name": "Main Warehouse"
| Status | Description |
|---|
| 404 | Order not found |
| 401 | Invalid or missing API key |
| 500 | Internal server error |