API Reference

Workflows API

Complete API reference for creating, managing, and executing automated workflows.

List Workflows

Retrieve all workflows for the authenticated tenant.

GET /api/v1/workflows
# Request
curl https://api.engrami.com/api/v1/workflows?tenant_id=tenant_xyz \
  -H "Authorization: Bearer YOUR_TOKEN"

# Response
{
  "items": [
    {
      "id": "wf_abc123",
      "name": "Customer Onboarding",
      "description": "Automated customer onboarding flow",
      "status": "active",
      "trigger_type": "webhook",
      "last_run_at": "2024-01-20T15:30:00Z",
      "created_at": "2024-01-15T10:30:00Z"
    }
  ],
  "total": 5,
  "page": 1
}

Create Workflow

Create a new workflow with nodes and edges configuration.

POST /api/v1/workflows
# Request
curl -X POST https://api.engrami.com/api/v1/workflows?tenant_id=tenant_xyz \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Support Ticket Handler",
    "description": "Automatically classify and route support tickets",
    "nodes": [
      {
        "id": "trigger",
        "type": "webhook",
        "config": { "path": "/tickets" }
      },
      {
        "id": "classify",
        "type": "agent",
        "config": { "agent_id": "agent_classifier" }
      },
      {
        "id": "route",
        "type": "condition",
        "config": {
          "rules": [
            { "if": "priority == high", "goto": "escalate" },
            { "else": "respond" }
          ]
        }
      },
      {
        "id": "respond",
        "type": "agent",
        "config": { "agent_id": "agent_support" }
      },
      {
        "id": "escalate",
        "type": "integration",
        "config": { "service": "pagerduty" }
      }
    ],
    "edges": [
      { "source": "trigger", "target": "classify" },
      { "source": "classify", "target": "route" },
      { "source": "route", "target": "respond" },
      { "source": "route", "target": "escalate" }
    ]
  }'

# Response
{
  "id": "wf_def456",
  "name": "Support Ticket Handler",
  "status": "draft",
  "webhook_url": "https://hooks.engrami.com/wf_def456/tickets",
  "created_at": "2024-01-20T16:00:00Z"
}

Get Workflow

Retrieve a specific workflow with full configuration.

GET /api/v1/workflows/{workflow_id}
# Request
curl https://api.engrami.com/api/v1/workflows/wf_abc123 \
  -H "Authorization: Bearer YOUR_TOKEN"

# Response
{
  "id": "wf_abc123",
  "name": "Customer Onboarding",
  "description": "Automated customer onboarding flow",
  "status": "active",
  "nodes": [...],
  "edges": [...],
  "trigger_type": "webhook",
  "webhook_url": "https://hooks.engrami.com/wf_abc123",
  "statistics": {
    "total_runs": 1523,
    "success_rate": 0.98,
    "avg_duration": "12.5s"
  },
  "created_at": "2024-01-15T10:30:00Z"
}

Update Workflow

Update a workflow's configuration.

PUT /api/v1/workflows/{workflow_id}
# Request
curl -X PUT https://api.engrami.com/api/v1/workflows/wf_abc123 \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Enhanced Onboarding",
    "nodes": [...],
    "edges": [...]
  }'

# Response
{
  "id": "wf_abc123",
  "name": "Enhanced Onboarding",
  "status": "active",
  "updated_at": "2024-01-20T16:30:00Z"
}

Execute Workflow

Manually trigger a workflow execution.

POST /api/v1/workflows/{workflow_id}/execute
# Request
curl -X POST https://api.engrami.com/api/v1/workflows/wf_abc123/execute \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "input": {
      "customer_id": "cust_123",
      "email": "customer@example.com"
    },
    "async": true
  }'

# Response
{
  "execution_id": "exec_xyz789",
  "workflow_id": "wf_abc123",
  "status": "running",
  "started_at": "2024-01-20T16:45:00Z"
}

Get Execution Status

Check the status of a workflow execution.

GET /api/v1/workflows/{workflow_id}/executions/{execution_id}
# Request
curl https://api.engrami.com/api/v1/workflows/wf_abc123/executions/exec_xyz789 \
  -H "Authorization: Bearer YOUR_TOKEN"

# Response
{
  "execution_id": "exec_xyz789",
  "workflow_id": "wf_abc123",
  "status": "completed",
  "started_at": "2024-01-20T16:45:00Z",
  "completed_at": "2024-01-20T16:45:12Z",
  "duration_ms": 12450,
  "node_executions": [
    {
      "node_id": "trigger",
      "status": "completed",
      "started_at": "2024-01-20T16:45:00Z",
      "duration_ms": 50
    },
    {
      "node_id": "classify",
      "status": "completed",
      "output": { "category": "onboarding" },
      "duration_ms": 2300
    }
  ],
  "output": {
    "success": true,
    "customer_onboarded": true
  }
}

List Executions

Get execution history for a workflow.

GET /api/v1/workflows/{workflow_id}/executions
# Request
curl https://api.engrami.com/api/v1/workflows/wf_abc123/executions?limit=10&status=completed \
  -H "Authorization: Bearer YOUR_TOKEN"

# Response
{
  "items": [
    {
      "execution_id": "exec_xyz789",
      "status": "completed",
      "duration_ms": 12450,
      "started_at": "2024-01-20T16:45:00Z"
    },
    {
      "execution_id": "exec_xyz788",
      "status": "completed",
      "duration_ms": 11200,
      "started_at": "2024-01-20T15:30:00Z"
    }
  ],
  "total": 156
}

Pause/Resume Workflow

POST /api/v1/workflows/{workflow_id}/pause
# Pause
curl -X POST https://api.engrami.com/api/v1/workflows/wf_abc123/pause \
  -H "Authorization: Bearer YOUR_TOKEN"

# Resume
curl -X POST https://api.engrami.com/api/v1/workflows/wf_abc123/resume \
  -H "Authorization: Bearer YOUR_TOKEN"

# Response
{
  "id": "wf_abc123",
  "status": "paused",  // or "active"
  "updated_at": "2024-01-20T17:00:00Z"
}
Continue to Memory API