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
| Field | Type | Required | Description |
|---|---|---|---|
station | string | Yes | ID or short code of the station |
status | string | No | Default pending |
output, started_at, completed_at, performed_by, error | No | Stored 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
| Code | Description |
|---|---|
400 | Validation error (missing station) |
401 | Invalid or missing API credentials |
403 | API key lacks work_records:create permission |
404 | Station not found |
Validation Error Response
{
"error": {
"code": "VALIDATION_ERROR",
"message": "station is required"
}
}
{
"error": {
"code": "VALIDATION_ERROR",
"message": "station is required"
}
}
See Also
- Get Work Record — check execution status
- Work Record Object — understand output structure
- Work Record Object — statuses, retries and how a run is queued and claimed