Workflows
post/v1/workflows

Create a workflow

Creates a new workflow definition. The definition must include tenant_id, workflow_id, and a non-empty steps array. Each step requires id, type, and name, plus type-specific required fields:

  • mcp_call requires tool_name and server_url
  • llm_call requires model and prompt
  • human_task requires task_type
  • lua_script requires script (max 64 KB)

Returns 201 Created with the saved workflow including its assigned id.

Server

https://api.agentruntime.io/v1/workflows
Production
AuthenticationRequiredBearerAuth

API key obtained from the AgentRuntime dashboard. Pass as Authorization: Bearer <key> on every request.

Stored only in this page session. It is not saved to local storage.

Test Request

Runs from your browser. Non-GET requests require explicit confirmation and tokens are sent only when you click Send.

Enter a bearer token and confirm the non-GET request to enable testing.

Client Libraries
Shell
curl -sS -X POST \
  'https://api.agentruntime.io/v1/workflows' \
  -H 'Authorization: Bearer <token>'

application/json

namerequired

string

Example: "customer-support-v2"

description

string

Example: "Routes support tickets, drafts replies with GPT-4o, escalates on low confidence."

definitionrequired
{
  "name": "customer-support-v2",
  "description": "Routes support tickets, drafts replies, escalates on low confidence.",
  "definition": {
    "tenant_id": "acme-corp",
    "workflow_id": "customer-support-v2",
    "steps": [
      {
        "id": "classify",
        "type": "mcp_call",
        "name": "Classify intent",
        "tool_name": "classify_ticket",
        "tool_args": {
          "text": "{{input.message}}"
        },
        "server_url": "https://tools.acme.com/mcp",
        "timeout_s": 10
      },
      {
        "id": "draft-reply",
        "type": "llm_call",
        "name": "Draft reply",
        "model": "gpt-4o-mini",
        "prompt": "Ticket: {{input.message}}. Category: {{steps.classify.result.category}}. Write a helpful reply.",
        "depends_on": [
          "classify"
        ]
      },
      {
        "id": "human-review",
        "type": "human_task",
        "name": "Agent review",
        "task_type": "reply_approval",
        "task_payload": {
          "draft": "{{steps.draft-reply.result}}"
        },
        "depends_on": [
          "draft-reply"
        ]
      }
    ]
  }
}
  • 201Workflow created successfully.

    application/json

    idrequired

    string

    Unique workflow identifier, assigned on creation.

    Example: "wf_01hw3k9x4v8m"

    namerequired

    string

    Human-readable name. Used in URLs and run logs.

    Example: "customer-support-v2"

    description

    string

    Optional longer description shown in the dashboard.

    Example: "Routes support tickets, drafts replies with GPT-4o, escalates on low confidence."

    definitionrequired
    created_at

    string

    Example: "2026-01-15T09:30:00Z"

    updated_at

    string

    Example: "2026-03-22T14:12:00Z"

    version

    integer

    Increments on every update. Useful for cache-busting and auditing.

    Example: 3

    {
      "id": "wf_01hw3k9x4v8m",
      "name": "customer-support-v2",
      "version": 1,
      "created_at": "2026-04-10T10:00:00Z",
      "updated_at": "2026-04-10T10:00:00Z"
    }
  • 401Missing or invalid Bearer token.

    application/json

    errorrequired

    string

    Human-readable description of what went wrong.

    Example: "workflow not found"

    code

    string

    Machine-readable error code for programmatic handling.

    Example: "NOT_FOUND"

    {
      "error": "unauthorized",
      "code": "UNAUTHORIZED"
    }
  • 422The request body is valid JSON but fails business validation.

    application/json

    errorrequired

    string

    Human-readable description of what went wrong.

    Example: "workflow not found"

    code

    string

    Machine-readable error code for programmatic handling.

    Example: "NOT_FOUND"

    {
      "error": "workflow definition is missing required field: steps",
      "code": "VALIDATION_ERROR"
    }
  • 500Unexpected server error.

    application/json

    errorrequired

    string

    Human-readable description of what went wrong.

    Example: "workflow not found"

    code

    string

    Machine-readable error code for programmatic handling.

    Example: "NOT_FOUND"

    {
      "error": "internal server error",
      "code": "INTERNAL_ERROR"
    }