Create Work Record

POST /api/v1/work-records

Creates a new work record for the station. It records a run; it doesn't queue one, so no factory session runs it. To run a station, use Run Station.

Request Body

FieldTypeRequiredDescription
stationstringYesID or short code of the station
statusstringNoDefault pending
output, started_at, completed_at, performed_by, errorNoStored as sent

Example Request

curl -X POST "https://orchestrator.assemblyline.sh/api/v1/work-records" \
  -H "api-key: al_xxxxxxxxxxxx" \
  -H "api-secret: xxxxxxxxxxxxxxxx" \
  -H "Content-Type: application/json" \
  -d '{
    "station": "st_def456"
  }'

Response

Returns the created work record with status 201 Created:

{
  "data": {
    "id": "wr_xyz789abc",
    "station": "st_def456",
    "status": "pending",
    "output": null,
    "started_at": null,
    "completed_at": null,
    "performed_by": "api_key_name",
    "error": null,
    "created_at": "2024-01-15T10:30:00Z"
  }
}

Run a Station and Wait

# 1. Trigger a station run (creates the work record)
WR_RESPONSE=$(curl -s -X POST "https://orchestrator.assemblyline.sh/api/v1/stations/st_invoice_validation/run" \
  -H "api-key: $API_KEY" \
  -H "api-secret: $API_SECRET")

WR_ID=$(echo $WR_RESPONSE | jq -r '.data.work_record_id')

# 2. Poll for completion
while true; do
  STATUS=$(curl -s -X GET "https://orchestrator.assemblyline.sh/api/v1/work-records/$WR_ID" \
    -H "api-key: $API_KEY" \
    -H "api-secret: $API_SECRET" | jq -r '.data.status')

  echo "Status: $STATUS"

  if [ "$STATUS" = "completed" ] || [ "$STATUS" = "failed" ]; then
    break
  fi

  sleep 1
done

Errors

CodeDescription
400Validation error (missing station)
401Invalid or missing API credentials
403API key lacks work_records:create permission
404Station not found

Validation Error Response

{
  "error": {
    "code": "VALIDATION_ERROR",
    "message": "station is required"
  }
}
{
  "error": {
    "code": "VALIDATION_ERROR",
    "message": "station is required"
  }
}

See Also