For AI agents: markdown of this page — /docs-content-en/chats/messages/blocks-delete.md documentation index — /llms.txt
Remove a block from a message
DELETE /v1/chats/messages/:messageId/blocks/:blockId
Removes a block from a constructor message.
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
messageId (path) |
number | yes | — | ID of the constructor message, a positive integer — data.id of the v2 send response or the id of a message with a non-null block in Messages around a message |
blockId (path) |
string | yes | — | Block ID — the value of block.elements[].id of the message. To get the message blocks, see Messages around a message |
No body is needed. Query parameters and body fields are rejected with 400 INVALID_PARAMS.
Examples
curl — personal key
curl -X DELETE "https://vibecode.bitrix24.com/v1/chats/messages/1001/blocks/650a1b2c3d4e5" \
-H "X-Api-Key: YOUR_API_KEY"
curl — OAuth application
curl -X DELETE "https://vibecode.bitrix24.com/v1/chats/messages/1001/blocks/650a1b2c3d4e5" \
-H "X-Api-Key: YOUR_APP_KEY" \
-H "Authorization: Bearer USER_SESSION_TOKEN"
JavaScript — personal key
const res = await fetch('https://vibecode.bitrix24.com/v1/chats/messages/1001/blocks/650a1b2c3d4e5', {
method: 'DELETE',
headers: { 'X-Api-Key': 'YOUR_API_KEY' },
})
const { data } = await res.json()
console.log('Block removed:', data.result)
JavaScript — OAuth application
const res = await fetch('https://vibecode.bitrix24.com/v1/chats/messages/1001/blocks/650a1b2c3d4e5', {
method: 'DELETE',
headers: {
'X-Api-Key': 'YOUR_APP_KEY',
'Authorization': 'Bearer USER_SESSION_TOKEN',
},
})
const { data } = await res.json()
console.log('Block removed:', data.result)
Response fields
| Field | Type | Description |
|---|---|---|
success |
boolean | Always true on success |
data.result |
boolean | true — the block was removed |
Response example
{
"success": true,
"data": { "result": true }
}
Error response example
422 — the message has one block left:
{
"success": false,
"error": {
"code": "BITRIX_ERROR",
"message": "EMPTY_ELEMENTS",
"b24Code": "EMPTY_ELEMENTS"
}
}
Errors
| HTTP | Code | Description |
|---|---|---|
| 400 | INVALID_PARAMS |
messageId is not a positive integer, the body is not a JSON object, or a query parameter or body field is passed. Checked before any call to Bitrix24 |
| 404 | ENTITY_NOT_FOUND |
Bitrix24 returned a generic "not found" code or an error with the text "not found". The portal code is in error.b24Code |
| 422 | BITRIX_ERROR |
Bitrix24 returned an error, the portal code is in error.b24Code. MESSAGE_NOT_FOUND — there is no message with this ID, BLOCK_NOT_FOUND — the message has no blocks, ELEMENT_NOT_FOUND — there is no block with this ID, EMPTY_ELEMENTS — the block is the last one in the message, MESSAGE_ACCESS_DENIED — you have no permission to edit the message, for example it belongs to someone else |
| 403 | SCOPE_DENIED |
The API key does not have the im scope |
| 403 | WRITE_BLOCKED_READONLY_KEY |
The key is read-only — see access rights |
| 401 | TOKEN_MISSING |
The API key has no Bitrix24 tokens configured |
The full list of common API errors — Errors.
Known specifics
Only constructor messages have blocks. A message becomes a constructor message when it is sent with the block field in v2 send mode or when blocks are set on it by editing the message in v2 mode. A plain message has no blocks.