Views: 6143
Last Modified: 23.03.2022

The method performs chat search

Revision: 19
Get information on the current API revision (platform version) – im.revision.get.

Parameters

Parameter Example Req. Description Revision
FIND Mint Yes Search phrase 19
OFFSET 0 No Offset of user selection 19
LIMIT 10 No User selection limit 19
  • Search is performed by the following fields: chat participants Title, First name and Last name.
  • The method supports standard Bitrix24 REST API pagewise navigation. Additionally, it can build navigation via the OFFSET and LIMIT parameters.

Method call

JavaScript

BX24.callMethod('im.search.chat.list', {
	FIND: 'Mint'
}, function(result){
	if(result.error())
	{
		console.error(result.error().ex);
	}
	else
	{
		console.log('users', result.data());
		console.log('total', result.total());
	}
});

PHP

$result = restCommand('im.search.chat.list', Array(
	'FIND' => 'Mint'
), $_REQUEST["auth"]);

Example of response

{    
	"result": {
		21191:  {
			"id": 21191,
			"title": "Mint chat No.3",
			"owner": 2,
			"extranet": false,
			"avatar": "",
			"color": "#4ba984",
			"type": "chat",
			"entity_type": "",
			"entity_data_1": "",
			"entity_data_2": "",
			"entity_data_3": "",
			"date_create": "2017-10-14T12:15:32+02:00",
			"message_type": "C"
		}
	},
	"total": 1
}    

Description of keys:

  • id – chat ID
  • title – chat name
  • owner – chat owner user ID
  • color – chat color in 'hex' format
  • avatar – link to avatar (if empty, avatar is not specified)
  • type – chat type (group chat, call chat, open channel chat and etc.)
  • entity_type – chat external code – type
  • entity_id – chat external code – ID
  • entity_data_1 – external data for chat
  • entity_data_2 – external data for chat
  • entity_data_3 – external data for chat
  • date_create – date when chat is created in ATOM format
  • message_type – type of chat messages

Example of response when error occurs

{
    "error": "FIND_SHORT",
    "error_description": "Too short a search phrase."
}

Description of keys:

  • error – error code
  • error_description – brief description of error

Possible error codes

Code Description
FIND_SHORT Search phrase is top short, search is performed with three symbols minimum.

Attention: restCommand function is used here for illustration purposes only. It is taken from the EchoBot example. You can send a REST command with your own function, or use the BX24.callMethod or bitrix24-php-sdk methods.





Courses developed by Bitrix24