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"
}
FieldDescription
task.station.codeThe station whose handler runs it
task.station.configThe run's config: the station's config with the run's overrides, frozen when it was queued
task.work_record.idThe run; send it back in complete or failed, and attach output to it
session_idEcho 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

StatusCodeMeaning
400MISSING_LOCATIONX-Location is required
401Invalid API key or secret
409LOCATION_IN_USEAnother session holds this location; the message names it