Event on Message Deletion ONIMBOTMESSAGEDELETE
If you are developing integrations for Bitrix24 using AI tools (Codex, Claude Code, Cursor), connect to the MCP server so that the assistant can utilize the official REST documentation.
Scope:
imbotWho can subscribe: a user of the application that registered the chat bot
DEPRECATED
The development of this event has been halted. Please use ONIMBOTV2MESSAGEDELETE.
The event ONIMBOTMESSAGEDELETE is triggered when a message is deleted in a dialogue with a chat bot. This event only works within the context of the chat bot application.
For bots with TYPE=B/H and OPENLINE=N, the parameter EVENT_MESSAGE_DELETE is ignored in the method imbot.register. To trigger the event for such bots, bind the handler EVENT_MESSAGE_DELETE using the method imbot.update.
Events will not be sent to the application until the installation is complete. Check the application installation
Event Triggering Rule
The event is triggered if the handler EVENT_MESSAGE_DELETE is bound and the message matches the bot type logic:
TYPE=B/H:- personal chat with the bot: the event triggers regardless of mentions,
- group chat: triggers only when the bot is mentioned,
TYPE=S— the event triggers regardless of mentions,TYPE=O— the event triggers in open line chats where the bot is involved.
Without EVENT_MESSAGE_DELETE, the event will not trigger regardless of mentions.
What the Handler Receives
Data is transmitted in the form of a POST request
{
"event": "ONIMBOTMESSAGEDELETE",
"event_handler_id": "457",
"data": {
"BOT": {
"571": {
"access_token": "9a0aa06900071b0000084400023bf0f107e7cd778b0dbccd0155cea",
"expires": "1772096154",
"expires_in": "3600",
"scope": "imbot",
"domain": "some-domain.bitrix24.com",
"server_endpoint": "https://oauth.bitrix.info/rest/",
"status": "F",
"client_endpoint": "https://some-domain.bitrix24.com/rest/",
"member_id": "bac1cd5c8940947a75e0d71b1a84e348",
"refresh_token": "9a0aa06900071b000844000023bf0f107e7cd778b0dbccd0155cea",
"user_id": "571",
"client_id": "a7eff906dd1d950269258a599214f69e",
"application_token": "831c76b092f9f135d9b6b36c3a720757",
"AUTH": {
"access_token": "9a0aa06900071b0000084400023bf0f107e7cd778b0dbccd0155cea",
"expires": "1772096154",
"expires_in": "3600",
"scope": "imbot",
"domain": "some-domain.bitrix24.com",
"server_endpoint": "https://oauth.bitrix.info/rest/",
"status": "F",
"client_endpoint": "https://some-domain.bitrix24.com/rest/",
"member_id": "bac1cd5c8940947a75e0d71b1a84e348",
"refresh_token": "9a0aa06900071b000844000023bf0f107e7cd778b0dbccd0155cea",
"user_id": "571",
"client_id": "a7eff906dd1d950269258a599214f69e",
"application_token": "831c76b092f9f135d9b6b36c3a720757"
},
"BOT_ID": "571",
"BOT_CODE": "BOT"
}
},
"PARAMS": {
"ID": "84525",
"CHAT_ID": "1453",
"AUTHOR_ID": "27",
"MESSAGE": "Message from 02/26/2026 09:27:30 has been deleted",
"MESSAGE_TYPE": "P",
"CHAT_AUTHOR_ID": "571",
"CHAT_ENTITY_ID": "",
"CHAT_ENTITY_DATA_1": "",
"CHAT_ENTITY_DATA_2": "",
"CHAT_ENTITY_DATA_3": "",
"FROM_USER_ID": "27",
"TO_USER_ID": "571",
"DIALOG_ID": "27",
"MESSAGE_ID": "84525",
"CHAT_TYPE": "P",
"LANGUAGE": "de"
},
"USER": {
"ID": "27",
"NAME": "Svetlana Ivanova",
"FIRST_NAME": "Svetlana",
"LAST_NAME": "Ivanova",
"WORK_POSITION": "",
"GENDER": "F",
"IS_BOT": "N",
"IS_CONNECTOR": "N",
"IS_NETWORK": "N",
"IS_EXTRANET": "N"
}
},
"ts": "1772092554",
"auth": {
"access_token": "9a0aa06900071b00084400001b0000781c0546d93491d81d",
"expires": "1772096154",
"expires_in": "3600",
"scope": "imbot",
"domain": "some-domain.bitrix24.com",
"server_endpoint": "https://oauth.bitrix.info/rest/",
"status": "F",
"client_endpoint": "https://some-domain.bitrix24.com/rest/",
"member_id": "bac1cd5c8940947a75e0d71b1a84e348",
"user_id": "27",
"refresh_token": "8a89c769000071b00084400001b000c1b724e4652017b0ea7051ffb8e",
"application_token": "831c76b092f9f135d9b6b36c3a720757"
}
}
{
"event": "ONIMBOTMESSAGEDELETE",
"event_handler_id": "457",
"data": {
"BOT": {
"571": {
"access_token": "9a0aa0690000071b000008440001b000781c0546d82fee9e8c",
"expires": "1772100933",
"expires_in": "3600",
"scope": "imbot",
"domain": "some-domain.bitrix24.com",
"server_endpoint": "https://oauth.bitrix.info/rest/",
"status": "F",
"client_endpoint": "https://some-domain.bitrix24.com/rest/",
"member_id": "bac1cd5c8940947a75e0d71b1a84e348",
"refresh_token": "9a0aa0690071b0000084400001b000781c0546d82fee9e8c",
"user_id": "571",
"client_id": "a7eff906dd1d950269258a599214f69e",
"application_token": "831c76b092f9f135d9b6b36c3a720757",
"AUTH": {
"access_token": "9a0aa0690000071b000008440001b000781c0546d82fee9e8c",
"expires": "1772100933",
"expires_in": "3600",
"scope": "imbot",
"domain": "some-domain.bitrix24.com",
"server_endpoint": "https://oauth.bitrix.info/rest/",
"status": "F",
"client_endpoint": "https://some-domain.bitrix24.com/rest/",
"member_id": "bac1cd5c8940947a75e0d71b1a84e348",
"refresh_token": "9a0aa0690071b0000084400001b000781c0546d82fee9e8c",
"user_id": "571",
"client_id": "a7eff906dd1d950269258a599214f69e",
"application_token": "831c76b092f9f135d9b6b36c3a720757"
},
"BOT_ID": "571",
"BOT_CODE": "BOT"
}
},
"PARAMS": {
"ID": "84537",
"CHAT_ID": "1157",
"AUTHOR_ID": "27",
"MESSAGE": "Message from 02/26/2026 11:14:02 has been deleted",
"MESSAGE_TYPE": "C",
"CHAT_AUTHOR_ID": "27",
"CHAT_ENTITY_TYPE": "THREAD",
"CHAT_ENTITY_ID": "",
"CHAT_ENTITY_DATA_1": "",
"CHAT_ENTITY_DATA_2": "",
"CHAT_ENTITY_DATA_3": "",
"DIALOG_ID": "chat1157",
"MESSAGE_ID": "84537",
"CHAT_TYPE": "C",
"LANGUAGE": "de"
}
},
"ts": "1772097333",
"auth": {
"access_token": "451da069000071b00084400001b00075b8bc870e6dbc3",
"expires": "1772100933",
"expires_in": "3600",
"scope": "imbot",
"domain": "some-domain.bitrix24.com",
"server_endpoint": "https://oauth.bitrix.info/rest/",
"status": "F",
"client_endpoint": "https://some-domain.bitrix24.com/rest/",
"member_id": "bac1cd5c8940947a75e0d71b1a84e348",
"user_id": "27",
"refresh_token": "359cc76900071b0000084400001b00071a54cd7aad70b5d2fa",
"application_token": "831c76b092f9f135d9b6b36c3a720757"
}
}
|
Parameter |
Description |
|
event |
Symbolic event code. In this case — |
|
event_handler_id |
Identifier of the event handler |
|
data |
Object containing event data. The structure is described below |
|
ts |
Date and time the event was sent from the event queue |
|
auth |
Object containing authorization parameters of the user on behalf of whom the event was triggered. The structure is described below |
Parameter data
|
Parameter |
Description |
|
BOT |
Set of authorization parameters for the bots to which the message is intended. The key of the object is the bot identifier The structure is described below |
|
PARAMS |
Parameters of the deleted message. The structure is described below |
|
USER |
Data of the author of the deleted message. It may be an empty object if The structure is described below |
Parameter BOT
|
Parameter |
Description |
|
{BOT_ID} |
Data object of a specific bot. The key corresponds to the bot identifier, for example The structure is described below |
Element /
|
Parameter |
Description |
|
access_token |
OAuth authorization token for the bot |
|
expires |
Moment the token expires |
|
expires_in |
Token lifetime in seconds |
|
scope |
Scope within which the event occurred |
|
domain |
Bitrix24 address where the event occurred |
|
server_endpoint |
Address of the OAuth server for REST requests |
|
status |
Status indicator of the application on the account |
|
client_endpoint |
General path for calling REST API methods on the account where the event occurred |
|
member_id |
Unique identifier of Bitrix24 |
|
refresh_token |
OAuth token for renewing the bot's authorization |
|
user_id |
Identifier of the bot user |
|
client_id |
Identifier of the application issued upon registration |
|
application_token |
Application token |
|
AUTH |
Authorization parameters of the bot in The structure is described below |
|
BOT_ID |
Identifier of the bot |
|
BOT_CODE |
Symbolic code of the bot |
Parameter PARAMS
|
Parameter |
Description |
|
ID |
Identifier of the message in the chat table |
|
CHAT_ID |
Identifier of the chat. For group chat and open line chat, the parameter is always passed. For personal dialogue, the parameter may be absent |
|
AUTHOR_ID |
Identifier of the author of the deleted message |
|
MESSAGE |
Text of the system notification about the deleted message |
|
MESSAGE_TYPE |
Type of message. Possible values:
|
|
CHAT_AUTHOR_ID |
Identifier of the chat owner |
|
CHAT_ENTITY_TYPE |
Type of the object to which the chat is linked |
|
CHAT_ENTITY_ID |
Identifier of the object to which the chat is linked |
|
CHAT_ENTITY_DATA_1 |
Additional data of the chat object — field 1 |
|
CHAT_ENTITY_DATA_2 |
Additional data of the chat object — field 2 |
|
CHAT_ENTITY_DATA_3 |
Additional data of the chat object — field 3 |
|
DIALOG_ID |
Identifier of the dialogue |
|
MESSAGE_ID |
Identifier of the deleted message. Added in the event handler from the second argument of the event |
|
CHAT_TYPE |
Type of chat. Possible values:
|
|
LANGUAGE |
Default language of Bitrix24 |
Parameter USER
|
Parameter |
Description |
|
ID |
Identifier of the user |
|
NAME |
Full name of the user |
|
FIRST_NAME |
First name of the user |
|
LAST_NAME |
Last name of the user |
|
WORK_POSITION |
User's position |
|
GENDER |
User's gender: |
|
IS_BOT |
Bot user indicator: |
|
IS_CONNECTOR |
Connector user indicator: |
|
IS_NETWORK |
External network user indicator: |
|
IS_EXTRANET |
Extranet user indicator: |
Parameter auth
Required parameters are marked with *
|
Name |
Description |
|
access_token |
Authorization token OAuth 2.0 |
|
expires_in |
Time in seconds until the token expires |
|
scope* |
Scope under which the event occurred |
|
domain* |
Address of Bitrix24 where the event occurred |
|
server_endpoint* |
Address of the Bitrix24 authorization server needed to refresh OAuth 2.0 tokens |
|
status* |
Status of the application that subscribed to this event:
|
|
client_endpoint* |
Common path for REST API method calls for Bitrix24 where the event occurred |
|
member_id* |
Identifier of Bitrix24 where the event occurred |
|
refresh_token |
Token for extending authorization OAuth 2.0 |
|
application_token* |
Token for secure event handling |
Authorization tokens are not always passed to the event handler. If the hit that initiated the event could not be linked to a specific Bitrix24 user, the tokens are not passed. Always check the contents of the auth key in the code.
It is recommended to store tokens obtained earlier during the application installation. Use them when working with the application interface in the form of embeds, widgets, and so on.
Continue Learning
- Event on Message Sent ONIMBOTMESSAGEADD
- Event on Message Update ONIMBOTMESSAGEUPDATE
- Event for Deleting Chat-Bot ONIMBOTDELETE
- Delete Message imbot.message.delete
- Create a Chat-Bot imbot.register