## Attach Drive files to a checklist item

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

Attaches files that are already on Bitrix24 Drive to a task checklist item. The files are not copied: each attachment refers to the Drive file itself.

## 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 |
|------|-----|:-----:|----------|
| `filesIds` | array | yes | Drive file IDs — numbers or strings prefixed with the letter `n`, for example `10808` or `"n10808"`. List: [`GET /v1/files`](/docs/entities/files/list). To upload a new file, use [`POST /v1/files/upload`](/docs/entities/files/upload) |

## Examples

### curl — personal key

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

### curl — OAuth application

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

### JavaScript — personal key

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

const { success, data } = await res.json()
console.log('Item attachments:', data?.checkListItem?.attachments)
```

### JavaScript — OAuth application

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

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 files were added |
| `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 employee 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 | Item attachments, including the newly added ones. An empty array — the item has no attachments. Otherwise an object where the key is the attachment ID and the value is the Drive file ID prefixed with the letter `n`. Pass the attachment ID to [`POST /v1/tasks/:taskId/checklist/:itemId/attachments/remove`](/docs/entities/tasks/checklist-actions/attachments-remove) |
| `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

Drive file `10808` is attached to the item, and the attachment has ID `596`:

```json
{
  "success": true,
  "data": {
    "checkListItem": {
      "id": 274,
      "copiedId": null,
      "userId": 1295,
      "createdBy": 1295,
      "parentId": 268,
      "title": "Agree on the date",
      "sortIndex": 2,
      "displaySortIndex": "",
      "isComplete": true,
      "isImportant": false,
      "completedCount": 0,
      "members": [],
      "attachments": {
        "596": "n10808"
      },
      "nodeId": null,
      "taskId": 4218
    }
  }
}
```

## Error response example

422 — Drive has no file with this ID:

```json
{
  "success": false,
  "error": {
    "code": "BITRIX_ERROR",
    "message": "File could not be found.",
    "b24Code": "ERROR_CORE"
  }
}
```

## 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` | `filesIds` is missing or is not an array. Message `filesIds 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 |
| 422 | `BITRIX_ERROR` | Drive has no file with an ID from `filesIds`. `error.b24Code` is `ERROR_CORE`; the message is in the Bitrix24 account language, for example `File could not be found.` |
| 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

**Attaching a file again does not duplicate the attachment.** A file that is already attached to the item can be passed again, including in the other form — `10808` or `"n10808"`. The method returns `200`, and the item keeps a single attachment with the same ID.

## 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)
- [Remove checklist item attachments](/docs/entities/tasks/checklist-actions/attachments-remove)
- [Get a checklist item](/docs/entities/tasks/checklist/get)
- [Files](/docs/entities/files)
- [Tasks](/docs/entities/tasks)
