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

# Create workflow

> MCP tool to create a new workflow in the Thena platform.

import Admonition from '@theme/Admonition';

### MCP tool: `create_workflow`

Creates a new workflow with comprehensive definition and configuration. This tool allows you to define workflow steps, activities, triggers, and execution policies.

<Admonition type="note">
  You must provide a name, team ID, type, trigger event, and workflow definition. All other fields are optional with sensible defaults.
</Admonition>

### Example prompt

```prompt theme={null}
Create a workflow for ticket escalation with notification and assignment steps
```

<Admonition type="info">
  When you use this prompt in a chat with the model (with the MCP tool registered), the model will automatically call the <code>create\_workflow</code> tool with the correct arguments.
</Admonition>

### Input parameters

| Name               | Type    | Required | Description                                    |
| ------------------ | ------- | -------- | ---------------------------------------------- |
| name               | string  | Yes      | The name of the workflow                       |
| teamId             | string  | Yes      | The team ID that owns this workflow            |
| type               | string  | Yes      | The type of the workflow                       |
| subType            | string  | No       | The sub-type of the workflow                   |
| triggerEvent       | object  | Yes      | The event that triggers this workflow          |
| filters            | object  | No       | Filters to apply to the workflow trigger       |
| annotations        | array   | No       | Annotations for the workflow                   |
| workflowDefinition | array   | Yes      | The definition of workflow steps               |
| executingAgent     | string  | No       | The agent that executes this workflow          |
| isActive           | boolean | No       | Whether the workflow is active (default: true) |
| metadata           | object  | No       | Additional metadata for the workflow           |

#### Trigger event structure

| Field     | Type   | Required | Description                                |
| --------- | ------ | -------- | ------------------------------------------ |
| uid       | string | Yes      | The unique identifier of the trigger event |
| eventName | string | Yes      | The name of the trigger event              |

#### Workflow step structure

Each step in the `workflowDefinition` array contains:

| Field            | Type    | Required | Description                                             |
| ---------------- | ------- | -------- | ------------------------------------------------------- |
| stepIdentifier   | number  | Yes      | The identifier for this step                            |
| activity         | object  | Yes      | The activity to execute in this step                    |
| input            | object  | Yes      | The input parameters for this activity                  |
| retryPolicy      | object  | No       | The retry policy for this step                          |
| onFailure        | string  | No       | Action to take on failure (CONTINUE, ABORT, COMPENSATE) |
| isSleepActivity  | boolean | No       | Whether this is a sleep/wait activity                   |
| executionTimeout | number  | No       | Timeout for execution in seconds                        |
| approver         | object  | No       | Approver configuration for this step                    |
| dependencies     | array   | No       | Step dependencies                                       |
| filters          | object  | No       | Filters for this step                                   |

#### Activity structure

| Field                      | Type    | Required | Description                                                            |
| -------------------------- | ------- | -------- | ---------------------------------------------------------------------- |
| uniqueIdentifier           | string  | Yes      | The unique identifier of the activity                                  |
| version                    | number  | No       | The version of the activity                                            |
| autoUpgradeToLatestVersion | boolean | No       | Whether to automatically upgrade to the latest version (default: true) |

#### Retry policy structure

| Field              | Type   | Required | Description                                 |
| ------------------ | ------ | -------- | ------------------------------------------- |
| maximumAttempts    | number | No       | Maximum number of retry attempts            |
| initialInterval    | number | No       | Initial interval between retries in seconds |
| backoffCoefficient | number | No       | Backoff coefficient for retry intervals     |

#### Approver structure

| Field   | Type   | Required | Description                     |
| ------- | ------ | -------- | ------------------------------- |
| type    | string | No       | Type of approver (TEAM or USER) |
| uid     | string | No       | ID of the approver              |
| timeout | number | No       | Timeout for approval in seconds |

### Response fields

The response will contain the created workflow with the same structure as the `get_workflow` tool.

### Sample response

```json theme={null}
{
  "data": {
    "uid": "WORKFLOW001",
    "type": "WORKFLOW",
    "subType": "AI_AGENT",
    "uniqueIdentifier": "ticket-escalation-workflow",
    "name": "Ticket Escalation Workflow",
    "version": 1,
    "triggerEvent": {
      "id": "EVENT001",
      "name": "ticket.created",
      "description": "Triggered when a new ticket is created"
    },
    "filters": {
      "priority": "high",
      "team": "support"
    },
    "annotations": [
      {
        "entityType": "workflow",
        "data": {
          "tags": ["escalation", "automation"]
        },
        "relations": []
      }
    ],
    "workflowDefinition": [
      {
        "stepIdentifier": 1,
        "activity": {
          "name": "send-notification",
          "uniqueIdentifier": "notification.activity",
          "version": 1,
          "autoUpgradeToLatestVersion": true
        },
        "input": {
          "recipients": ["support-team"],
          "message": "High priority ticket requires immediate attention",
          "priority": "urgent"
        },
        "retryPolicy": {
          "maximumAttempts": 3,
          "initialInterval": 1000,
          "backoffCoefficient": 2
        },
        "onFailure": "CONTINUE",
        "isSleepActivity": false,
        "executionTimeout": 30000,
        "dependencies": [],
        "filters": {
          "notificationType": "escalation"
        }
      },
      {
        "stepIdentifier": 2,
        "activity": {
          "name": "assign-to-senior-agent",
          "uniqueIdentifier": "assignment.activity",
          "version": 1,
          "autoUpgradeToLatestVersion": true
        },
        "input": {
          "priority": "high",
          "skillSet": ["escalation", "technical"],
          "autoAssign": true
        },
        "retryPolicy": {
          "maximumAttempts": 2,
          "initialInterval": 5000,
          "backoffCoefficient": 1.5
        },
        "onFailure": "ABORT",
        "isSleepActivity": false,
        "executionTimeout": 60000,
        "dependencies": [1],
        "filters": {
          "agentLevel": "senior"
        }
      }
    ],
    "executingAgent": "workflow-engine",
    "isActive": true,
    "createdAt": "2025-07-24T07:19:10.258Z",
    "updatedAt": "2025-07-24T07:19:10.258Z",
    "createdBy": "USER001",
    "teamId": "TEAM001",
    "metadata": {
      "description": "Automated workflow for escalating high-priority tickets",
      "tags": ["escalation", "automation", "support"],
      "category": "customer-service"
    }
  },
  "status": true,
  "message": "Workflow created successfully!",
  "timestamp": "2025-07-25T12:50:38.937Z"
}
```

<Admonition type="tip">
  Always pass an object as input, even if empty, to avoid errors when calling the tool directly.
</Admonition>

<Admonition type="warning">
  This tool creates new workflows in the system. Ensure all required fields are properly configured before creation.
</Admonition>

***
