Workflows API

Create and execute multi-agent workflow pipelines.

Endpoints

MethodPathDescription
GET/workflowsList all workflows
POST/workflowsCreate a workflow
GET/workflows/{id}Get workflow details
PUT/workflows/{id}Update a workflow
DELETE/workflows/{id}Delete a workflow
POST/workflows/{id}/runStart a workflow run
GET/workflows/{id}/runsList runs for a workflow
GET/runs/{id}Get run status
POST/workflows/stepExecute single step (legacy)

POST /workflows

Create a new workflow definition.

curl -X POST http://localhost:4200/workflows \
  -H "Content-Type: application/json" \
  -d '{
    "name": "claims-pipeline",
    "description": "End-to-end claims processing",
    "steps": [
      {
        "name": "intake",
        "agent": {"ByName": "claims-intake-agent"},
        "prompt_template": "Process this claim: {{input}}",
        "mode": "Sequential",
        "timeout_secs": 120,
        "error_mode": "Fail",
        "output_var": "claim_data"
      },
      {
        "name": "validation",
        "agent": {"ByName": "policy-validator"},
        "prompt_template": "Validate coverage: {{claim_data}}",
        "mode": "Sequential",
        "timeout_secs": 60,
        "error_mode": {"Retry": {"max_retries": 2}},
        "output_var": "validation_result"
      },
      {
        "name": "routing",
        "agent": {"ById": "550e8400-e29b-41d4-a716-446655440000"},
        "prompt_template": "Route claim: {{validation_result}}",
        "mode": "Sequential",
        "timeout_secs": 30,
        "error_mode": "Skip"
      }
    ]
  }'

Request Body

FieldTypeRequiredDescription
namestringYesWorkflow name
descriptionstringNoDescription
stepsarrayYesOrdered step definitions

Step Definition

FieldTypeRequiredDescription
namestringYesStep name
agentobjectYesAgent ref: {"ByName": "..."} or {"ById": "uuid"}
prompt_templatestringYesTemplate with {{input}} / {{var}} placeholders
modestringYesSequential, FanOut, Collect, Conditional, Loop
timeout_secsintegerYesMax execution time
error_modestring/objectYesFail, Skip, or {"Retry": {"max_retries": N}}
output_varstringNoVariable name to store step output

Response (201 Created)

{
  "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
  "name": "claims-pipeline",
  "description": "End-to-end claims processing",
  "steps": [...],
  "created_at": "2026-06-04T10:00:00Z"
}

GET /workflows

curl http://localhost:4200/workflows

Response (200)

{
  "workflows": [
    {
      "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
      "name": "claims-pipeline",
      "description": "End-to-end claims processing",
      "steps": [...],
      "created_at": "2026-06-04T10:00:00Z"
    }
  ]
}

GET /workflows/{id}

curl http://localhost:4200/workflows/a1b2c3d4-e5f6-7890-abcd-ef1234567890

Response (200)

{
  "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
  "name": "claims-pipeline",
  "description": "End-to-end claims processing",
  "steps": [
    {
      "name": "intake",
      "agent": {"ByName": "claims-intake-agent"},
      "prompt_template": "Process this claim: {{input}}",
      "mode": "Sequential",
      "timeout_secs": 120,
      "error_mode": "Fail",
      "output_var": "claim_data"
    }
  ],
  "created_at": "2026-06-04T10:00:00Z"
}

PUT /workflows/{id}

Update an existing workflow definition.

curl -X PUT http://localhost:4200/workflows/a1b2c3d4-e5f6-7890-abcd-ef1234567890 \
  -H "Content-Type: application/json" \
  -d '{
    "name": "claims-pipeline-v2",
    "description": "Updated pipeline with fraud check",
    "steps": [...]
  }'

Response (200)

Updated workflow definition.


DELETE /workflows/{id}

curl -X DELETE http://localhost:4200/workflows/a1b2c3d4-e5f6-7890-abcd-ef1234567890

Response (204 No Content)


POST /workflows/{id}/run

Start a workflow execution with input.

curl -X POST http://localhost:4200/workflows/a1b2c3d4-e5f6-7890-abcd-ef1234567890/run \
  -H "Content-Type: application/json" \
  -d '{"input": "New auto claim: rear-end collision on I-95, policy POL-2024-200"}'

Request Body

FieldTypeRequiredDescription
inputstringYesInitial input text for the workflow

Response (200)

{
  "id": "c3d4e5f6-a7b8-9012-cdef-123456789012",
  "workflow_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
  "workflow_name": "claims-pipeline",
  "input": "New auto claim: rear-end collision on I-95...",
  "state": "Completed",
  "step_results": [
    {"step": "intake", "output": "Claim data collected...", "duration_ms": 2300},
    {"step": "validation", "output": "Coverage confirmed...", "duration_ms": 1100},
    {"step": "routing", "output": "Routed to auto-collision queue", "duration_ms": 800}
  ],
  "output": "Claim #CLM-2026-042 created. Routed to adjuster queue: auto-collision-moderate.",
  "started_at": "2026-06-04T10:15:00Z",
  "completed_at": "2026-06-04T10:15:04Z"
}

Failed Run Response

{
  "id": "d4e5f6a7-b8c9-0123-def0-234567890123",
  "state": "Failed",
  "step_results": [
    {"step": "intake", "output": "...", "duration_ms": 2100}
  ],
  "error": "Step 'validation' timed out after 60 seconds",
  "started_at": "2026-06-04T09:30:00Z",
  "completed_at": "2026-06-04T09:31:02Z"
}

GET /workflows/{id}/runs

List all runs for a workflow.

curl http://localhost:4200/workflows/a1b2c3d4-e5f6-7890-abcd-ef1234567890/runs

Response (200)

{
  "runs": [
    {
      "id": "c3d4e5f6-a7b8-9012-cdef-123456789012",
      "state": "Completed",
      "started_at": "2026-06-04T10:15:00Z",
      "completed_at": "2026-06-04T10:15:04Z"
    }
  ]
}

GET /runs/{id}

Get detailed status of a specific run.

curl http://localhost:4200/runs/c3d4e5f6-a7b8-9012-cdef-123456789012

Response (200)

Full run status (same format as POST /workflows/{id}/run response).


Run States

StateDescription
PendingRun queued, not yet started
RunningCurrently executing steps
CompletedAll steps finished successfully
FailedA step failed (based on error_mode)