Find Message in Chat im.dialog.messages.search
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:
imWho can execute the method: chat participant
The method im.dialog.messages.search performs a search for messages in the chat.
Method Parameters
Required parameters are marked with *
|
Name |
Description |
|
CHAT_ID* |
Identifier of the chat in which the search is performed |
|
SEARCH_MESSAGE |
Search string for the message text. Search for this parameter is performed for strings longer than 2 characters |
|
DATE_FROM |
Start of the search period in ISO 8601 format (RFC3339) |
|
DATE_TO |
End of the search period in ISO 8601 format (RFC3339) |
|
DATE |
Search for messages on a specific date in ISO 8601 format (RFC3339). If the parameter is provided, the search is performed within 24 hours from the specified date |
|
ORDER |
Sorting parameters. Supported field:
Default: |
|
LIMIT |
Number of messages returned. Default value: |
|
LAST_ID |
Identifier of the last message from the previous selection for pagination |
Code Examples
How to Use Examples in Documentation
curl -X POST \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{"CHAT_ID":3,"SEARCH_MESSAGE":"test","ORDER":{"ID":"DESC"},"LIMIT":20}' \
https://**put_your_bitrix24_address**/rest/**put_your_user_id_here**/**put_your_webhook_here**/im.dialog.messages.search
curl -X POST \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{"CHAT_ID":3,"SEARCH_MESSAGE":"test","ORDER":{"ID":"DESC"},"LIMIT":20,"auth":"**put_access_token_here**"}' \
https://**put_your_bitrix24_address**/rest/im.dialog.messages.search
try
{
const response = await $b24.callMethod(
'im.dialog.messages.search',
{
CHAT_ID: 3,
SEARCH_MESSAGE: 'test',
ORDER: { ID: 'DESC' },
LIMIT: 20
}
);
const result = response.getData().result;
console.log('Search result:', result);
}
catch (error)
{
console.error('Error:', error);
}
try {
$response = $b24Service
->core
->call(
'im.dialog.messages.search',
[
'CHAT_ID' => 3,
'SEARCH_MESSAGE' => 'test',
'ORDER' => ['ID' => 'DESC'],
'LIMIT' => 20,
]
);
$result = $response
->getResponseData()
->getResult();
echo 'Success: ' . print_r($result, true);
} catch (Throwable $e) {
error_log($e->getMessage());
echo 'Error: ' . $e->getMessage();
}
BX24.callMethod(
'im.dialog.messages.search',
{
CHAT_ID: 3,
SEARCH_MESSAGE: 'test',
ORDER: { ID: 'DESC' },
LIMIT: 20
},
function(result)
{
if (result.error())
{
console.error(result.error());
}
else
{
console.log(result.data());
}
}
);
require_once('crest.php');
$result = CRest::call(
'im.dialog.messages.search',
[
'CHAT_ID' => 3,
'SEARCH_MESSAGE' => 'test',
'ORDER' => ['ID' => 'DESC'],
'LIMIT' => 20,
]
);
echo '<PRE>';
print_r($result);
echo '</PRE>';
Response Handling
HTTP status: 200
{
"result": {
"users": [
{
"id": 1,
"active": true,
"name": "Alex",
"firstName": "Alex",
"lastName": "",
"workPosition": "",
"color": "#df532d",
"avatar": "https://cdn-com.bitrix24.com/path/avatar.jpg",
"avatarHr": "https://cdn-com.bitrix24.com/path/avatar.jpg",
"gender": "F",
"birthday": "",
"extranet": false,
"network": false,
"bot": false,
"connector": false,
"externalAuthId": "socservices",
"status": "online",
"idle": false,
"lastActivityDate": "2026-02-13T14:27:33+01:00",
"mobileLastDate": false,
"desktopLastDate": false,
"absent": false,
"departments": [1, 107, 47, 3],
"phones": {
"personal_mobile": "19998887766",
"inner_phone": "111"
},
"botData": null,
"type": "user",
"website": "",
"email": "user@example.com"
}
],
"files": [],
"additionalMessages": [],
"copilot": null,
"stickers": [],
"reactions": [],
"tariffRestrictions": {
"isHistoryLimitExceeded": false
},
"usersShort": [],
"messages": [
{
"id": 33653,
"chat_id": 2421,
"author_id": 1,
"date": "2026-02-13T14:28:00+01:00",
"text": "test message",
"isSystem": false,
"uuid": "18533186-232b-4423-8438-64501da182f5",
"forward": null,
"params": [],
"viewedByOthers": false,
"unread": false,
"viewed": true
}
]
},
"time": {
"start": 1770982150,
"finish": 1770982150.503861,
"duration": 0.5038609504699707,
"processing": 0,
"date_start": "2026-02-13T14:29:10+01:00",
"date_finish": "2026-02-13T14:29:10+01:00",
"operating_reset_at": 1770982750,
"operating": 0
}
}
Returned Data
|
Name |
Description |
|
result |
Root element of the response |
|
result.messages |
Array of found messages (detailed description) |
|
result.users |
Users associated with the found messages (detailed description) |
|
result.files |
Files from the found messages |
|
result.additionalMessages |
Additional messages related to the found ones, such as forwarded or quoted (detailed description) |
|
result.copilot |
BitrixGPT data, if present in the response. Can be |
|
result.stickers |
Stickers associated with the found messages |
|
result.reactions |
Reactions to the found messages (detailed description) |
|
result.tariffRestrictions |
Information about tariff restrictions on history. Contains the flag |
|
result.usersShort |
Brief information about users who reacted. Used as a supplementary reference to |
|
time |
Information about the request execution time |
Message
|
Name |
Description |
|
id |
Identifier of the message |
|
chat_id |
Identifier of the chat |
|
author_id |
Identifier of the message author |
|
date |
Date and time of message creation |
|
text |
Text of the message |
|
isSystem |
Indicator of a system message |
|
uuid |
External UUID of the message. Can be |
|
forward |
Information about forwarding. Can be |
|
params |
Message parameters |
|
viewedByOthers |
Indicator that the message has been viewed by other participants |
|
unread |
Indicator of an unread message for the current user |
|
viewed |
Indicator that the message has been viewed by the current user |
User
|
Name |
Description |
|
id |
Identifier of the user |
|
active |
User is active |
|
name |
Full name |
|
firstName |
First name |
|
lastName |
Last name |
|
workPosition |
Position |
|
color |
Profile color in hex format |
|
avatar |
Avatar URL |
|
avatarHr |
High-resolution avatar URL |
|
gender |
Gender |
|
birthday |
Birthday |
|
extranet |
Indicator of an extranet user |
|
network |
Indicator of a Bitrix24 Network user |
|
bot |
Indicator of a bot |
|
connector |
Indicator of a connector user |
|
externalAuthId |
External authorization code |
|
status |
User status |
|
idle |
Indicator of inactivity |
|
lastActivityDate |
Date and time of last activity |
|
mobileLastDate |
Last activity in the mobile app. Can be |
|
desktopLastDate |
Last activity in the desktop app. Can be |
|
absent |
Indicator of absence |
|
departments |
Array of department identifiers |
|
phones |
User's phones |
|
botData |
Additional bot data. For a regular user |
|
type |
User type |
|
website |
User's website |
|
email |
User's e-mail |
Reactions
|
Name |
Description |
|
messageId |
Identifier of the message |
|
reactionCounters |
Count of reactions by each type |
|
reactionUsers |
Users by types of reactions |
|
ownReactions |
Reactions of the current user |
Error Handling
HTTP status: 400, 403
{
"error": "CHAT_ID_EMPTY",
"error_description": "CHAT_ID can't be empty"
}
|
Name |
Description |
|
error |
String error code. It may consist of digits, Latin letters, and underscores |
|
error_description |
Textual description of the error. The description is not intended to be shown to the end user in its raw form |
Possible Error Codes
|
Code |
Description |
Value |
|
|
CHAT_ID can't be empty |
Required parameter |
|
|
You do not have access to this chat |
No access to the specified chat |
Statuses and System Error Codes
HTTP Status: 20x, 40x, 50x
The errors described below may occur when calling any method.
|
Status |
Code |
Description |
|
|
|
An internal server error has occurred. Please contact the server administrator or Bitrix24 technical support |
|
|
|
An internal server error has occurred. Please contact the server administrator or Bitrix24 technical support |
|
|
|
The request intensity limit has been exceeded |
|
|
|
The current method is not permitted for calls using batch |
|
|
|
The maximum length of parameters passed to the batch method has been exceeded |
|
|
|
Invalid access token or webhook code |
|
|
|
The HTTPS protocol is required for method calls |
|
|
|
The REST API is blocked due to overload. This is a manual individual block; please contact Bitrix24 technical support to lift it |
|
|
|
The REST API is only available on commercial plans |
|
|
|
The user associated with the access token or webhook used to call the method lacks the necessary permissions |
|
|
|
The manifest is not available |
|
|
|
The request requires higher privileges than those provided by the webhook token |
|
|
|
The provided access token has expired |
|
|
|
The user does not have access to the application. This means that the application is installed, but the portal administrator has restricted access to this application to specific users only |
|
|
|
The public part of the site is closed. To open the public part of the site on an on-premise installation, disable the "Temporary closure of the public part of the site" option. Path to the setting: Desktop > Settings > Product Settings > Module Settings > Main Module > Temporary closure of the public part of the site |
Continue Learning
- Get the List of Recent Messages im.dialog.messages.get
- Set the "read" flag for messages im.dialog.read
- Set the "unread" flag for messages im.dialog.unread
- Send "User is typing" indicator im.dialog.writing
- Send Message im.message.add
- Update Message im.message.update
- Delete Message im.message.delete