Attach Workpieces
POST /api/factory/attach-workpieces
Records which workpieces the run handled and how each one ended: done or failed. The
Orchestrator stores the map on the work record as workpieces, counts the values into
done_count and failed_count, and keeps nothing else about the workpieces: their files stay
in the factory. Calling it again replaces the map and both counts.
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
work_record_id | string | Yes | From the poll response |
workpieces | object | Yes | Workpiece id → "done" or "failed". {} is valid: a run with no workpieces. |
{
"work_record_id": "Rk7pW2qLm9Xa",
"workpieces": { "inv-1001": "done", "inv-1002": "failed" }
}
A value other than done or failed is stored, but neither count includes it.
attachWorkpieces(work_record_id, workpieces) in @assemblyline/lib-factory calls this.
Response
{ "success": true, "done_count": 1, "failed_count": 1 }
Errors
| Status | Code | Meaning |
|---|---|---|
400 | BAD_REQUEST | Invalid JSON, no work_record_id, or workpieces is not an object |
403 | FORBIDDEN | The work record belongs to another org |
404 | NOT_FOUND | No such work record |