> ## 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.

# Create Workflow

> Create a new multi-tool workflow

## Overview

Creates a new workflow that chains multiple Danube tools into an ordered pipeline. Each step executes a tool and can reference results from previous steps using template syntax (`{{steps.N.result.field}}`, `{{inputs.field}}`).

**Auth:** Accepts either JWT or API key (`danube-api-key` header).

## Body Parameters

<ParamField body="name" type="string" required>
  Workflow name (max 128 characters)
</ParamField>

<ParamField body="description" type="string" default="">
  Workflow description
</ParamField>

<ParamField body="steps" type="array" required>
  Ordered list of workflow steps

  <Expandable title="Step object">
    <ParamField body="step_number" type="integer" required>
      Step position (1-based)
    </ParamField>

    <ParamField body="tool_id" type="string" required>
      Tool UUID to execute
    </ParamField>

    <ParamField body="tool_name" type="string" required>
      Tool display name
    </ParamField>

    <ParamField body="description" type="string" required>
      What this step does
    </ParamField>

    <ParamField body="input_mapping" type="object" required>
      Parameter mapping with template variables. Use `{{inputs.field}}` for workflow inputs and `{{steps.N.result.field}}` for previous step outputs.
    </ParamField>
  </Expandable>
</ParamField>

<ParamField body="visibility" type="string" default="private">
  `"private"` or `"public"`
</ParamField>

<ParamField body="tags" type="array" default={[]}>
  Tags for discovery
</ParamField>

## Response

<ResponseField name="id" type="string">
  Created workflow UUID
</ResponseField>

<ResponseField name="name" type="string">
  Workflow name
</ResponseField>

<ResponseField name="description" type="string">
  Workflow description
</ResponseField>

<ResponseField name="steps" type="array">
  The workflow steps as provided
</ResponseField>

<ResponseField name="owner_id" type="string">
  Owner user ID
</ResponseField>

<ResponseField name="visibility" type="string">
  `"private"` or `"public"`
</ResponseField>

<ResponseField name="tags" type="array">
  Workflow tags
</ResponseField>

<ResponseField name="created_at" type="string">
  ISO 8601 creation timestamp
</ResponseField>

## Example

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST "https://api.danubeai.com/v1/workflows" \
    -H "danube-api-key: YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "name": "Weather Alert Pipeline",
      "description": "Get weather forecast and send Slack notification",
      "steps": [
        {
          "step_number": 1,
          "tool_id": "tool_weather_001",
          "tool_name": "Weather - Get Forecast",
          "description": "Fetch the weather forecast",
          "input_mapping": {"city": "{{inputs.city}}"}
        },
        {
          "step_number": 2,
          "tool_id": "tool_slack_001",
          "tool_name": "Slack - Send Message",
          "description": "Post forecast to Slack",
          "input_mapping": {
            "channel": "{{inputs.channel}}",
            "text": "Forecast: {{steps.1.result.forecast}}"
          }
        }
      ],
      "visibility": "private",
      "tags": ["weather", "notifications"]
    }'
  ```

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

  with DanubeClient(api_key="dk_...") as client:
      workflow = client.workflows.create(
          name="Weather Alert Pipeline",
          description="Get weather and send Slack notification",
          steps=[
              {
                  "step_number": 1,
                  "tool_id": "tool_weather_001",
                  "tool_name": "Weather - Get Forecast",
                  "description": "Fetch the weather forecast",
                  "input_mapping": {"city": "{{inputs.city}}"},
              },
              {
                  "step_number": 2,
                  "tool_id": "tool_slack_001",
                  "tool_name": "Slack - Send Message",
                  "description": "Post forecast to Slack",
                  "input_mapping": {
                      "channel": "{{inputs.channel}}",
                      "text": "Forecast: {{steps.1.result.forecast}}",
                  },
              },
          ],
          visibility="private",
          tags=["weather", "notifications"],
      )
      print(f"Created: {workflow.id}")
  ```

  ```typescript TypeScript SDK theme={null}
  import { DanubeClient } from 'danube';

  const client = new DanubeClient({ apiKey: 'dk_...' });
  const workflow = await client.workflows.create({
    name: 'Weather Alert Pipeline',
    description: 'Get weather and send Slack notification',
    steps: [
      {
        stepNumber: 1,
        toolId: 'tool_weather_001',
        toolName: 'Weather - Get Forecast',
        description: 'Fetch the weather forecast',
        inputMapping: { city: '{{inputs.city}}' },
      },
      {
        stepNumber: 2,
        toolId: 'tool_slack_001',
        toolName: 'Slack - Send Message',
        description: 'Post forecast to Slack',
        inputMapping: {
          channel: '{{inputs.channel}}',
          text: 'Forecast: {{steps.1.result.forecast}}',
        },
      },
    ],
    visibility: 'private',
    tags: ['weather', 'notifications'],
  });
  console.log(`Created: ${workflow.id}`);
  ```
</RequestExample>

<ResponseExample>
  ```json theme={null}
  {
    "id": "wf_abc123",
    "name": "Weather Alert Pipeline",
    "description": "Get weather forecast and send Slack notification",
    "steps": [
      {
        "step_number": 1,
        "tool_id": "tool_weather_001",
        "tool_name": "Weather - Get Forecast",
        "description": "Fetch the weather forecast",
        "input_mapping": {"city": "{{inputs.city}}"}
      },
      {
        "step_number": 2,
        "tool_id": "tool_slack_001",
        "tool_name": "Slack - Send Message",
        "description": "Post forecast to Slack",
        "input_mapping": {
          "channel": "{{inputs.channel}}",
          "text": "Forecast: {{steps.1.result.forecast}}"
        }
      }
    ],
    "owner_id": "user_456",
    "visibility": "private",
    "tags": ["weather", "notifications"],
    "created_at": "2026-02-21T12:00:00Z",
    "updated_at": "2026-02-21T12:00:00Z"
  }
  ```
</ResponseExample>

## MCP Tool

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

```python theme={null}
result = await mcp.call_tool("create_workflow", {
    "name": "Weather Alert Pipeline",
    "steps": [
        {
            "step_number": 1,
            "tool_id": "tool_weather_001",
            "tool_name": "Weather - Get Forecast",
            "description": "Fetch the weather forecast",
            "input_mapping": {"city": "{{inputs.city}}"}
        }
    ],
    "visibility": "private"
})
```
