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

# Update workflow

> MCP tool to update an existing workflow in the Thena platform.

import Admonition from '@theme/Admonition';

### MCP tool: `update_workflow`

Updates an existing workflow's definition and configuration. This tool allows you to modify workflow steps, activities, triggers, and execution policies while preserving the workflow's unique identifier.

<Admonition type="note">
  You must provide the workflow unique identifier. All other fields are optional and only the provided fields will be updated.
</Admonition>

### Example prompt

```prompt theme={null}
Update workflow "ticket-escalation-workflow" to add a new notification step and modify the retry policy
```

<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>update\_workflow</code> tool with the correct arguments.
</Admonition>

### Input parameters

| Name                     | Type    | Required | Description                                     |
| ------------------------ | ------- | -------- | ----------------------------------------------- |
| workflowUniqueIdentifier | string  | Yes      | The unique identifier of the workflow to update |
| name                     | string  | No       | The updated name of the workflow                |
| teamId                   | string  | No       | The team ID that owns this workflow             |
| triggerEvent             | object  | No       | 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   | No       | The definition of workflow steps                |
| executingAgent           | string  | No       | The agent that executes this workflow           |
| isActive                 | boolean | No       | Whether the workflow is active                  |
| 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 updated 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": "Enhanced Ticket Escalation Workflow",
    "version": 2,
    "triggerEvent": {
      "id": "EVENT001",
      "name": "ticket.created",
      "description": "Triggered when a new ticket is created"
    },
    "filters": {
      "priority": "high",
      "team": "support",
      "autoEscalate": true,
      "escalationThreshold": 15
    },
    "annotations": [
      {
        "entityType": "workflow",
        "data": {
          "tags": ["escalation", "automation", "enhanced"]
        },
        "relations": []
      }
    ],
    "workflowDefinition": [
      {
        "stepIdentifier": 1,
        "activity": {
          "name": "send-notification",
          "uniqueIdentifier": "notification.activity",
          "version": 2,
          "autoUpgradeToLatestVersion": true
        },
        "input": {
          "recipients": ["support-team", "senior-agents"],
          "message": "High priority ticket requires immediate attention",
          "priority": "urgent",
          "includeMetrics": true
        },
        "retryPolicy": {
          "maximumAttempts": 5,
          "initialInterval": 2000,
          "backoffCoefficient": 2.5
        },
        "onFailure": "CONTINUE",
        "isSleepActivity": false,
        "executionTimeout": 45000,
        "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", "senior"],
          "autoAssign": true,
          "loadBalancing": true
        },
        "retryPolicy": {
          "maximumAttempts": 3,
          "initialInterval": 5000,
          "backoffCoefficient": 1.5
        },
        "onFailure": "ABORT",
        "isSleepActivity": false,
        "executionTimeout": 60000,
        "dependencies": [1],
        "filters": {
          "agentLevel": "senior"
        }
      },
      {
        "stepIdentifier": 3,
        "activity": {
          "name": "update-ticket-status",
          "uniqueIdentifier": "status-update.activity",
          "version": 1,
          "autoUpgradeToLatestVersion": true
        },
        "input": {
          "status": "escalated",
          "comment": "Automatically escalated due to high priority",
          "addTimestamp": true
        },
        "retryPolicy": {
          "maximumAttempts": 2,
          "initialInterval": 1000,
          "backoffCoefficient": 1
        },
        "onFailure": "CONTINUE",
        "isSleepActivity": false,
        "executionTimeout": 15000,
        "dependencies": [2],
        "filters": {}
      }
    ],
    "executingAgent": "workflow-engine-v2",
    "isActive": true,
    "createdAt": "2025-07-24T07:19:10.258Z",
    "updatedAt": "2025-07-25T12:50:38.937Z",
    "createdBy": "USER001",
    "teamId": "TEAM001",
    "metadata": {
      "description": "Enhanced automated workflow for escalating high-priority tickets",
      "tags": ["escalation", "automation", "support", "enhanced"],
      "category": "customer-service",
      "version": "2.0",
      "lastUpdated": "2025-07-25T12:50:38.937Z"
    }
  },
  "status": true,
  "message": "Workflow updated 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 modifies existing workflow data. Only the fields you provide will be updated; other fields will remain unchanged. The workflow version will be incremented automatically.
</Admonition>

***
