Poll for Tasks
GET /api/factory/poll
Claims the oldest queued run (a work record) of a station on a line at X-Location, in the
key's org, and marks it running. Concurrent polls never claim the same run.
Send X-Exclude-Stations with the codes of the stations the session is running now, comma
separated: their runs are skipped, so a station never runs twice at once.
Example Request
curl "https://orchestrator.assemblyline.sh/api/factory/poll" \
-H "api-key: al_xxxxxxxxxxxxxxxxxx" \
-H "api-secret: xxxxxxxxxxxxxxxxxxxxxxxx" \
-H "X-Location: office-mac" \
-H "X-Factory-User-Agent: factory-acme/0.1.0 (darwin arm64; office-mac; acme; pid:4242)" \
-H "X-Exclude-Stations: EX1"
Response - Run Available
{
"task": {
"station": {
"code": "EX0",
"config": { "source_dir": "samples" }
},
"work_record": {
"id": "wr8Hn2QpLx1c"
},
"org_id": "acme00000001"
},
"session_id": "Ys7dK2mQ9wPz"
}
| Field | Description |
|---|---|
task.station.code | The station whose handler runs it |
task.station.config | The run's config: the station's config with the run's overrides, frozen when it was queued |
task.work_record.id | The run; send it back in complete or failed, and attach output to it |
session_id | Echo it as X-Factory-Session on later requests |
Response - Nothing To Do
{ "task": null, "session_id": "Ys7dK2mQ9wPz" }
Response - Session Closed
{ "task": null, "session_id": null, "session_closed": true }
The session was closed from the Orchestrator (Settings → Factory sessions). The factory session should exit; when it starts again it opens a new session.
Errors
| Status | Code | Meaning |
|---|---|---|
400 | MISSING_LOCATION | X-Location is required |
401 | Invalid API key or secret | |
409 | LOCATION_IN_USE | Another session holds this location; the message names it |