Guides
Use the Mobius HTTP API to create a workflow definition, launch runs from a backend service or script, and read the terminal result — without touching the dashboard.
Before you start
- You have a Mobius API key exported as
MOBIUS_API_KEY. See Create an API key if you do not. - Your project handle is exported as
PROJECTand your API base URL asMOBIUS_BASE_URL. - At least one worker is registered and actively heartbeating in the project. Runs with worker actions stay in
queueduntil a worker claims them.
Walkthrough
-
Create the workflow definition with
POST /v1/projects/{project}/workflows. The response is201 Createdand contains the definition'sid. Record it asWORKFLOW_ID. Thehandleis auto-derived fromnamewhen omitted and must be unique within the org.curl -X POST "$MOBIUS_BASE_URL/v1/projects/$PROJECT/workflows" \ -H "Authorization: Bearer $MOBIUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "name": "Ingest document", "spec": { "name": "ingest-document", "steps": [ { "name": "parse", "action": "doc.parse" }, { "name": "index", "action": "doc.index" } ] } }' -
Start a run with
POST /v1/projects/{project}/runs. Passdefinition_idto target the saved definition. The response is202 Acceptedwithstatus: queued. Record the runidasRUN_ID.curl -X POST "$MOBIUS_BASE_URL/v1/projects/$PROJECT/runs" \ -H "Authorization: Bearer $MOBIUS_API_KEY" \ -H "Content-Type: application/json" \ -d "{ \"definition_id\": \"$WORKFLOW_ID\", \"external_id\": \"doc-abc123\", \"inputs\": {\"doc_url\": \"https://example.com/doc.pdf\"} }" -
Subscribe to the run's event stream with
GET /v1/projects/{project}/runs/{id}/events. The server writes a seedrun_updatedframe on connection so reconnects never miss the latest state. Each frame carries{type, run_id, seq, timestamp, data}wheretypeisrun_updated,job_updated, oraction_appended. Close the stream once you seerun_updatedwithstatus: completedorstatus: failed.curl --no-buffer "$MOBIUS_BASE_URL/v1/projects/$PROJECT/runs/$RUN_ID/events" \ -H "Authorization: Bearer $MOBIUS_API_KEY" -
Fetch the terminal state with
GET /v1/projects/{project}/runs/{id}. A completed run returnsstatus: completed. Theresult_b64field carries the base64-encoded terminal result when the workflow produced output.curl "$MOBIUS_BASE_URL/v1/projects/$PROJECT/runs/$RUN_ID" \ -H "Authorization: Bearer $MOBIUS_API_KEY"
Follow-ups
- Cancel an in-flight run with
POST /v1/projects/{project}/runs/{id}/cancellationsor cancel a batch withPOST /v1/projects/{project}/runs/cancellations. - Re-enqueue a failed run with
POST /v1/projects/{project}/runs/retries. - Resume a
suspendedrun waiting on a signal withPOST /v1/projects/{project}/runs/{id}/signals— see Interactions for the pattern.
Do the same in the dashboard
Open Projects → <your project> → Workflows, click New workflow, then use the run inspector to launch and observe a run.
Troubleshooting
409oncreateWorkflow: a workflow with that name already exists in the project. Choose a different name or update the existing definition withPATCH /v1/projects/{project}/workflows/{id}.400onstartRun: the request contained bothdefinition_idandspec, or neither. Provide exactly one.- Run stays in
queued: no worker is registered or actively heartbeating for the queue this run targets. Runs use thedefaultqueue when none is specified. Verify at least one worker'slast_heartbeat_atis recent. 401on any call: the key is missing or revoked. Re-issue with Create an API key and re-exportMOBIUS_API_KEY.
See also
- Workflows — the definition and versioning model.
- Runs — state machine and lifecycle.
- Redoc reference: workflows and runs — full request and response schemas.