Skip to content

Workflows API

Create, manage, and execute visual workflows.

Endpoints

MethodEndpointDescription
GET/api/agents/{id}/workflowsList workflows
POST/api/agents/{id}/workflowsCreate workflow
GET/api/agents/{id}/workflows/{workflowId}Get workflow
PUT/api/agents/{id}/workflows/{workflowId}Update workflow
DELETE/api/agents/{id}/workflows/{workflowId}Delete workflow
POST/api/agents/{id}/workflows/executeExecute workflow

List Workflows

bash
GET /api/agents/{id}/workflows

Query Parameters

ParameterTypeDescription
statusstringFilter by status
limitnumberMax results (default: 50)
offsetnumberSkip results

Response

json
{
  "workflows": [
    {
      "id": "workflow-123",
      "name": "Email Notification",
      "description": "Send email on events",
      "status": "active",
      "created_at": "2024-12-01T00:00:00Z",
      "updated_at": "2024-12-15T10:00:00Z"
    }
  ],
  "meta": {
    "total": 10,
    "limit": 50,
    "offset": 0
  }
}

Create Workflow

bash
POST /api/agents/{id}/workflows
Content-Type: application/json

Request Body

json
{
  "name": "Email Notification",
  "description": "Send email on events",
  "nodes": [
    {
      "id": "trigger-1",
      "type": "trigger",
      "position": { "x": 100, "y": 100 },
      "data": { "event": "schedule" }
    },
    {
      "id": "email-1",
      "type": "email",
      "position": { "x": 300, "y": 100 },
      "data": {
        "to": "{{contact.email}}",
        "subject": "Notification",
        "body": "Hello {{contact.name}}"
      }
    }
  ],
  "edges": [
    {
      "id": "edge-1",
      "source": "trigger-1",
      "target": "email-1"
    }
  ],
  "status": "draft"
}

Response

json
{
  "id": "workflow-123",
  "name": "Email Notification",
  "status": "draft",
  "created_at": "2024-12-15T10:00:00Z"
}

Get Workflow

bash
GET /api/agents/{id}/workflows/{workflowId}

Response

json
{
  "id": "workflow-123",
  "name": "Email Notification",
  "description": "Send email on events",
  "nodes": [...],
  "edges": [...],
  "status": "active",
  "created_at": "2024-12-01T00:00:00Z",
  "updated_at": "2024-12-15T10:00:00Z"
}

Update Workflow

bash
PUT /api/agents/{id}/workflows/{workflowId}
Content-Type: application/json

Request Body

json
{
  "name": "Updated Workflow",
  "nodes": [...],
  "edges": [...],
  "status": "active"
}

Delete Workflow

bash
DELETE /api/agents/{id}/workflows/{workflowId}

Response

json
{
  "success": true
}

Execute Workflow

bash
POST /api/agents/{id}/workflows/execute
Content-Type: application/json

Request Body

json
{
  "workflow_id": "workflow-123",
  "input": {
    "contact": {
      "name": "John",
      "email": "john@example.com"
    }
  }
}

Response

json
{
  "execution_id": "exec-456",
  "status": "running",
  "started_at": "2024-12-15T10:00:00Z"
}

Execution Status

Get Execution

bash
GET /api/agents/{id}/workflows/executions/{executionId}

Response

json
{
  "id": "exec-456",
  "workflow_id": "workflow-123",
  "status": "complete",
  "input": {...},
  "output": {...},
  "started_at": "2024-12-15T10:00:00Z",
  "completed_at": "2024-12-15T10:00:05Z",
  "node_results": [
    {
      "node_id": "trigger-1",
      "status": "complete",
      "duration_ms": 10
    },
    {
      "node_id": "email-1",
      "status": "complete",
      "duration_ms": 500
    }
  ]
}

Execution Statuses

StatusDescription
queuedWaiting to start
runningCurrently executing
completeFinished successfully
erroredFailed with error
terminatedManually stopped

List Executions

bash
GET /api/agents/{id}/workflows/executions?workflow_id={workflowId}&limit=50

Response

json
{
  "executions": [
    {
      "id": "exec-456",
      "workflow_id": "workflow-123",
      "status": "complete",
      "started_at": "2024-12-15T10:00:00Z",
      "completed_at": "2024-12-15T10:00:05Z"
    }
  ]
}

Workflow Status

StatusDescription
draftNot ready for execution
activeReady for execution
pausedTemporarily disabled
archivedNo longer in use

Node Types

TypeDescription
triggerStart node
if-elseConditional branching
switchMulti-way branching
loopIterate over items
waitDelay execution
http-requestMake HTTP requests
emailSend email
telegramSend Telegram message
slackSend Slack message
navigateBrowser navigation
clickBrowser click
chatAI conversation
codeExecute JavaScript

Errors

CodeDescription
400Invalid workflow data
404Workflow not found
409Execution already running

Examples

Create and Execute

bash
# Create workflow
curl -X POST https://your-domain.com/api/agents/{id}/workflows \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Simple Flow",
    "nodes": [...],
    "edges": [...],
    "status": "active"
  }'

# Execute
curl -X POST https://your-domain.com/api/agents/{id}/workflows/execute \
  -d '{"workflow_id": "workflow-123", "input": {}}'

Released under the MIT License.