For AI agents: markdown of this page — /docs-content-en/openlines/operator/finish-another.md documentation index — /llms.txt

Finish another operator's dialog

POST /v1/openlines/operator/finish-another

Finishes an Open Channel dialog handled by another operator: the current session of the chat is closed.

The action runs on behalf of the employee the key belongs to — see On whose behalf the action runs.

Request fields (body)

Field Type Required Description
FieldchatId Typenumber | string Requiredyes DescriptionOpen Channel chat identifier, a positive integer. A string is accepted if it consists of digits only and does not start with zero. See Chat ID

Examples

curl — personal key

Terminal
curl -X POST https://vibecode.bitrix24.com/v1/openlines/operator/finish-another \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"chatId": 5255}'

curl — OAuth application

Terminal
curl -X POST https://vibecode.bitrix24.com/v1/openlines/operator/finish-another \
  -H "X-Api-Key: YOUR_APP_KEY" \
  -H "Authorization: Bearer USER_SESSION_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"chatId": 5255}'

JavaScript — personal key

javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/openlines/operator/finish-another', {
  method: 'POST',
  headers: {
    'X-Api-Key': 'YOUR_API_KEY',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ chatId: 5255 }),
})

const body = await res.json()
if (!body.success) throw new Error(`${body.error.code}: ${body.error.message}`)
console.log('Dialog finished:', body.data.chatId)

JavaScript — OAuth application

javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/openlines/operator/finish-another', {
  method: 'POST',
  headers: {
    'X-Api-Key': 'YOUR_APP_KEY',
    'Authorization': 'Bearer USER_SESSION_TOKEN',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ chatId: 5255 }),
})

const body = await res.json()
if (!body.success) throw new Error(`${body.error.code}: ${body.error.message}`)
console.log('Dialog finished:', body.data.chatId)

Response fields

Field Type Description
Fieldsuccess Typeboolean Descriptiontrue
Fielddata.chatId Typenumber DescriptionChat identifier from the request. A string from the request is returned as a number
Fielddata.finished Typeboolean DescriptionAlways true

Response example

JSON
{
  "success": true,
  "data": {
    "chatId": 5255,
    "finished": true
  }
}

Error response example

404 — no chat with this identifier:

JSON
{
  "success": false,
  "error": {
    "code": "ENTITY_NOT_FOUND",
    "message": "Open Line chat not found"
  }
}

Errors

HTTP Code Description
HTTP400 CodeINVALID_CHAT_ID DescriptionchatId is missing, is not a positive integer, is a string with non-digit characters or a leading zero, or is greater than 9007199254740991
HTTP404 CodeENTITY_NOT_FOUND DescriptionNo chat with this chatId
HTTP422 CodeBITRIX_ERROR DescriptionThe chat has no open session: the dialog is already finished. error.b24Code is NOT_LOAD_SESSION_OR_CHAT, and error.message is Session or chat failed to load
HTTP422 CodeBITRIX_ERROR DescriptionBitrix24 refused the action for another reason. The refusal code, if Bitrix24 returned one, is in error.b24Code
HTTP403 CodeBITRIX_ACCESS_DENIED DescriptionThe employee the call runs as has no permission for the action
HTTP502 CodeOPENLINE_OPERATOR_FAILED DescriptionBitrix24 responded without an error but did not confirm the action
HTTP403 CodeSCOPE_DENIED DescriptionThe key has no imopenlines scope
HTTP403 CodeWRITE_BLOCKED_READONLY_KEY DescriptionThe key is read-only
HTTP401 CodeMISSING_API_KEY DescriptionThe X-Api-Key header is missing
HTTP401 CodeINVALID_API_KEY DescriptionThe key is not recognized
HTTP401 CodeTOKEN_MISSING DescriptionA personal key has no access to the Bitrix24 portal, or an application key was sent without a session token in Authorization
HTTP502 CodeBITRIX_UNAVAILABLE DescriptionBitrix24 is unavailable or the connection to it broke before the response was complete

Full list of common API errors — Errors.

Known specifics

  • The session is closed with closeReason equal to operator. You can see it in POST /v1/openlines/sessions/search. An operator finishes their own dialog with POST /v1/openlines/operator/finish, described in Operator actions on a dialog.
  • A repeated call right after finishing also returns 200. A repeated call within the first seconds after a successful finish returns finished: true, although the session is already closed. A minute later, a repeated call returns 422 BITRIX_ERROR with NOT_LOAD_SESSION_OR_CHAT. To check whether the session is closed, use status in POST /v1/openlines/sessions/search, not the response of a repeated call.

See also