Factory API
A factory session is a running factory process at one location. It polls the Orchestrator for the next queued run of a station on a line at that location, runs the station's handler, and reports back. The Orchestrator never calls a factory; every request starts on the factory's side.
You rarely call these endpoints yourself: @assemblyline/lib-factory does it for you
(startFactory()). They are documented so you can see what crosses the wire.
Authentication
Every request carries the org's API key:
| Header | Required | Purpose |
|---|---|---|
api-key | Yes | API key (starts with al_) |
api-secret | Yes | API secret |
X-Location | Poll only | The location this session serves; lines at this location are dispatched to it |
X-Factory-User-Agent | No | Machine fingerprint (package, host, user, pid). Sending it opens a factory session |
X-Factory-Session | No | Session id returned by the previous poll |
X-Exclude-Stations | No (poll only) | Codes of the stations the session is running now; their runs aren't claimed |
At most one factory session is active per org and location. A second session at the same
location is refused with 409 LOCATION_IN_USE, naming the session that holds it.
Endpoints
| Endpoint | Purpose |
|---|---|
GET /api/factory/poll | Claim the next queued run |
POST /api/factory/complete | Report a run's output |
POST /api/factory/failed | Report a failure (retried up to 3 times) |
POST /api/factory/attach-document | Attach a markdown document to the work record |
POST /api/factory/attach-report | Attach the run's report |
POST /api/factory/attach-file | Attach a binary file (xlsx, xls, pdf, csv, png, jpeg; 10 MB max) |
POST /api/factory/attach-workpieces | Record each workpiece's outcome: { "<workpiece_id>": "done" | "failed" } |
POST /api/factory/disconnect | End the session on shutdown so the location frees at once |
What crosses the wire
Workpieces stay in the factory's folders; the Orchestrator never sees them. It stores what the station's handler sends: the run's output, the report, attached documents and files, and the workpiece outcome map.