Para agentes de IA: markdown de esta página — /docs-content-en/chats/management.md índice de la documentación — /llms.txt

Los artículos de la documentación están disponibles actualmente en inglés.

Chat management

Create and change group chats, their description, color, avatar, member permissions and message deletion policy; transfer ownership, manage notifications, join and leave chats, attach a parent chat, delete and pin chats, set an unread mark, and mark all chats or a list section as read.

Scope: im | Base URL: https://vibecode.bitrix24.com/v1 | Authorization: X-Api-Key

Create a group chat

POST /v1/chats

Creates a new group chat in the Bitrix24 account. Returns the numeric ID of the created chat.

Parameters

Parameter Type Required Description
format (query) string no v2 turns on the v2 mode — see "The v2 mode" below. Any other value is ignored and the response is unchanged

The v2 mode. format=v2 creates the chat with the v2 messenger method im.v2.Chat.add. The body stays flat, as in the regular mode, but accepts more fields — the owner, managers, permissions, message auto-deletion, the avatar, members by department. Every field is checked before any call to Bitrix24: an unknown field, a wrong type or a value outside the list is rejected with 400 INVALID_PARAMS naming the field. The check exists because Bitrix24 silently replaces a wrong role or auto-deletion delay with the default. In the response data is the object { chatId, chat }; Bitrix24 leaves chat empty, so read the new chat's card with dialog details in the v2 mode. An open chat in the v2 mode is type: "CHAT" with searchable: "Y"; the old spelling type: "OPEN" is rejected with 400 INVALID_PARAMS.

Request fields (body)

Field Type Required Description
title string no Chat name
description string no Chat description
users array no Array of numeric member IDs. List: GET /v1/users. In the v2 mode — positive integers only
type string no Chat type: CHAT (regular) or OPEN (open). Defaults to CHAT. In the v2 mode: CHAT, CHANNEL, COPILOT or COLLAB; OPEN is rejected
entityType string no Type of the related entity (for example, CRM)
entityId string no Identifier of the related entity (for example, DEAL|123)
color string no Chat color: RED, GREEN, MINT, LIGHT_BLUE, DARK_BLUE, PURPLE, AQUA, PINK, LIME, BROWN, AZURE, KHAKI, SAND, MARENGO, GRAY, GRAPHITE
searchable string no The v2 mode only. Y — an open chat: any employee can find it and join
ownerId number no The v2 mode only. The chat owner; the caller by default
managers array no The v2 mode only. IDs of the chat managers — positive integers
memberEntities array no The v2 mode only. Members by entity — [type, id] pairs: ["user", 5], ["department", "12:F"] (a department with its sub-departments), ["project", 3]
parentChatId number no The v2 mode only. Create the chat as a child of this chat — see parent chat
avatar string | number no The v2 mode only. An image as a base64 string, or the ID of a Drive file the caller can read
manageUsersAdd string no The v2 mode only. Who can add members: MEMBER, MANAGER, OWNER
manageUsersDelete string no The v2 mode only. Who can remove members: MEMBER, MANAGER, OWNER
manageUi string no The v2 mode only. Who can change the name, description and avatar: MEMBER, MANAGER, OWNER
manageSettings string no The v2 mode only. Who can change the chat settings: MANAGER, OWNER
manageMessages string no The v2 mode only. Who can post: NONE (nobody but the owner), MEMBER, MANAGER, OWNER
manageMessagesAutoDelete string no The v2 mode only. Who can turn on message auto-deletion: NONE, MEMBER, MANAGER, OWNER
manageGuestInvites string no The v2 mode only. Who can invite guests: NONE, MEMBER, MANAGER, OWNER
messagesAutoDeleteDelay number no The v2 mode only. Delete messages after this many hours: 0 (never), 1, 24, 168, 720
conferencePassword string no The v2 mode only. Password of a video conference chat
copilotMainRole string no The v2 mode only. The CoPilot role code of a COPILOT chat
entityData1, entityData2, entityData3 string no The v2 mode only. Arbitrary entity data, stored as is

Examples

curl — personal key

Terminal
curl -X POST https://vibecode.bitrix24.com/v1/chats \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "title": "Project Alpha",
    "users": [27, 29],
    "type": "CHAT",
    "color": "AZURE"
  }'

curl — OAuth application

Terminal
curl -X POST https://vibecode.bitrix24.com/v1/chats \
  -H "X-Api-Key: YOUR_APP_KEY" \
  -H "Authorization: Bearer USER_SESSION_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "title": "Project Alpha",
    "users": [27, 29],
    "type": "CHAT",
    "color": "AZURE"
  }'

JavaScript — personal key

javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/chats', {
  method: 'POST',
  headers: {
    'X-Api-Key': 'YOUR_API_KEY',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    title: 'Project Alpha',
    users: [27, 29],
    type: 'CHAT',
    color: 'AZURE',
  }),
})

const { success, data } = await res.json()
console.log('Chat ID:', data) // numeric chat ID

JavaScript — OAuth application

javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/chats', {
  method: 'POST',
  headers: {
    'X-Api-Key': 'YOUR_APP_KEY',
    'Authorization': 'Bearer USER_SESSION_TOKEN',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    title: 'Project Alpha',
    users: [27, 29],
    type: 'CHAT',
    color: 'AZURE',
  }),
})

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

curl — the v2 mode

Terminal
curl -X POST "https://vibecode.bitrix24.com/v1/chats?format=v2" \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "title": "Project Alpha",
    "searchable": "Y",
    "memberEntities": [["user", 27], ["department", "12:F"]],
    "manageUi": "MANAGER"
  }'

Response fields

Field Type Description
success boolean Always true on success
data number Numeric ID of the created chat
data.chatId number The v2 mode: numeric ID of the created chat
data.chat object The v2 mode: always an empty object — Bitrix24 does not fill it

Response example

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

Error response example

422 — Bitrix24 returned an error while creating the chat:

JSON
{
  "success": false,
  "error": {
    "code": "BITRIX_ERROR",
    "message": "Access denied."
  }
}

Errors

HTTP Code Description
400 INVALID_PARAMS The v2 mode only: the body is not a JSON object, an unknown field or a query parameter other than format, a wrong type or a value outside the list — the message names the field — or type: "OPEN". Checked before any call to Bitrix24
422 BITRIX_ERROR Bitrix24 returned an error (text in message). In the v2 mode the portal code arrives in error.b24Code
403 SCOPE_DENIED The API key lacks the im scope
401 TOKEN_MISSING The API key has no configured tokens

Full list of common API errors — Errors.

Known specifics

The title field is optional. A chat can be created without a name — in that case the name is generated automatically from the members' names. The field is recommended for groups with more than two members.

The OPEN type. An open chat is visible to all account users who know its ID. A regular chat (CHAT) is available only to invited members.

The data field is the numeric chat ID. Subsequent calls (PATCH /v1/chats/:chatId, POST /v1/chats/:chatId/users, and others) need exactly the numeric ID, not the chat<N> string. In the v2 mode this ID arrives in data.chatId.

An avatar in the request body. The request body is limited to 1 MiB, and base64 inflates an image by a third: the avatar field fits an image of up to about 750 KiB. Upload a larger image to Drive and pass the file ID.

See also