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

Delete message

DELETE /v1/bots/:botId/messages/:messageId

Deletes a message. By default the deletion is a soft hide — the message is hidden but stays in the database. For full removal from the database, pass complete: true.

Parameters

Parameter Type Required Description
ParameterbotId (path) Typenumber Requiredyes DescriptionBot ID. List: GET /v1/bots
ParametermessageId (path) Typenumber Requiredyes DescriptionMessage ID. Returned in the data.id field of POST /v1/bots/:botId/messages and in the message.id field of bot events

Request fields (body)

Parameter Type Required Default Description
Parametercomplete Typeboolean Requiredno Defaultfalse Descriptiontrue — full removal from the DB, false — soft hide

Examples

curl — personal key

Terminal
curl -X DELETE https://vibecode.bitrix24.com/v1/bots/42/messages/1502 \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "complete": true }'

curl — OAuth application

Terminal
curl -X DELETE https://vibecode.bitrix24.com/v1/bots/42/messages/1502 \
  -H "X-Api-Key: YOUR_APP_KEY" \
  -H "Authorization: Bearer USER_SESSION_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ "complete": true }'

JavaScript — personal key

javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/bots/42/messages/1502', {
  method: 'DELETE',
  headers: {
    'X-Api-Key': 'YOUR_API_KEY',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ complete: true }),
})

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

JavaScript — OAuth application

javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/bots/42/messages/1502', {
  method: 'DELETE',
  headers: {
    'X-Api-Key': 'YOUR_APP_KEY',
    'Authorization': 'Bearer USER_SESSION_TOKEN',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ complete: true }),
})

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

Response fields

Field Type Description
Fielddata.result Typeboolean Descriptiontrue on successful deletion

Response example

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

Error response example

403 — the bot belongs to a different key:

JSON
{
  "success": false,
  "error": {
    "code": "BOT_ACCESS_DENIED",
    "message": "This bot belongs to a different API key"
  }
}

Errors

HTTP Code Description
HTTP400 CodeINVALID_BOT_ID DescriptionbotId is not a number
HTTP400 CodeINVALID_PARAMS DescriptionmessageId in the path must be a positive integer from 1 to 9007199254740991, without a sign, leading zeros, fraction, exponent or whitespace. Rejected before calling Bitrix24
HTTP404 CodeBOT_NOT_FOUND DescriptionNo bot found with this ID
HTTP403 CodeBOT_ACCESS_DENIED DescriptionThe bot belongs to a different API key
HTTP422 CodeBITRIX_ERROR DescriptionBitrix24 error (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.

Known specifics

System messages: messages with authorId = 0 (sent with system: true) cannot be deleted by the bot unless it is a chat administrator.

Empty body: for a soft delete the body can be omitted.

See also