The Jobs API allows you to programmatically create and execute analysis jobs in Orion. Jobs are created from templates and can be monitored for completion status.
Job Lifecycle
Get templates
Retrieve available assignment templates that define the analysis
configuration.
Create a job
Create a new job from a template, optionally providing template variables.
Run the job
Start execution of the created job using its assignment ID.
Monitor status
Poll the status endpoint to track job progress until completion.
Retrieve results
Once complete, fetch the analysis results as formatted markdown.
Job States
Jobs progress through the following states:
| State | Description |
|---|
draft | Job created but not yet started |
queued | Job waiting to be executed |
active | Job is being prepared for execution |
executing | Analysis is actively running |
completed | Job finished successfully |
canceled | Job was canceled before completion |
Endpoints
Example: Complete Job Workflow
# 1. Get available templates
TEMPLATES=$(curl -X GET '/v1alpha/jobs/templates' \
-H "Authorization: Bearer $TOKEN")
# 2. Create a job from a template
ASSIGNMENT_ID=$(curl -X POST '/v1alpha/jobs/' \
-H "Authorization: Bearer $TOKEN" \
-H 'Content-Type: application/json' \
-d '{
"payload": {
"type": "template",
"template_id": "YOUR_TEMPLATE_ID",
"template_vars": {
"date_range": "last_30_days"
}
}
}' | jq -r '.')
# 3. Run the job
curl -X POST '/v1alpha/jobs/run' \
-H "Authorization: Bearer $TOKEN" \
-H 'Content-Type: application/json' \
-d "{\"payload\": {\"type\": \"assignment\", \"assignment_id\": \"$ASSIGNMENT_ID\"}}"
# 4. Poll for completion
while true; do
STATUS=$(curl -s -X GET "/v1alpha/jobs/status?assignment_id=$ASSIGNMENT_ID" \
-H "Authorization: Bearer $TOKEN" | jq -r '.job_status')
if [ "$STATUS" = "completed" ]; then
break
fi
sleep 5
done
# 5. Get the insight result
INSIGHT_ID=$(curl -s -X GET "/v1alpha/jobs/status?assignment_id=$ASSIGNMENT_ID" \
-H "Authorization: Bearer $TOKEN" | jq -r '.insight_id')
curl -X GET "/v1alpha/jobs/result?insight_id=$INSIGHT_ID" \
-H "Authorization: Bearer $TOKEN"
For production integrations, consider using webhooks to receive notifications
when jobs complete instead of polling the status endpoint.