> ## Documentation Index
> Fetch the complete documentation index at: https://docs.danubeai.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Execute Workflow

> Run a workflow with the provided inputs

## Overview

Executes a workflow by running each step sequentially. Each step calls a Danube tool and template variables are resolved with results from previous steps. Returns the full execution result including all step outcomes.

**Auth:** Accepts either JWT or API key (`danube-api-key` header). Public workflows can be executed by any authenticated user; private workflows require ownership.

## Path Parameters

<ParamField path="workflow_id" type="string" required>
  The workflow UUID to execute
</ParamField>

## Body Parameters

<ParamField body="inputs" type="object" default={{}}>
  Input values referenced by `{{inputs.field}}` templates in the workflow steps
</ParamField>

## Response

<ResponseField name="id" type="string">
  Execution ID (use to poll status or retrieve results later)
</ResponseField>

<ResponseField name="workflow_id" type="string">
  The workflow that was executed
</ResponseField>

<ResponseField name="status" type="string">
  Execution status: `pending`, `running`, `success`, or `failed`
</ResponseField>

<ResponseField name="inputs" type="object">
  The inputs that were provided
</ResponseField>

<ResponseField name="step_results" type="array">
  Results from each step

  <Expandable title="Step result object">
    <ResponseField name="step_number" type="integer">
      Step position
    </ResponseField>

    <ResponseField name="tool_id" type="string">
      Tool that was executed
    </ResponseField>

    <ResponseField name="tool_name" type="string">
      Tool name
    </ResponseField>

    <ResponseField name="status" type="string">
      `success` or `failed`
    </ResponseField>

    <ResponseField name="result" type="any">
      Tool output (varies by tool)
    </ResponseField>

    <ResponseField name="error" type="string">
      Error message if step failed
    </ResponseField>

    <ResponseField name="execution_time_ms" type="integer">
      Step execution time in milliseconds
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="error" type="string">
  Overall error message if the workflow failed
</ResponseField>

<ResponseField name="execution_time_ms" type="integer">
  Total execution time in milliseconds
</ResponseField>

<ResponseField name="started_at" type="string">
  ISO 8601 timestamp when execution began
</ResponseField>

<ResponseField name="completed_at" type="string">
  ISO 8601 timestamp when execution finished
</ResponseField>

## Example

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST "https://api.danubeai.com/v1/workflows/wf_abc123/execute" \
    -H "danube-api-key: YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "inputs": {
        "city": "San Francisco",
        "channel": "#weather-alerts"
      }
    }'
  ```

  ```python Python SDK theme={null}
  from danube import DanubeClient

  with DanubeClient(api_key="dk_...") as client:
      execution = client.workflows.execute(
          "wf_abc123",
          inputs={"city": "San Francisco", "channel": "#weather-alerts"}
      )
      print(f"Status: {execution.status}")
      for step in execution.step_results:
          print(f"  Step {step.step_number}: {step.status}")
  ```
</RequestExample>

<ResponseExample>
  ```json theme={null}
  {
    "id": "exec_xyz789",
    "workflow_id": "wf_abc123",
    "user_id": "user_456",
    "status": "success",
    "inputs": {
      "city": "San Francisco",
      "channel": "#weather-alerts"
    },
    "step_results": [
      {
        "step_number": 1,
        "tool_id": "tool_weather_001",
        "tool_name": "Weather - Get Forecast",
        "status": "success",
        "result": {
          "forecast": "Partly cloudy, 18C, 10% chance of rain"
        },
        "error": null,
        "execution_time_ms": 340
      },
      {
        "step_number": 2,
        "tool_id": "tool_slack_001",
        "tool_name": "Slack - Send Message",
        "status": "success",
        "result": {
          "message_ts": "1708100000.000100"
        },
        "error": null,
        "execution_time_ms": 210
      }
    ],
    "error": null,
    "execution_time_ms": 550,
    "started_at": "2026-02-16T12:00:00Z",
    "completed_at": "2026-02-16T12:00:01Z",
    "created_at": "2026-02-16T12:00:00Z"
  }
  ```
</ResponseExample>

## MCP Tool

This endpoint is also available as the `execute_workflow` MCP tool:

```python theme={null}
result = await mcp.call_tool("execute_workflow", {
    "workflow_id": "wf_abc123",
    "inputs": {"city": "San Francisco"}
})
```
