Traceability API

Reference for ProductTraceability and ProcessingStage endpoints with automatic totals recalculation.

Traceability Records

MethodPathDescription
GET/api/traceabilityList records
POST/api/traceabilityCreate a record
PATCH/api/traceability/{id}Update a record

Processing Stages

MethodPathDescription
GET/api/processing-stagesList all stages
POST/api/processing-stagesCreate a stage
PATCH/api/processing-stages/{id}Update a stage
POST/api/processing-stages/bulkBulk upsert stages

POST /api/traceability

Shell
curl -X POST http://localhost:8080/api/traceability \
-H "Content-Type: application/json" \
-d '{ "company_product_id": 3, "status": "DRAFT" }'

POST /api/processing-stages/bulk

JSON
{
"stages": [
{ "traceability_id": 10, "stage_name": "Spinning", "stage_order": 1, "country_code": "IN" },
{ "traceability_id": 10, "stage_name": "Dyeing", "stage_order": 2, "country_code": "BD", "distance_km": 2200, "co2_kg": 0.18 }
]
}

After bulk insert, ProductTraceability.total_distance_km and total_co2_kg are automatically recalculated.