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

Assign an owner

POST /v1/bots/:botId/chats/:dialogId/owner

Transfers chat ownership to another user. The bot must be the current chat owner.

Parameters

Parameter Type Required Description
ParameterbotId (path) Typenumber Requiredyes DescriptionBot ID. List: GET /v1/bots
ParameterdialogId (path) Typestring Requiredyes DescriptionGroup chat ID in the form chatXXX. Returned in the data.chat.dialogId field of POST /v1/bots/:botId/chats and in the chat.dialogId field of bot events

Request fields (body)

Parameter Type Required Description
ParameteruserId Typenumber Requiredyes DescriptionID of the new owner

Examples

curl — personal key

Terminal
curl -X POST https://vibecode.bitrix24.com/v1/bots/42/chats/chat456/owner \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "userId": 5 }'

curl — OAuth application

Terminal
curl -X POST https://vibecode.bitrix24.com/v1/bots/42/chats/chat456/owner \
  -H "X-Api-Key: YOUR_APP_KEY" \
  -H "Authorization: Bearer USER_SESSION_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ "userId": 5 }'

JavaScript — personal key

javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/bots/42/chats/chat456/owner', {
  method: 'POST',
  headers: {
    'X-Api-Key': 'YOUR_API_KEY',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ userId: 5 }),
})

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

JavaScript — OAuth application

javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/bots/42/chats/chat456/owner', {
  method: 'POST',
  headers: {
    'X-Api-Key': 'YOUR_APP_KEY',
    'Authorization': 'Bearer USER_SESSION_TOKEN',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ userId: 5 }),
})

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

Response fields

Field Type Description
Fieldsuccess Typeboolean DescriptionAlways true on success
Fielddata Typeobject DescriptionResult of the ownership transfer
Fielddata.result Typeboolean Descriptiontrue if ownership was transferred successfully

Response example

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

Error response example

403 — the bot is not the chat owner:

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

Errors

HTTP Code Description
HTTP400 CodeINVALID_BOT_ID DescriptionbotId is not a number
HTTP404 CodeBOT_NOT_FOUND DescriptionNo bot found with this ID
HTTP403 CodeBOT_ACCESS_DENIED DescriptionThe bot belongs to another API key
HTTP403 CodeBITRIX_ACCESS_DENIED DescriptionThe bot is not a participant of the chat or is not its owner
HTTP422 CodeBITRIX_ERROR DescriptionAnother Bitrix24 error, text in message
HTTP403 CodeSCOPE_DENIED DescriptionThe API key does not have the imbot scope
HTTP403 CodeWRITE_BLOCKED_READONLY_KEY DescriptionThe key is read-only — see access rights
HTTP410 CodeBOT_DISABLED DescriptionThe bot is disabled and does not process API calls. How to restore it — Bot disabled
HTTP401 CodeTOKEN_MISSING DescriptionThe API key has no configured tokens

Full list of common API errors — Errors.

See also