Skip to main content

Workflows API

Manage automation workflows -- define multi-step pipelines, configure steps with tools, execute workflows, and track execution history.

Triggers

Trigger CRUD endpoints (/api/v1/triggers) are documented separately. This page covers the workflow-scoped trigger listing endpoint only.

Workflow CRUD

List Workflows

GET /api/v1/workflows

Returns all workflows with optional filters. Paginated.

curl http://localhost:8080/api/v1/workflows?is_active=true
ParameterTypeRequiredDefaultDescription
pageintNo1Page number (1-indexed)
page_sizeintNo50Items per page (max 1000)
categorystringNonullFilter by category
is_systemboolNonullFilter by system flag
is_activeboolNonullFilter by active flag
expose_as_ai_toolboolNonullFilter by AI tool exposure

Response 200 OK

{
"data": [
{
"id": "wf_abc123",
"database_name": "default",
"name": "Auto-Extract Pipeline",
"description": "Automatically extract entities from new uploads",
"category": "extraction",
"is_system": false,
"is_active": true,
"expose_as_ai_tool": false,
"input_schema": {
"type": "object",
"properties": {
"source_id": {"type": "string"}
},
"required": ["source_id"]
},
"output_schema": null,
"allow_parallel_execution": true,
"timeout_seconds": null,
"max_retries": 0,
"tags": ["extraction", "automation"],
"icon": "robot",
"version": "1",
"created_by": null,
"created_at": "2026-03-01T12:00:00",
"updated_at": "2026-03-01T12:00:00",
"last_executed_at": "2026-03-09T08:30:00"
}
],
"pagination": {
"page": 1,
"page_size": 50,
"total_items": 1,
"total_pages": 1
}
}

Create Workflow

POST /api/v1/workflows
curl -X POST http://localhost:8080/api/v1/workflows \
-H "Content-Type: application/json" \
-d '{
"name": "Auto-Extract Pipeline",
"description": "Automatically extract entities from new uploads",
"category": "extraction",
"expose_as_ai_tool": false,
"input_schema": {
"type": "object",
"properties": {
"source_id": {"type": "string"}
},
"required": ["source_id"]
},
"output_schema": null,
"allow_parallel_execution": true,
"timeout_seconds": null,
"max_retries": 0,
"tags": ["extraction"],
"icon": "robot"
}'
FieldTypeRequiredDefaultDescription
namestringYes--Workflow name
descriptionstringNonullHuman-readable description
categorystringNonullGrouping category
expose_as_ai_toolboolNofalseExpose workflow as an AI-callable tool
input_schemaobjectYes--JSON Schema for workflow inputs
output_schemaobjectNonullJSON Schema for workflow outputs
allow_parallel_executionboolNotrueAllow concurrent executions
timeout_secondsintNonullMaximum execution time
max_retriesintNo0Number of retries on failure
tagsstring[]No[]Searchable tags
iconstringNonullIcon identifier for UI

Response 201 Created -- returns the full WorkflowResponse object.

Get Workflow

GET /api/v1/workflows/{workflow_id}
curl http://localhost:8080/api/v1/workflows/wf_abc123
ParameterTypeRequiredDescription
workflow_idstring (path)YesWorkflow ID

Response 200 OK -- returns a single WorkflowResponse.

Errors: 404 if the workflow does not exist.

Update Workflow

PATCH /api/v1/workflows/{workflow_id}

Partial update -- only include the fields you want to change. System workflows cannot be updated.

curl -X PATCH http://localhost:8080/api/v1/workflows/wf_abc123 \
-H "Content-Type: application/json" \
-d '{
"name": "Renamed Pipeline",
"is_active": false,
"max_retries": 3
}'
FieldTypeRequiredDescription
namestringNoWorkflow name
descriptionstringNoDescription
categorystringNoCategory
is_activeboolNoEnable or disable the workflow
expose_as_ai_toolboolNoExpose as AI tool
input_schemaobjectNoInput JSON Schema
output_schemaobjectNoOutput JSON Schema
allow_parallel_executionboolNoAllow concurrent executions
timeout_secondsintNoTimeout in seconds
max_retriesintNoRetry count
tagsstring[]NoTags (replaces existing)
iconstringNoIcon identifier

Response 200 OK -- returns the updated WorkflowResponse.

Errors: 404 if the workflow does not exist.

Delete Workflow

DELETE /api/v1/workflows/{workflow_id}

Permanently deletes a workflow and its steps. System workflows cannot be deleted.

curl -X DELETE http://localhost:8080/api/v1/workflows/wf_abc123

Response 204 No Content

Errors: 404 if the workflow does not exist.

Duplicate Workflow

POST /api/v1/workflows/{workflow_id}/duplicate

Creates a copy of a workflow and all its steps. The new workflow name is "{original_name} (Copy)".

curl -X POST http://localhost:8080/api/v1/workflows/wf_abc123/duplicate
ParameterTypeRequiredDescription
workflow_idstring (path)YesWorkflow ID to duplicate

Response 201 Created

{
"workflow_id": "wf_new456",
"message": "Workflow duplicated successfully",
"was_existing": false
}

Errors: 404 if the workflow does not exist.


Workflow Steps

Steps define the ordered sequence of tool invocations within a workflow.

List Steps

GET /api/v1/workflows/{workflow_id}/steps

Returns all steps for a workflow sorted by step_number.

curl http://localhost:8080/api/v1/workflows/wf_abc123/steps

Response 200 OK

[
{
"id": "step_001",
"workflow_id": "wf_abc123",
"step_number": 1,
"name": "Extract Entities",
"description": "Run entity extraction on the source",
"tool_type": "system_tool",
"tool_id": "extract_entities",
"configuration": {
"depth": "full",
"domain": "auto"
},
"condition": null,
"retry_on_failure": false,
"timeout_seconds": 300,
"depends_on": [],
"continue_on_error": false,
"thinking_mode": null,
"created_at": "2026-03-01T12:00:00",
"updated_at": "2026-03-01T12:00:00"
}
]

Create Step

POST /api/v1/workflows/{workflow_id}/steps
curl -X POST http://localhost:8080/api/v1/workflows/wf_abc123/steps \
-H "Content-Type: application/json" \
-d '{
"step_number": 1,
"name": "Extract Entities",
"description": "Run entity extraction on the source",
"tool_type": "system_tool",
"tool_id": "extract_entities",
"configuration": {
"depth": "full",
"domain": "auto"
},
"condition": null,
"retry_on_failure": false,
"timeout_seconds": 300,
"depends_on": [],
"continue_on_error": false,
"thinking_mode": null
}'
FieldTypeRequiredDefaultDescription
step_numberintYes--Position in execution order
namestringYes--Step name
descriptionstringNonullDescription
tool_typestringYes--system_tool, user_tool, or workflow
tool_idstringYes--ID of the tool or sub-workflow to execute
configurationobjectYes--Parameter mappings passed to the tool
conditionobjectNonullConditional execution rules
retry_on_failureboolNofalseRetry this step on failure
timeout_secondsintNonullPer-step timeout
depends_onstring[]No[]Step IDs that must complete first
continue_on_errorboolNofalseContinue workflow if step fails
thinking_modestringNonullLLM thinking mode override

Response 201 Created -- returns the WorkflowStepResponse.

Errors: 404 workflow not found, 400 validation error.

Get Step

GET /api/v1/workflows/{workflow_id}/steps/{step_id}
curl http://localhost:8080/api/v1/workflows/wf_abc123/steps/step_001

Response 200 OK -- returns a single WorkflowStepResponse.

Errors: 404 if the workflow or step does not exist.

Update Step

PATCH /api/v1/workflows/{workflow_id}/steps/{step_id}

Partial update -- only include fields to change. System workflow steps cannot be modified.

curl -X PATCH http://localhost:8080/api/v1/workflows/wf_abc123/steps/step_001 \
-H "Content-Type: application/json" \
-d '{
"timeout_seconds": 600,
"retry_on_failure": true
}'

All fields from WorkflowStepCreate are accepted, all optional.

Response 200 OK -- returns the updated WorkflowStepResponse.

Errors: 404 workflow or step not found, 400 validation error.

Delete Step

DELETE /api/v1/workflows/{workflow_id}/steps/{step_id}
curl -X DELETE http://localhost:8080/api/v1/workflows/wf_abc123/steps/step_001

Response 204 No Content

Errors: 404 workflow or step not found.

Reorder Steps

PUT /api/v1/workflows/{workflow_id}/steps/reorder

Updates step_number for all steps based on the provided ordering. The request must include every step ID belonging to the workflow.

curl -X PUT http://localhost:8080/api/v1/workflows/wf_abc123/steps/reorder \
-H "Content-Type: application/json" \
-d '{
"step_order": ["step_003", "step_001", "step_002"]
}'
FieldTypeRequiredDescription
step_orderstring[]YesOrdered list of all step IDs

Response 200 OK -- returns the reordered list of WorkflowStepResponse objects.

Errors: 400 if step IDs are missing or extra, 404 workflow not found.


Export and Import

Export Workflow

GET /api/v1/workflows/{workflow_id}/export

Exports a workflow with all its steps to a portable JSON format suitable for backup or sharing between databases.

curl http://localhost:8080/api/v1/workflows/wf_abc123/export

Response 200 OK

{
"data": {
"format_version": "1",
"workflow": {
"name": "Auto-Extract Pipeline",
"description": "Automatically extract entities from new uploads",
"category": "extraction",
"input_schema": {"type": "object"},
"output_schema": null,
"tags": ["extraction"],
"icon": "robot"
},
"steps": [
{
"step_number": 1,
"name": "Extract Entities",
"tool_type": "system_tool",
"tool_id": "extract_entities",
"configuration": {"depth": "full"}
}
]
},
"message": "Workflow exported successfully"
}

Errors: 404 if the workflow does not exist.

Import Workflow

POST /api/v1/workflows/import

Imports a workflow from previously exported JSON. Supports duplicate handling strategies.

curl -X POST http://localhost:8080/api/v1/workflows/import \
-H "Content-Type: application/json" \
-d '{
"workflow_data": {
"format_version": "1",
"workflow": {
"name": "Auto-Extract Pipeline",
"description": "Imported pipeline",
"input_schema": {"type": "object"},
"tags": ["extraction"]
},
"steps": []
},
"on_duplicate": "rename",
"new_name": null,
"import_as_inactive": true
}'
FieldTypeRequiredDefaultDescription
workflow_dataobjectYes--Exported workflow JSON
on_duplicatestringNo"fail"Duplicate name strategy: fail, skip, or rename
new_namestringNonullOverride workflow name on import
import_as_inactiveboolNofalseImport with is_active=false for testing

Response 201 Created

{
"workflow_id": "wf_new456",
"message": "Workflow imported successfully as 'Auto-Extract Pipeline (copy)'",
"was_existing": false
}

Errors: 400 if the export data is invalid or on_duplicate is "fail" and a workflow with the same name exists.


Workflow Triggers

List Triggers for Workflow

GET /api/v1/workflows/{workflow_id}/triggers

Returns all triggers configured to fire this workflow.

curl http://localhost:8080/api/v1/workflows/wf_abc123/triggers

Response 200 OK

[
{
"id": "trg_001",
"name": "On Upload Complete",
"event_source": "source.uploaded",
"workflow_id": "wf_abc123",
"enabled": true,
"priority": 0,
"created_at": "2026-03-01T12:00:00",
"updated_at": "2026-03-01T12:00:00"
}
]

Errors: 404 if the workflow does not exist.


Workflow Executions

Execute Workflow

POST /api/v1/workflows/{workflow_id}/executions

Queues a workflow for asynchronous execution. Returns immediately with an execution ID that you can use to poll for status.

curl -X POST http://localhost:8080/api/v1/workflows/wf_abc123/executions \
-H "Content-Type: application/json" \
-d '{
"inputs": {
"source_id": "src_789"
},
"triggered_by": "manual"
}'
FieldTypeRequiredDefaultDescription
inputsobjectNo{}Input values matching the workflow's input_schema
triggered_bystringNo"manual"Origin of the execution (e.g., manual, trigger, api)

Response 202 Accepted

{
"execution_id": "exec_xyz789",
"status": "queued",
"message": "Workflow execution queued successfully"
}

List Executions

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

Paginated execution history for a workflow.

curl "http://localhost:8080/api/v1/workflows/wf_abc123/executions?status=completed&page=1&page_size=20"
ParameterTypeRequiredDefaultDescription
pageintNo1Page number (1-indexed)
page_sizeintNo50Items per page (max 1000)
statusstringNonullFilter: pending, running, completed, failed, cancelled

Response 200 OK

{
"data": [
{
"id": "exec_xyz789",
"workflow_id": "wf_abc123",
"status": "completed",
"triggered_by": "manual",
"duration_ms": 12500,
"created_at": "2026-03-09T08:30:00",
"completed_at": "2026-03-09T08:30:13"
}
],
"pagination": {
"page": 1,
"page_size": 50,
"total_items": 1,
"total_pages": 1
}
}

Each item in data contains the full execution object (see Get Execution Details for the complete schema), excluding step_executions.

Get Execution Details

GET /api/v1/workflows/{workflow_id}/executions/{execution_id}

Returns full execution details including individual step execution results.

curl http://localhost:8080/api/v1/workflows/wf_abc123/executions/exec_xyz789

Response 200 OK

{
"id": "exec_xyz789",
"workflow_id": "wf_abc123",
"triggered_by": "manual",
"trigger_id": null,
"parent_execution_id": null,
"inputs": {"source_id": "src_789"},
"outputs": {"entities_extracted": 42},
"status": "completed",
"current_step_id": null,
"failed_step_id": null,
"error_message": null,
"duration_ms": 12500,
"created_at": "2026-03-09T08:30:00",
"started_at": "2026-03-09T08:30:01",
"completed_at": "2026-03-09T08:30:13",
"step_executions": [
{
"step_id": "step_001",
"step_name": "Extract Entities",
"status": "completed",
"started_at": "2026-03-09T08:30:01",
"completed_at": "2026-03-09T08:30:13",
"outputs": {"entities_extracted": 42},
"error_message": null
}
]
}

Errors: 404 if the workflow or execution does not exist.

Cancel Execution

POST /api/v1/workflows/{workflow_id}/executions/{execution_id}/cancel

Gracefully cancels a running or queued execution.

curl -X POST http://localhost:8080/api/v1/workflows/wf_abc123/executions/exec_xyz789/cancel

Response 200 OK

{
"execution_id": "exec_xyz789",
"status": "cancelled",
"message": "Execution cancelled"
}

Errors: 404 if not found, 400 if the execution has already completed, failed, or been cancelled.


Workflow Stats

Per-Workflow Stats

GET /api/v1/workflows/{workflow_id}/stats

Aggregate execution statistics for a single workflow.

curl http://localhost:8080/api/v1/workflows/wf_abc123/stats

Response 200 OK

{
"workflow_id": "wf_abc123",
"total_executions": 150,
"successful_executions": 142,
"failed_executions": 6,
"cancelled_executions": 2,
"success_rate": 0.9467,
"avg_duration_ms": 12500,
"min_duration_ms": 3200,
"max_duration_ms": 45000,
"last_execution_at": "2026-03-09T08:30:00",
"last_success_at": "2026-03-09T08:30:00",
"last_failure_at": "2026-03-08T14:12:00",
"updated_at": "2026-03-09T08:30:13"
}

Errors: 404 if the workflow does not exist.

Global Stats

GET /api/v1/workflows/stats

Aggregated statistics across all workflows in the current database.

curl http://localhost:8080/api/v1/workflows/stats

Response 200 OK

{
"total_workflows": 12,
"active_workflows": 10,
"inactive_workflows": 2,
"total_executions": 1450,
"successful_executions": 1380,
"failed_executions": 55,
"cancelled_executions": 15,
"success_rate": 0.9517
}

Execution Flow Example

A typical execute-poll-result workflow:

1. Start execution

curl -X POST http://localhost:8080/api/v1/workflows/wf_abc123/executions \
-H "Content-Type: application/json" \
-d '{"inputs": {"source_id": "src_789"}}'

Response (202 Accepted):

{
"execution_id": "exec_xyz789",
"status": "queued",
"message": "Workflow execution queued successfully"
}

2. Poll for status

curl http://localhost:8080/api/v1/workflows/wf_abc123/executions/exec_xyz789

While running, the status field will be "running" and current_step_id will indicate which step is active.

3. Check final result

Once status is "completed" or "failed", the response includes:

  • outputs -- the final workflow outputs (on success)
  • error_message and failed_step_id -- diagnostic info (on failure)
  • duration_ms -- total wall-clock time
  • step_executions -- per-step breakdown