For AI agents: markdown of this page — /docs-content-en/entities/tasks/checklist-actions/attachments-content.md documentation index — /llms.txt

Attach a file to a checklist item by content

POST /v1/tasks/:taskId/checklist/:itemId/attachments/content

Uploads a file to the "Uploaded files" folder on the Drive of the user on whose behalf the call is made, and attaches it to a task checklist item.

Parameters

Parameter Type Required Description
ParametertaskId (path) Typenumber Requiredyes DescriptionTask ID. List: GET /v1/tasks
ParameteritemId (path) Typenumber Requiredyes DescriptionChecklist item ID. List of items: GET /v1/tasks/:taskId/checklist

Request fields (body)

Field Type Required Description
FieldattachmentParameters Typeobject Requiredyes DescriptionThe file to attach
FieldattachmentParameters.NAME Typestring Requiredyes DescriptionFile name with an extension, for example notes.txt. The file is saved on Drive under this name
FieldattachmentParameters.CONTENT Typestring Requiredyes DescriptionFile content in base64

Examples

curl — personal key

Terminal
curl -X POST "https://vibecode.bitrix24.com/v1/tasks/4218/checklist/276/attachments/content" \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"attachmentParameters":{"NAME":"notes.txt","CONTENT":"QnVpbGQgY2hlY2sgbm90ZXM="}}'

curl — OAuth application

Terminal
curl -X POST "https://vibecode.bitrix24.com/v1/tasks/4218/checklist/276/attachments/content" \
  -H "X-Api-Key: YOUR_APP_KEY" \
  -H "Authorization: Bearer USER_SESSION_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"attachmentParameters":{"NAME":"notes.txt","CONTENT":"QnVpbGQgY2hlY2sgbm90ZXM="}}'

JavaScript — personal key

javascript
const content = Buffer.from('Build check notes').toString('base64')

const res = await fetch('https://vibecode.bitrix24.com/v1/tasks/4218/checklist/276/attachments/content', {
  method: 'POST',
  headers: {
    'X-Api-Key': 'YOUR_API_KEY',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    attachmentParameters: { NAME: 'notes.txt', CONTENT: content },
  }),
})

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

JavaScript — OAuth application

javascript
const content = Buffer.from('Build check notes').toString('base64')

const res = await fetch('https://vibecode.bitrix24.com/v1/tasks/4218/checklist/276/attachments/content', {
  method: 'POST',
  headers: {
    'X-Api-Key': 'YOUR_APP_KEY',
    'Authorization': 'Bearer USER_SESSION_TOKEN',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    attachmentParameters: { NAME: 'notes.txt', CONTENT: content },
  }),
})

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

Response fields

Field Type Description
Fieldsuccess Typeboolean Descriptiontrue if the request succeeded
Fielddata.checkListItem Typeobject DescriptionThe checklist item as it was before the file was added
Fielddata.checkListItem.id Typenumber DescriptionItem ID
Fielddata.checkListItem.copiedId Typenumber | null DescriptionID of the item this one was copied from. null — the item was not copied
Fielddata.checkListItem.userId Typenumber DescriptionID of the user on whose behalf the call is made
Fielddata.checkListItem.createdBy Typenumber DescriptionID of the item author. List: GET /v1/users
Fielddata.checkListItem.parentId Typenumber DescriptionParent item ID. 0 — a top-level item
Fielddata.checkListItem.title Typestring DescriptionItem text
Fielddata.checkListItem.sortIndex Typenumber DescriptionPosition of the item among items with the same parent: the lower the number, the higher the item
Fielddata.checkListItem.displaySortIndex Typestring DescriptionItem number for display. An empty string in this method's response
Fielddata.checkListItem.isComplete Typeboolean DescriptionWhether the item is completed
Fielddata.checkListItem.isImportant Typeboolean DescriptionWhether the item is marked as important
Fielddata.checkListItem.completedCount Typenumber DescriptionNumber of completed sub-items. 0 in this method's response
Fielddata.checkListItem.members Typearray DescriptionItem 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
Fielddata.checkListItem.attachments Typearray | object DescriptionItem attachments before the call. An empty array — the item had 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
Fielddata.checkListItem.nodeId Typenull DescriptionNode key from saving the checklist. null in this method's response
Fielddata.checkListItem.taskId Typenumber DescriptionTask ID

Response example

The file is attached to an item that had no attachments before the call:

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": [],
      "nodeId": null,
      "taskId": 4218
    }
  }
}

Error response example

422 — attachmentParameters has no CONTENT:

JSON
{
  "success": false,
  "error": {
    "code": "BITRIX_ERROR",
    "message": "Error adding attachment",
    "b24Code": "0"
  }
}

Errors

HTTP Code Description
HTTP400 CodeINVALID_PARAMS DescriptiontaskId is not a positive integer. Message taskId must be a positive integer
HTTP400 CodeINVALID_PARAMS DescriptionitemId is not a positive integer. Message itemId must be a positive integer
HTTP400 CodeINVALID_PARAMS DescriptionThe body is missing or is not a JSON object. Message JSON object body is required
HTTP400 CodeINVALID_PARAMS DescriptionattachmentParameters is missing or is not an object, for example a string. Message attachmentParameters must be an object
HTTP401 CodeMISSING_API_KEY DescriptionX-Api-Key is missing
HTTP401 CodeTOKEN_MISSING DescriptionThe key has no Bitrix24 tokens
HTTP403 CodeSCOPE_DENIED DescriptionThe key lacks the task scope
HTTP403 CodeWRITE_BLOCKED_READONLY_KEY DescriptionThe key is in read-only mode. error.details.switchUrl contains the URL of the section where the mode is changed
HTTP413 CodePAYLOAD_TOO_LARGE DescriptionThe request body, including the base64 file content, exceeds 1 MiB
HTTP415 CodeFST_ERR_CTP_INVALID_MEDIA_TYPE DescriptionA body with a Content-Type the API does not parse, for example application/xml
HTTP404 CodeTASK_NOT_FOUND DescriptionThe task is missing or inaccessible and the core returned the legacy named task-not-found signature
HTTP404 CodeNOT_FOUND DescriptionThe 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
HTTP422 CodeBITRIX_ERROR DescriptionAnother Bitrix24 error, including an unrecognized core denial
HTTP422 CodeBITRIX_ERROR DescriptionattachmentParameters has no CONTENT or NAME. The message is in the Bitrix24 account language, for example Error adding attachment
HTTP429 CodeRATE_LIMITED DescriptionRequest rate exceeded. The effective cap is in the x-ratelimit-limit header

The full list of common API errors — Errors.

Known specifics

Read the item to get the new attachment ID. The attachment created by the call is visible in GET /v1/tasks/:taskId/checklist/:itemId: its ID is a key of the attachments object, and fileId is the Drive file ID.

Removing the attachment deletes the file from Drive. Details — Remove checklist item attachments. To keep the file on Drive, upload it with POST /v1/files/upload and attach it from Drive.

A string that is not base64 is accepted without an error. If CONTENT is not base64-encoded, the method returns 200, and a file with corrupted content appears on Drive. Encode the content before the call, as in the JavaScript examples.

This method cannot attach a file larger than 768 KiB. The request body is limited to 1 MiB, and base64 makes the file a third larger. Upload a larger file with POST /v1/files/upload and attach it from Drive.

See also