Skip to main content

Workflow & Multi-Agent Planning API

Execute workflows and leverage multi-agent planning for complex task decomposition through the Orchestrator API.

Overview

The Workflow API provides:

  • Workflow Execution: Execute predefined workflows with sequential/parallel steps
  • Multi-Agent Planning (MAP): LLM-powered task decomposition and execution
  • Execution Tracking: Monitor workflow progress and retrieve results

Base URL: http://localhost:8081 (Orchestrator)

Authentication

All endpoints require:

  • Authorization: Basic base64(clientId:clientSecret) header
  • Content-Type: application/json header (for POST requests)

Workflow requests include a user context for audit trail:

  • user.id — User identifier
  • user.email — User email
  • user.role — User role for policy evaluation

Workflow Execution

POST /api/v1/workflows/execute

Execute a workflow definition.

Request:

curl -X POST http://localhost:8081/api/v1/workflows/execute \
-H "Content-Type: application/json" \
-d '{
"workflow": {
"metadata": {
"name": "travel-booking",
"version": "1.0"
},
"spec": {
"steps": [
{
"name": "search_flights",
"type": "mcp_query",
"connector": "amadeus-travel",
"statement": "search_flights",
"parameters": {
"origin": "SFO",
"destination": "CDG",
"departure_date": "2025-06-01"
}
},
{
"name": "search_hotels",
"type": "mcp_query",
"connector": "amadeus-travel",
"statement": "search_hotels",
"parameters": {
"city": "Paris",
"check_in": "2025-06-01",
"check_out": "2025-06-07"
}
},
{
"name": "summarize",
"type": "llm",
"prompt": "Summarize the flight and hotel options for a trip from SFO to Paris",
"depends_on": ["search_flights", "search_hotels"]
}
]
}
},
"input": {
"budget": 5000,
"currency": "USD"
},
"user": {
"id": 123,
"email": "[email protected]",
"role": "user"
}
}'

Request Body:

FieldTypeRequiredDescription
workflow.metadata.namestringYesWorkflow name
workflow.spec.stepsarrayYesArray of workflow steps
inputobjectNoInput data for the workflow
userobjectYesUser context for audit

Step Types:

TypeDescription
mcp_queryExecute a query via MCP connector
mcp_executeExecute a command via MCP connector
llmSend prompt to LLM provider
conditionConditional branching
parallelExecute steps in parallel

Response (200 OK):

{
"id": "wf_exec_abc123",
"status": "completed",
"workflow_name": "travel-booking",
"started_at": "2025-01-02T10:00:00Z",
"completed_at": "2025-01-02T10:00:05Z",
"steps": [
{
"name": "search_flights",
"status": "completed",
"process_time": "1.234s",
"output": {
"flights": [
{"airline": "Air France", "price": 850}
]
}
},
{
"name": "search_hotels",
"status": "completed",
"process_time": "1.456s",
"output": {
"hotels": [
{"name": "Hotel Eiffel", "price_per_night": 200}
]
}
},
{
"name": "summarize",
"status": "completed",
"process_time": "2.123s",
"output": "I found great options for your trip..."
}
],
"output": {
"final_result": "I found great options for your trip..."
}
}

GET /api/v1/workflows/executions/{id}

Get details of a workflow execution.

Request:

curl http://localhost:8081/api/v1/workflows/executions/wf_exec_abc123

Response (200 OK):

{
"id": "wf_exec_abc123",
"status": "completed",
"workflow_name": "travel-booking",
"started_at": "2025-01-02T10:00:00Z",
"completed_at": "2025-01-02T10:00:05Z",
"duration_ms": 5234,
"steps": [
{
"name": "search_flights",
"status": "completed",
"started_at": "2025-01-02T10:00:00Z",
"completed_at": "2025-01-02T10:00:01Z",
"process_time": "1.234s"
},
{
"name": "search_hotels",
"status": "completed",
"started_at": "2025-01-02T10:00:00Z",
"completed_at": "2025-01-02T10:00:01Z",
"process_time": "1.456s"
},
{
"name": "summarize",
"status": "completed",
"started_at": "2025-01-02T10:00:02Z",
"completed_at": "2025-01-02T10:00:05Z",
"process_time": "2.123s"
}
],
"output": {
"final_result": "I found great options for your trip..."
}
}

GET /api/v1/workflows/executions

List recent workflow executions.

Request:

curl "http://localhost:8081/api/v1/workflows/executions?limit=10"

Query Parameters:

ParameterTypeDefaultDescription
limitinteger10Number of executions to return (max: 100)
offsetinteger0Pagination offset
statusstring(all)Filter by status: pending, running, completed, failed

Response (200 OK):

{
"executions": [
{
"id": "wf_exec_abc123",
"workflow_name": "travel-booking",
"status": "completed",
"started_at": "2025-01-02T10:00:00Z",
"duration_ms": 5234
},
{
"id": "wf_exec_def456",
"workflow_name": "data-pipeline",
"status": "failed",
"started_at": "2025-01-02T09:00:00Z",
"error": "Step 'fetch_data' timed out"
}
],
"count": 2
}

GET /api/v1/workflows/executions/tenant/{tenant_id}

List workflow executions for a specific tenant.

Request:

curl http://localhost:8081/api/v1/workflows/executions/tenant/my-tenant

Response (200 OK):

{
"tenant_id": "my-tenant",
"count": 5,
"executions": [
{
"id": "wf_exec_abc123",
"workflow_name": "travel-booking",
"status": "completed",
"started_at": "2025-01-02T10:00:00Z"
}
]
}

Multi-Agent Planning (MAP)

POST /api/v1/plan

Submit a complex query for LLM-powered task decomposition and execution.

Request:

curl -X POST http://localhost:8081/api/v1/plan \
-H "Content-Type: application/json" \
-d '{
"query": "Plan a business trip from San Francisco to Paris for June 1-7, find flights under $1000 and 4-star hotels near the Eiffel Tower",
"domain": "travel",
"execution_mode": "auto",
"user": {
"id": 123,
"email": "[email protected]",
"role": "user"
},
"context": {
"budget": 5000,
"currency": "USD",
"preferences": {
"airline_alliance": "SkyTeam",
"hotel_amenities": ["wifi", "breakfast"]
}
}
}'

Request Body:

FieldTypeRequiredDescription
querystringYesNatural language query
domainstringNoDomain hint: travel, healthcare, finance, generic
execution_modestringNoExecution mode: auto, parallel, sequential
userobjectYesUser context (required for governance)
contextobjectNoAdditional context for planning

Response (200 OK):

{
"success": true,
"plan_id": "plan_xyz789",
"steps": [
{
"id": "step_1_search_flights",
"name": "search_flights",
"type": "mcp_query",
"description": "Search for flights from SFO to CDG under $1000",
"depends_on": [],
"agent": "amadeus-travel",
"parameters": {
"origin": "SFO",
"destination": "CDG",
"departure_date": "2025-06-01",
"return_date": "2025-06-07",
"max_price": 1000
}
},
{
"id": "step_2_search_hotels",
"name": "search_hotels",
"type": "mcp_query",
"description": "Search for 4-star hotels near Eiffel Tower",
"depends_on": [],
"agent": "amadeus-travel",
"parameters": {
"city": "Paris",
"check_in": "2025-06-01",
"check_out": "2025-06-07",
"star_rating": 4,
"landmark": "Eiffel Tower"
}
},
{
"id": "step_3_summarize",
"name": "summarize_options",
"type": "llm",
"description": "Create a summary of travel options",
"depends_on": ["step_1_search_flights", "step_2_search_hotels"]
}
],
"workflow_execution_id": "wf_exec_abc123",
"result": "I found excellent options for your Paris trip:\n\n**Flights:**\n- Air France AF123: $850 direct, departing 10:00 AM\n- Delta DL456: $920 with 1 stop\n\n**Hotels:**\n- Hotel Eiffel Palace (4-star): $180/night, 0.5 km from Eiffel Tower\n- Le Meridien Étoile (4-star): $210/night, 1.2 km from Eiffel Tower\n\nTotal estimated cost: $1,930-$2,390 (within your $5,000 budget)",
"metadata": {
"tasks_executed": 3,
"execution_mode": "parallel",
"execution_time_ms": 4567,
"tasks": [
{"name": "search_flights", "status": "completed", "time_ms": 1234},
{"name": "search_hotels", "status": "completed", "time_ms": 1456},
{"name": "summarize_options", "status": "completed", "time_ms": 2345}
]
}
}

Plan Status

GET /api/v1/plan/{id}

Get the status of a previously submitted plan.

Request:

curl http://localhost:8081/api/v1/plan/plan_xyz789

Response (200 OK):

{
"plan_id": "plan_xyz789",
"status": "completed",
"query": "Plan a business trip from San Francisco to Paris",
"domain": "travel",
"steps": [
{
"id": "step_1_search_flights",
"name": "search_flights",
"status": "completed"
}
],
"result": "I found excellent options for your Paris trip..."
}

POST /api/v1/plan/execute

Execute a previously generated plan (two-step MAP flow). Use this when you want to review a plan before executing it.

Request:

curl -X POST http://localhost:8081/api/v1/plan/execute \
-H "Content-Type: application/json" \
-d '{
"plan_id": "plan_xyz789",
"user": {
"id": 123,
"email": "[email protected]",
"role": "user"
}
}'

Unified Execution API

The Unified Execution API provides a single interface for tracking both MAP plans and WCP workflows. It includes status queries and cancellation.

Base URL: http://localhost:8081 (Orchestrator)

CORS: All endpoints respond to OPTIONS preflight requests with Access-Control-Allow-Origin: * and allow GET, POST, OPTIONS methods with Content-Type, Authorization, X-Tenant-ID, and X-Org-ID headers.


GET /api/v1/unified/executions

List executions across both MAP plans and WCP workflows.

Request:

curl "http://localhost:8081/api/v1/unified/executions?limit=20&execution_type=wcp_workflow"

Query Parameters:

ParameterTypeDescription
limitintegerMax results (default: 20, max: 100). Invalid values fall back to default.
offsetintegerPagination offset (default: 0). Invalid values fall back to default.
execution_typestringFilter by type: map_plan or wcp_workflow
statusstringFilter by status (see Execution Status Values)

Headers:

HeaderRequiredDescription
X-Tenant-IDNoFilter by tenant ID (multi-tenancy)
X-Org-IDNoFilter by organization ID

Response (200 OK):

{
"executions": [
{
"execution_id": "wf_abc123",
"execution_type": "wcp_workflow",
"name": "data-pipeline",
"status": "running",
"progress_percent": 66.7,
"total_steps": 3,
"current_step_index": 2,
"started_at": "2026-02-06T10:00:00Z",
"created_at": "2026-02-06T10:00:00Z",
"updated_at": "2026-02-06T10:00:03Z"
}
],
"total": 1,
"limit": 20,
"offset": 0,
"has_more": false
}

The has_more field indicates whether additional pages of results exist beyond the current offset.


GET /api/v1/unified/executions/{id}

Get detailed status of a specific execution. The {id} parameter accepts:

  • An execution ID (direct lookup)
  • A WCP workflow ID (prefix wf_ or wcp_)
  • A MAP plan ID (prefix plan_)

The API tries multiple lookup strategies and returns the first match.

Request:

curl http://localhost:8081/api/v1/unified/executions/wf_abc123

Response (200 OK):

{
"execution_id": "wf_abc123",
"execution_type": "wcp_workflow",
"name": "data-pipeline",
"source": "crewai",
"status": "running",
"current_step_index": 2,
"total_steps": 3,
"progress_percent": 66.7,
"started_at": "2026-02-06T10:00:00Z",
"duration": "5s",
"steps": [
{
"step_id": "step-1",
"step_index": 0,
"step_name": "Fetch Data",
"step_type": "tool_call",
"status": "completed",
"started_at": "2026-02-06T10:00:00Z",
"ended_at": "2026-02-06T10:00:01Z",
"duration": "1s",
"decision": "allow",
"model": "gpt-4",
"provider": "openai"
},
{
"step_id": "step-2",
"step_index": 1,
"step_name": "Process Data",
"step_type": "llm_call",
"status": "completed",
"started_at": "2026-02-06T10:00:01Z",
"ended_at": "2026-02-06T10:00:03Z",
"duration": "2s",
"decision": "allow",
"model": "gpt-4",
"provider": "openai"
},
{
"step_id": "step-3",
"step_index": 2,
"step_name": "Store Results",
"step_type": "tool_call",
"status": "running",
"started_at": "2026-02-06T10:00:03Z"
}
],
"metadata": {
"workflow_id": "wf_abc123"
},
"created_at": "2026-02-06T10:00:00Z",
"updated_at": "2026-02-06T10:00:03Z"
}

Example: WCP step with policy gate and approval flow:

{
"step_id": "gate-1",
"step_index": 0,
"step_name": "Policy Evaluation",
"step_type": "gate",
"status": "approval",
"started_at": "2026-02-06T10:00:00Z",
"decision": "require_approval",
"decision_reason": "Query accesses PII columns in production database",
"policies_matched": ["pii-protection", "prod-data-access"],
"approval_status": "pending",
"model": "gpt-4",
"provider": "openai",
"result_summary": "Awaiting manager approval for PII data access"
}

ExecutionStatus field reference:

FieldTypeOmitted when empty
execution_idstringNo
execution_typestringNo
namestringNo
sourcestringYes
statusstringNo
current_step_indexintegerNo
total_stepsintegerNo
progress_percentfloatNo
started_atdatetimeNo
completed_atdatetimeYes
durationstringYes
stepsarrayYes
errorstringYes
tenant_idstringYes
org_idstringYes
user_idstringYes
client_idstringYes
estimated_cost_usdfloatYes
actual_cost_usdfloatYes
metadataobjectYes
created_atdatetimeNo
updated_atdatetimeNo

StepStatus field reference:

FieldTypeOmitted when empty
step_idstringNo
step_indexintegerNo
step_namestringNo
step_typestringNo
statusstringNo
started_atdatetimeYes
ended_atdatetimeYes
durationstringYes
decisionstringYes
decision_reasonstringYes
policies_matchedstring[]Yes
approval_statusstringYes
approved_bystringYes
approved_atdatetimeYes
modelstringYes
providerstringYes
inputobjectYes
outputobjectYes
cost_usdfloatYes
result_summarystringYes
errorstringYes

GET /api/v1/unified/executions/{id}/stream

Stream real-time execution status updates via Server-Sent Events (SSE). The connection sends the current execution state immediately on connect, then pushes events as the execution progresses. The server closes the connection when the execution reaches a terminal state (completed, failed, cancelled, aborted, expired).

Request:

curl -N http://localhost:8081/api/v1/unified/executions/wf_abc123/stream \
-H "Accept: text/event-stream"

Path Parameters:

ParameterTypeDescription
idstringExecution ID, WCP workflow ID, or MAP plan ID

Headers:

HeaderRequiredDescription
AuthorizationYesBasic base64(clientId:clientSecret)
X-Tenant-IDNoTenant ID (used for per-tenant connection limits)

Response Headers:

Content-Type: text/event-stream
Cache-Control: no-cache
Connection: keep-alive
X-Accel-Buffering: no

SSE Event Format:

Each event follows the standard SSE format with id, event, and data fields:

id: 1707220800000
event: execution.started
data: {"execution_id":"wf_abc123","execution_type":"wcp_workflow","name":"data-pipeline","status":"running",...}

The data payload is the full ExecutionStatus JSON object (same schema as the GET endpoint).

Event Types:

EventDescription
statusInitial execution state sent on connect
execution.startedExecution has begun
execution.completedExecution completed successfully (terminal)
execution.failedExecution failed (terminal)
execution.cancelledExecution was cancelled (terminal)
step.startedA step has started executing
step.completedA step completed successfully
step.failedA step failed
step.decisionA policy gate decision was made on a step

Connection Lifecycle:

  1. Client connects; server sends the current state as a status event
  2. If the execution is already terminal, the server closes the connection immediately
  3. While running, the server pushes events as execution state changes
  4. A :keepalive SSE comment is sent every 15 seconds to prevent proxy idle timeouts
  5. On terminal event (execution.completed, execution.failed, execution.cancelled), the server closes the connection
  6. If the client disconnects, the server cleans up the subscription

Connection Limits:

In community mode, each tenant is limited to 5 concurrent SSE connections. Enterprise mode has no limit. Exceeding the limit returns 429 Too Many Requests.

Error Responses:

HTTP StatusError CodeDescription
400BAD_REQUESTMissing execution ID
404NOT_FOUNDExecution not found
429TOO_MANY_REQUESTSPer-tenant SSE connection limit reached
500INTERNAL_ERRORStreaming not supported or lookup failure
503SERVICE_UNAVAILABLEEvent streaming not available

POST /api/v1/unified/executions/{id}/cancel

Cancel a running execution. Propagates to the appropriate subsystem:

  • WCP workflows are aborted via AbortWorkflow
  • MAP plans are cancelled via CancelPlan

Request:

curl -X POST http://localhost:8081/api/v1/unified/executions/wf_abc123/cancel \
-H "Content-Type: application/json" \
-d '{"reason": "no longer needed"}'

Request Body:

FieldTypeRequiredDescription
reasonstringNoReason for cancellation (default: "cancelled via unified API")

Response (200 OK):

Returns the full updated ExecutionStatus object (same schema as the GET endpoint):

{
"execution_id": "wf_abc123",
"execution_type": "wcp_workflow",
"name": "data-pipeline",
"status": "cancelled",
"current_step_index": 1,
"total_steps": 3,
"progress_percent": 33.3,
"started_at": "2026-02-06T10:00:00Z",
"completed_at": "2026-02-06T10:00:05Z",
"duration": "5s",
"steps": [...],
"created_at": "2026-02-06T10:00:00Z",
"updated_at": "2026-02-06T10:00:05Z"
}

Error Responses:

HTTP StatusError CodeDescription
400BAD_REQUESTMissing execution ID or unknown execution type
404NOT_FOUNDExecution not found
409CONFLICTExecution already in terminal state
500INTERNAL_ERRORSubsystem cancellation failed

Execution Status Values

Workflow Status

ValueDescription
pendingExecution queued but not started
runningExecution in progress
completedAll steps completed successfully
failedOne or more steps failed
cancelledExecution was cancelled via the cancel endpoint
abortedWCP workflow aborted (e.g., policy violation)
expiredMAP plan expired before execution started

Step Status Values

StatusDescription
pendingStep not yet started
runningStep currently executing
completedStep completed successfully
failedStep failed
skippedStep was skipped
blockedStep blocked by policy (WCP)
approvalStep waiting for human approval (WCP)

Step Types

TypeDescription
llm_callLLM provider invocation
tool_callExternal tool or function call
connector_callMCP connector invocation
human_taskHuman-in-the-loop task
synthesisMAP result synthesis step
actionGeneric action step
gateWCP policy gate evaluation

Execution Flow

  1. Workflow enters pending status when submitted
  2. Steps with no dependencies start in parallel (status: running)
  3. Steps with depends_on wait until all dependencies are completed
  4. If any step fails and has no error handler, the workflow status becomes failed
  5. On success of all steps, the workflow status becomes completed

Gate Decisions

Policy gate decisions on steps (WCP):

DecisionDescription
allowStep allowed to proceed
blockStep blocked by policy
require_approvalStep requires human approval before proceeding

Approval Status

Approval state when a step has decision: "require_approval":

StatusDescription
pendingAwaiting approval
approvedApproved by a user
rejectedRejected by a user

Error Responses

All error responses use a consistent format:

{
"error": {
"code": "NOT_FOUND",
"message": "Execution not found: exec-123"
}
}

Workflow API errors:

HTTP StatusError CodeDescription
400INVALID_WORKFLOWWorkflow definition is invalid
400MISSING_USER_CONTEXTUser context required for governance
404EXECUTION_NOT_FOUNDWorkflow execution not found
404PLAN_NOT_FOUNDPlan does not exist
500PLANNING_FAILEDLLM planning engine failed
504EXECUTION_TIMEOUTWorkflow exceeded timeout

Example (400):

{
"error": {
"code": "INVALID_WORKFLOW",
"message": "Workflow spec.steps must contain at least one step"
}
}

Example (404):

{
"error": {
"code": "EXECUTION_NOT_FOUND",
"message": "Workflow execution 'wf_exec_invalid' not found"
}
}

Example (504):

{
"error": {
"code": "EXECUTION_TIMEOUT",
"message": "Workflow 'travel-booking' exceeded 60s timeout at step 'search_flights'"
}
}

Unified Execution API errors:

HTTP StatusError CodeDescription
400BAD_REQUESTMissing or invalid execution ID
404NOT_FOUNDExecution not found
409CONFLICTExecution already in terminal state (cancel only)
500INTERNAL_ERRORInternal server error

Next Steps