# Deactivate workflow

> Turn a workflow off (back to draft).

Source: https://docs.mycrmsim.com/docs/automations/deactivate-workflow

```http
POST https://backend.mysmsgateway.app/api/v1/ext/workflows/{id}/deactivate
```

- Category: myCRMSIM Automations / Automations
- Auth: Bearer access token
- Scope: `automations.write`

Its triggers stop starting it, and the runs in progress are **cancelled**. A workflow an AI agent uses as a task cannot be turned off until it is removed from the agent (400).

## Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `id` | path | number | yes | Workflow id. Example: `1201` |
| `workspace_id` | body | number | yes | A workspace of the installer. Example: `7` |

## Request body

```json
{
  "workspace_id": 7
}
```

## Response 200

OK

```json
{
  "success": true,
  "message": "Workflow deactivated (draft). Runs in progress were cancelled.",
  "data": {
    "id": 1201,
    "status": "draft"
  }
}
```

## Response 400

Used by an AI agent

```json
{
  "success": false,
  "message": "This workflow is in use by AI agent (Revive). Remove it from the agent's tasks before you unpublish it."
}
```

## Response 401

Missing or invalid token

```json
{
  "success": false,
  "message": "Invalid or expired access token."
}
```

## Response 403

Missing scope

```json
{
  "success": false,
  "message": "Missing scope(s): automations.write. This integration was granted: …"
}
```

## Response 404

workspace_id does not exist or is not the installer's (same response for both)

```json
{
  "success": false,
  "message": "Workspace not found or not accessible to this token"
}
```

## Response 404

The workflow does not exist, is not the installer's, or is in another workspace

```json
{
  "success": false,
  "message": "Workflow not found or not accessible to this token"
}
```
