For AI agents: markdown of this page — /docs-content-en/chats/management/folder-chats-set.md documentation index — /llms.txt

Set the folders of a chat

PUT /v1/chats/:dialogId/folders

Puts a chat into exactly the listed personal folders of the current user: the chat is added to the listed folders and removed from the other personal folders.

The call is a write: a read-only key gets 403 WRITE_BLOCKED_READONLY_KEY before any call to Bitrix24.

Do not confuse with GET /v1/chats/:chatId/folder — that is the chat's Drive folder, not a chat-list folder.

Parameters

Parameter Type Required Description
dialogId (path) string yes Dialog ID: chatXXX for a group chat — the dialogId field of recent dialogs, a user ID for a direct dialog — from the user list, or the me alias

Request fields (body)

Field Type Required Description
folderIds number[] yes IDs of the personal folders the chat should end up in — the id of folders with type: "personal" from GET /v1/chats/folders. Each element is a positive integer: a number or a string of digits without leading zeros. [] removes the chat from all personal folders

There are no query parameters. Any query parameter or other body field is rejected with 400 INVALID_PARAMS.

Examples

curl — personal key

Terminal
curl -X PUT "https://vibecode.bitrix24.com/v1/chats/chat42/folders" \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"folderIds": [15, 16]}'

curl — OAuth application

Terminal
curl -X PUT "https://vibecode.bitrix24.com/v1/chats/chat42/folders" \
  -H "X-Api-Key: YOUR_APP_KEY" \
  -H "Authorization: Bearer USER_SESSION_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"folderIds": [15, 16]}'

JavaScript — personal key

javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/chats/chat42/folders', {
  method: 'PUT',
  headers: {
    'X-Api-Key': 'YOUR_API_KEY',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ folderIds: [15, 16] }),
})

const { success } = await res.json()

JavaScript — OAuth application

javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/chats/chat42/folders', {
  method: 'PUT',
  headers: {
    'X-Api-Key': 'YOUR_APP_KEY',
    'Authorization': 'Bearer USER_SESSION_TOKEN',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ folderIds: [15, 16] }),
})

const { success } = await res.json()

Response fields

Field Type Description
success boolean Always true on success
data.result boolean true — the write succeeded. The resulting folder contents — GET /v1/chats/folders/:folderId

Response example

JSON
{
  "success": true,
  "data": {
    "result": true
  }
}

Error response example

400 — folderIds is missing:

JSON
{
  "success": false,
  "error": {
    "code": "INVALID_PARAMS",
    "message": "`folderIds` is missing: pass the full list of the personal folders of the chat (`[]` takes it out of all of them)."
  }
}

Errors

HTTP Code Description
400 INVALID_PARAMS folderIds is missing, is not an array or has an element that is not a positive integer; a query parameter or an unknown body field was sent; the body is not a JSON object. Checked before any call to Bitrix24
404 ENTITY_NOT_FOUND Bitrix24 answered "not found"; the portal code is in error.b24Code
422 BITRIX_ERROR Bitrix24 returned an error; the portal code is in error.b24Code: FOLDER_CHATS_LIMIT_EXCEEDED — the folder would hold more than 50 chats, FOLDER_CHAT_NOT_ELIGIBLE — the user is not a chat member or the chat type is not eligible, CHAT_NOT_FOUND — the chat does not exist on the portal
502 ME_ALIAS_RESOLUTION_FAILED Failed to resolve the user when using the me alias
502 BITRIX_UNAVAILABLE Bitrix24 is unavailable or returned a server error
403 SCOPE_DENIED The API key does not have the im scope
403 WRITE_BLOCKED_READONLY_KEY The key is read-only — the call changes folder contents
401 TOKEN_MISSING The API key has no Bitrix24 tokens configured

Full list of common API errors — Errors.

Known specifics

  • IDs of system, other users' and non-existent folders are skipped without an error — the response is successful, and the contents of those folders do not change.
  • The call can make the key owner a chat member. If the chat allows auto-join — for example, a comment chat, a collab or a task chat — the call adds the key owner as a member, as opening the chat in the Bitrix24 interface does.

See also