Skip to main content
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

1

Get templates

Retrieve available assignment templates that define the analysis configuration.
2

Create a job

Create a new job from a template, optionally providing template variables.
3

Run the job

Start execution of the created job using its assignment ID.
4

Monitor status

Poll the status endpoint to track job progress until completion.
5

Retrieve results

Once complete, fetch the analysis results as formatted markdown.

Job States

Jobs progress through the following states:
StateDescription
draftJob created but not yet started
queuedJob waiting to be executed
activeJob is being prepared for execution
executingAnalysis is actively running
completedJob finished successfully
canceledJob 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.