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

FieldTypeRequiredDescription
work_record_idstringYesFrom the poll response
workpiecesobjectYesWorkpiece 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

StatusCodeMeaning
400BAD_REQUESTInvalid JSON, no work_record_id, or workpieces is not an object
403FORBIDDENThe work record belongs to another org
404NOT_FOUNDNo such work record