## Delete a flow

`DELETE /v1/tasks/flows/:flowId`

Deletes a task flow by its ID.

## Parameters

| Parameter | Type | Required | Description |
|----------|-----|:-----:|----------|
| `flowId` (path) | number | yes | Flow ID, a positive integer. List: [`GET /v1/tasks/flows`](/docs/entities/tasks/flows-list) |

## Examples

### curl — personal key

```bash
curl -X DELETE "https://vibecode.bitrix24.com/v1/tasks/flows/20" \
  -H "X-Api-Key: YOUR_API_KEY"
```

### curl — OAuth application

```bash
curl -X DELETE "https://vibecode.bitrix24.com/v1/tasks/flows/20" \
  -H "X-Api-Key: YOUR_APP_KEY" \
  -H "Authorization: Bearer USER_SESSION_TOKEN"
```

### JavaScript — personal key

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/tasks/flows/20', {
  method: 'DELETE',
  headers: {
    'X-Api-Key': 'YOUR_API_KEY',
  },
})

const { success, data } = await res.json()
if (success && data.deleted) {
  console.log('Flow deleted')
}
```

### JavaScript — OAuth application

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/tasks/flows/20', {
  method: 'DELETE',
  headers: {
    'X-Api-Key': 'YOUR_APP_KEY',
    'Authorization': 'Bearer USER_SESSION_TOKEN',
  },
})

const { success, data } = await res.json()
if (success && data.deleted) {
  console.log('Flow deleted')
}
```

## Response fields

A successful deletion returns `200` with a body, not `204 No Content`.

| Field | Type | Description |
|------|-----|----------|
| `success` | boolean | `true` on success |
| `data.deleted` | boolean | `true` — the flow is deleted |

## Response example

```json
{
  "success": true,
  "data": {
    "deleted": true
  }
}
```

## Error response example

422 — no flow with this `flowId` exists, or it is already deleted:

```json
{
  "success": false,
  "error": {
    "code": "BITRIX_ERROR",
    "message": "Unknown error. [Flow: 312]",
    "b24Code": "0"
  }
}
```

## Errors

| HTTP | Code | Description |
|------|-----|----------|
| 400 | `INVALID_PARAMS` | `flowId` is not a positive integer. Message: `flowId must be a positive safe integer` |
| 400 | `FST_ERR_CTP_EMPTY_JSON_BODY` | The `Content-Type: application/json` header is sent with an empty body. Remove the header |
| 401 | `MISSING_API_KEY` | The `X-Api-Key` header is missing |
| 401 | `INVALID_API_KEY` | The key is not found |
| 401 | `TOKEN_MISSING` | The key has no Bitrix24 tokens |
| 403 | `SCOPE_DENIED` | The key has neither the `task` nor the `tasks` scope |
| 403 | `WRITE_BLOCKED_READONLY_KEY` | The key is in read-only mode. `error.details.switchUrl` holds the address of the section where the mode is changed |
| 422 | `BITRIX_ERROR` | No flow with this `flowId` exists, including on a repeated deletion. The message looks like `Unknown error. [Flow: 312]`; there is no `404` response in this case |
| 429 | `RATE_LIMITED` | The request rate to Bitrix24 or to the platform is exceeded. Retry after the delay in the `Retry-After` header |
| 502 | `BITRIX_UNAVAILABLE` | Bitrix24 is unreachable or returned a server error |
| 503 | `BITRIX_TIMEOUT` | Bitrix24 did not respond in time |

Full list of common API errors — [Errors](/docs/errors).

## Known specifics

**The flow's workgroup stays.** Deletion does not touch the group the flow was bound to, including a group created together with the flow. While the group exists, a new flow with the same name cannot be created without `groupId` — the response is `422` with the message `A group with this name already exists`. To delete the group as well, save the `groupId` from [`GET /v1/tasks/flows/:flowId`](/docs/entities/tasks/flows-get) before deleting the flow and call [`DELETE /v1/workgroups/:id`](/docs/entities/workgroups/delete).

**Disabling instead of deleting.** To stop a flow and keep its settings, disable it: [`POST /v1/tasks/flows/:flowId/activate`](/docs/entities/tasks/flows-activate) switches an enabled flow to disabled.

## See also

- [Flows and flow tasks](/docs/entities/tasks/flows)
- [List flows](/docs/entities/tasks/flows-list)
- [Get a flow](/docs/entities/tasks/flows-get)
- [Create a flow](/docs/entities/tasks/flows-create)
- [Toggle flow activity](/docs/entities/tasks/flows-activate)
- [Workgroups](/docs/entities/workgroups)
