## Remove checklist item attachments

`POST /v1/tasks/:taskId/checklist/:itemId/attachments/remove`

Removes attachments from a task checklist item — files attached by content or from Bitrix24 Drive.

## Parameters

| Parameter | Type | Required | Description |
|----------|-----|:-----:|----------|
| `taskId` (path) | number | yes | Task ID. List: [`GET /v1/tasks`](/docs/entities/tasks/list) |
| `itemId` (path) | number | yes | Checklist item ID. List of items: [`GET /v1/tasks/:taskId/checklist`](/docs/entities/tasks/checklist/list) |

## Request fields (body)

| Field | Type | Required | Description |
|------|-----|:-----:|----------|
| `attachmentsIds` | array | yes | Attachment IDs — numbers. An attachment ID is a key of the item's `attachments` object, not a Drive file ID. List: [`GET /v1/tasks/:taskId/checklist/:itemId`](/docs/entities/tasks/checklist/get) |

## Examples

### curl — personal key

```bash
curl -X POST "https://vibecode.bitrix24.com/v1/tasks/4218/checklist/276/attachments/remove" \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"attachmentsIds":[592]}'
```

### curl — OAuth application

```bash
curl -X POST "https://vibecode.bitrix24.com/v1/tasks/4218/checklist/276/attachments/remove" \
  -H "X-Api-Key: YOUR_APP_KEY" \
  -H "Authorization: Bearer USER_SESSION_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"attachmentsIds":[592]}'
```

### JavaScript — personal key

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/tasks/4218/checklist/276/attachments/remove', {
  method: 'POST',
  headers: {
    'X-Api-Key': 'YOUR_API_KEY',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ attachmentsIds: [592] }),
})

const { success, data } = await res.json()
console.log('Attachments left:', Object.keys(data?.checkListItem?.attachments ?? {}).length)
```

### JavaScript — OAuth application

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/tasks/4218/checklist/276/attachments/remove', {
  method: 'POST',
  headers: {
    'X-Api-Key': 'YOUR_APP_KEY',
    'Authorization': 'Bearer USER_SESSION_TOKEN',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ attachmentsIds: [592] }),
})

const { success, data } = await res.json()
```

## Response fields

| Field | Type | Description |
|------|-----|----------|
| `success` | boolean | `true` if the request succeeded |
| `data.checkListItem` | object | The checklist item after the attachments were removed |
| `data.checkListItem.id` | number | Item ID |
| `data.checkListItem.copiedId` | number \| null | ID of the item this one was copied from. `null` — the item was not copied |
| `data.checkListItem.userId` | number | ID of the user on whose behalf the call is made |
| `data.checkListItem.createdBy` | number | ID of the item author. List: [`GET /v1/users`](/docs/entities/users/list) |
| `data.checkListItem.parentId` | number | Parent item ID. `0` — a top-level item |
| `data.checkListItem.title` | string | Item text |
| `data.checkListItem.sortIndex` | number | Position of the item among items with the same parent: the lower the number, the higher the item |
| `data.checkListItem.displaySortIndex` | string | Item number for display. An empty string in this method's response |
| `data.checkListItem.isComplete` | boolean | Whether the item is completed |
| `data.checkListItem.isImportant` | boolean | Whether the item is marked as important |
| `data.checkListItem.completedCount` | number | Number of completed sub-items. `0` in this method's response |
| `data.checkListItem.members` | array | Item members — objects with the fields `id`, `type`, `name`, `personalPhoto`, `personalGender`, `image`, `isCollaber`. `id` is the user ID as a string; `type`: `A` — participant, `U` — observer |
| `data.checkListItem.attachments` | array \| object | Attachments the item still has. An empty array — no attachments are left. Otherwise an object where the key is the attachment ID and the value is the Drive file ID prefixed with the letter `n` |
| `data.checkListItem.nodeId` | null | Node key from [saving the checklist](/docs/entities/tasks/checklist-actions/tree). `null` in this method's response |
| `data.checkListItem.taskId` | number | Task ID |

## Response example

Attachment `592` is removed, and the item still has attachment `594`:

```json
{
  "success": true,
  "data": {
    "checkListItem": {
      "id": 276,
      "copiedId": null,
      "userId": 1295,
      "createdBy": 1295,
      "parentId": 268,
      "title": "Check the build",
      "sortIndex": 1,
      "displaySortIndex": "",
      "isComplete": true,
      "isImportant": true,
      "completedCount": 0,
      "members": [
        {
          "id": "1295",
          "type": "U",
          "name": "John Smith",
          "personalPhoto": "33093",
          "personalGender": "",
          "image": "https://example.bitrix24.com/...",
          "isCollaber": false
        }
      ],
      "attachments": {
        "594": "n10806"
      },
      "nodeId": null,
      "taskId": 4218
    }
  }
}
```

## Error response example

400 — `attachmentsIds` is not an array:

```json
{
  "success": false,
  "error": {
    "code": "INVALID_PARAMS",
    "message": "attachmentsIds must be an array"
  }
}
```

## Errors

| HTTP | Code | Description |
|------|-----|----------|
| 400 | `INVALID_PARAMS` | `taskId` is not a positive integer. Message `taskId must be a positive integer` |
| 400 | `INVALID_PARAMS` | `itemId` is not a positive integer. Message `itemId must be a positive integer` |
| 400 | `INVALID_PARAMS` | The body is missing or is not a JSON object. Message `JSON object body is required` |
| 400 | `INVALID_PARAMS` | `attachmentsIds` is missing or is not an array. Message `attachmentsIds must be an array` |
| 401 | `MISSING_API_KEY` | `X-Api-Key` is missing |
| 401 | `TOKEN_MISSING` | The key has no Bitrix24 tokens |
| 403 | `SCOPE_DENIED` | The key lacks the `task` scope |
| 403 | `WRITE_BLOCKED_READONLY_KEY` | The key is in read-only mode. `error.details.switchUrl` contains the URL of the section where the mode is changed |
| 415 | `FST_ERR_CTP_INVALID_MEDIA_TYPE` | A body with a `Content-Type` the API does not parse, for example `application/xml` |
| 404 | `TASK_NOT_FOUND` | The task is missing or inaccessible and the core returned the legacy named task-not-found signature |
| 404 | `NOT_FOUND` | The `itemId` item is missing, belongs to another task or is inaccessible. This also covers an unnamed task access denial in Russian, English, German or Kazakh; this denial does not distinguish a missing task from denied access |
| 422 | `BITRIX_ERROR` | Another Bitrix24 error, including an unrecognized core denial |
| 429 | `RATE_LIMITED` | Request rate exceeded. The effective cap is in the `x-ratelimit-limit` header |

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

## Known specifics

**An unknown ID does not cause an error.** If the item has no attachment with the passed ID, the method returns `200` and leaves the attachments unchanged. Check `attachments` in the response to confirm the result.

**The Drive file is not always deleted.** The file of an attachment created [by content](/docs/entities/tasks/checklist-actions/attachments-content) disappears from Drive after the attachment is removed: [`GET /v1/files/:id`](/docs/entities/files/get) returns `404` for it. A file attached [from Drive](/docs/entities/tasks/checklist-actions/attachments-disk) stays in place.

## See also

- [Checklist actions and task file](/docs/entities/tasks/checklist-actions)
- [Attach a file to a checklist item by content](/docs/entities/tasks/checklist-actions/attachments-content)
- [Attach Drive files to a checklist item](/docs/entities/tasks/checklist-actions/attachments-disk)
- [Get a checklist item](/docs/entities/tasks/checklist/get)
- [Tasks](/docs/entities/tasks)
