Workflow API Endpoints
The Workflow API enables execution and management of multi-step workflows with suspend/resume capabilities. All workflow endpoints follow the pattern /workflows/*.
List All Workflows
Returns a list of all registered workflows.
Endpoint: GET /workflows
Response:
{
"success": true,
"data": [
{
"id": "order-approval",
"name": "Order Approval Workflow",
"purpose": "Process and approve customer orders",
"stepsCount": 5,
"status": "idle"
},
{
"id": "data-processing",
"name": "Data Processing Pipeline",
"purpose": "ETL pipeline for data transformation",
"stepsCount": 8,
"status": "idle"
}
]
}
cURL Example:
curl http://localhost:3141/workflows
Get Workflow Details
Retrieve detailed information about a specific workflow including schemas.
Endpoint: GET /workflows/:id
Response:
{
"success": true,
"data": {
"id": "order-approval",
"name": "Order Approval Workflow",
"purpose": "Process and approve customer orders",
"status": "idle",
"stepsCount": 5,
"steps": [
{
"id": "validate-order",
"name": "Validate Order",
"type": "andThen",
"purpose": "Validate order data",
"inputSchema": {
/* JSON Schema */
},
"outputSchema": {
/* JSON Schema */
}
},
{
"id": "check-inventory",
"name": "Check Inventory",
"type": "andThen",
"purpose": "Verify stock availability"
},
{
"id": "approval-required",
"name": "Manager Approval",
"type": "andWhen",
"purpose": "Wait for manager approval if needed",
"suspendSchema": {
/* JSON Schema */
},
"resumeSchema": {
/* JSON Schema */
}
}
],
"inputSchema": {
"type": "object",
"properties": {
"orderId": { "type": "string" },
"amount": { "type": "number" },
"items": { "type": "array" }
},
"required": ["orderId", "amount"]
},
"suspendSchema": null,
"resumeSchema": null
}
}
Note: Schemas are converted from Zod to JSON Schema format using zodSchemaToJsonUI.
cURL Example:
curl http://localhost:3141/workflows/order-approval
List Workflow Executions
Retrieve executions for a workflow using query parameters.
Endpoint: GET /workflows/executions
Query Parameters:
| Name | Type | Description |
|---|---|---|
workflowId | string (optional) | Workflow ID to filter executions (omit to get all) |
status | string (optional) | Filter by status (running, suspended, completed, cancelled, error) |
from | string (optional) | ISO timestamp to filter executions created after this time |
to | string (optional) | ISO timestamp to filter executions created before this time |
limit | number (optional) | Max results to return |
offset | number (optional) | Offset for pagination |
Response:
{
"success": true,
"data": [
{
"id": "6a8ca92c-0d8a-425f-b24f-09f841a8c200",
"workflowId": "order-approval",
"workflowName": "Order Approval Workflow",
"status": "completed",
"input": {
"employeeId": "sample-employeeId",
"amount": 42,
"category": "sample-category",
"description": "sample-description"
},
"metadata": {
"traceId": "abe55638e17097f497bfb7ba5ed92a50",
"spanId": "0704efe9b0bf5bfc"
},
"events": [
{
"id": "3a290355-4baa-4e48-9502-f8d314fb008e",
"type": "workflow-start",
"name": "Expense Approval Workflow",
"from": "Expense Approval Workflow",
"startTime": "2025-12-10T15:18:04.423Z",
"endTime": "2025-12-10T15:18:04.423Z",
"status": "running",
"input": {
"employeeId": "sample-employeeId",
"amount": 42,
"category": "sample-category",
"description": "sample-description"
}
},
{
"id": "8d80ee68-bd2d-451f-abed-856845280509",
"type": "workflow-complete",
"name": "Expense Approval Workflow",
"from": "Expense Approval Workflow",
"startTime": "2025-12-10T15:18:05.415Z",
"endTime": "2025-12-10T15:18:05.415Z",
"status": "success",
"output": {
"status": "approved",
"approvedBy": "system",
"finalAmount": 42
}
}
],
"output": {
"status": "approved",
"approvedBy": "system",
"finalAmount": 42
},
"createdAt": "2025-12-10T15:18:04.421Z",
"updatedAt": "2025-12-10T15:18:05.413Z"
}
]
}
cURL Example:
curl "http://localhost:3141/workflows/executions?workflowId=order-approval&status=completed&limit=20&offset=0"
List all executions:
curl "http://localhost:3141/workflows/executions?limit=50"
Execute Workflow
Execute a workflow synchronously and wait for completion.
Endpoint: POST /workflows/:id/execute
Request Body:
{
"input": {
"orderId": "ORD-12345",
"amount": 5000,
"customerEmail": "customer@example.com",
"items": ["laptop", "mouse", "keyboard"]
},
"options": {
"userId": "user-123",
"conversationId": "conv-456",
"executionId": "custom-exec-id",
"context": {
"priority": "high",
"department": "sales"
},
"workflowState": {
"plan": "pro",
"region": "eu"
}
}
}
Options:
| Field | Type | Description |
|---|---|---|
userId | string | User ID for tracking |
conversationId | string | Conversation context |
executionId | string | Custom execution ID |
context | object | Additional context data |
workflowState | object | Shared state available to workflow steps |
Response (Completed):
{
"success": true,
"data": {
"executionId": "exec_1234567890_abc123",
"startAt": "2024-01-15T10:00:00.000Z",
"endAt": "2024-01-15T10:00:05.123Z",
"status": "completed",
"result": {
"approved": true,
"processedBy": "system",
"totalAmount": 5000
}
}
}
Response (Suspended):
{
"success": true,
"data": {
"executionId": "exec_1234567890_abc123",
"startAt": "2024-01-15T10:00:00.000Z",
"endAt": null,
"status": "suspended",
"result": null,
"suspension": {
"suspendedAt": "2024-01-15T10:00:02.500Z",
"reason": "Waiting for manager approval",
"suspendedStepIndex": 2
}
}
}
cURL Example:
curl -X POST http://localhost:3141/workflows/order-approval/execute \
-H "Content-Type: application/json" \
-d '{
"input": {
"orderId": "ORD-789",
"amount": 1500,
"items": ["book", "pen"]
},
"options": {
"userId": "user-456"
}
}'