ImbaChat API

API for creating dialogues and conferences

1.1 Create a new group with members

Description Executing this method will create a new group and add users listed in the request body to this group. Request parameters

  1. imba_id - Required parameter, specifies belonging to the widget. The variable type is integer. If imba_id was not passed to the request, the server will return an error with code 422 and a message that the required parameter was not passed (see Possible errors)
  2. login - Required parameter, username of the site user where the widget is installed. The variable type is string. If login was not passed to the request, the server will return an error with code 422 and a message that the required parameter was not passed (see Possible errors)
  3. password - Required parameter, password of the site user where the widget is installed. The variable type is string. If password was not passed to the request, the server will return an error with code 422 and a message that the required parameter was not passed (see Possible errors)
  4. room_title - Optional parameter, defines the name of the room for all users, it is this parameter that the user sees in the list of rooms. The variable type is string. If room_title was not passed to the request, the server will assign this variable the value “new room”.
  5. room_pipe - An optional parameter, this parameter is a string identifier of the group, it is needed in order to be able to define groups without specifying the room_id. The variable type is string. If room_pipe was not passed to the request, the server will assign a random unique value to this variable.
  6. room_is_public - Optional parameter, this parameter determines whether the group is public or not. The variable type is integer. Possible values ​​are 1 - public group, 0 - closed group.
  7. room_type - Optional parameter, this parameter determines the type of the group to be created. The variable type is integer. Possible values: 0 - dialogue, 1 - conference, 3 - technical support room.
  8. users_ids - Optional parameter, this parameter defines the group members. The variable type is an associative array. Example parameter: users_ids = [1, 2, 3]; The array value is the IDs of users who are registered on the external site.

Request example: CURL:

curl --location --request POST 'https://api.imbachat.com/imbachat/v1/widget/imba_rooms' \
--form 'imba_id=209' \
--form 'login=admin' \
--form 'password=admin' \
--form 'users_ids[0]=3' \
--form 'room_type=1' \
--form 'users_ids[1]=4' \
--form 'room_title=Тестовая API группа 9' \
--form 'room_pipe=' \
--form 'room_is_public =1'

PHP:

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://api.imbachat.com/imbachat/v1/widget/imba_rooms",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => array('imba_id' => '209','login' => 'admin','password' => 'admin','users_ids[0]' => '3','room_type' => '1','users_ids[1]' => '4','room_title' => 'Тестовая API группа 9','room_pipe' => '','room_is_public ' => '1'),
  CURLOPT_HTTPHEADER => array(
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

Response example:

{
    "code": 200,
    "message": "Success",
    "data": [
        {
            "success": true,
            "roomId": 613,
            "room_id": 613
        }
    ]
}

1.2 Adding new members to the group created by

Description Executing this method will create a new group and add users listed in the request body to this group. Request parameters

  1. imba_id - Required parameter, specifies belonging to the widget. The variable type is integer. If imba_id was not passed to the request, the server will return an error with code 422 and a message that the required parameter was not passed (see Possible errors)
  2. login - Required parameter, username of the site user where the widget is installed. The variable type is string. If login was not passed to the request, the server will return an error with code 422 and a message that the required parameter was not passed (see Possible errors)
  3. password - Required parameter, password of the site user where the widget is installed. The variable type is string. If password was not passed to the request, the server will return an error with code 422 and a message that the required parameter was not passed (see Possible errors)
  4. room_title - Optional parameter, defines the name of the room for all users, it is this parameter that the user sees in the list of rooms. The variable type is string. If room_title was not passed to the request, the server will assign this variable the value “new room”.
  5. room_pipe - Optional parameter, this parameter is a string identifier of the group, it is needed so that you can define groups without specifying room_id. The variable type is string. If room_pipe was not passed to the request, the server will assign a random unique value to this variable.
  6. room_is_public - Optional parameter, this parameter determines whether the group is public or not. The variable type is integer. Possible values ​​are 1 - public group, 0 - closed group.
  7. room_type - Optional parameter, this parameter determines the type of the group to be created. The variable type is integer. Possible values: 0 - dialogue, 1 - conference, 3 - technical support room.
  8. users_ids - Optional parameter, this parameter defines the group members. The variable type is an associative array. Example parameter: users_ids = [1, 2, 3]; The array value is the IDs of users who are registered on the external site.
  9. room_id - Optional parameter, this parameter is a numeric identifier of the group, it is needed so that you can define groups without specifying room_pipe. The variable type is integer. If room_ id and room_pipe were not passed to the request, the server will create a new room

Request example: CURL:

curl --location --request POST 'https://api.imbachat.com/imbachat/v1/widget/imba_rooms' \
--form 'imba_id=209' \
--form 'login=admin' \
--form 'password=admin' \
--form 'users_ids[0]=1' \
--form 'room_type=1' \
--form 'room_title=Test API group 9' \
--form 'room_pipe=' \
--form 'room_is_public =1' \
--form 'room_id=613'

PHP:

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://api.imbachat.com/imbachat/v1/widget/imba_rooms",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => array('imba_id' => '209','login' => 'admin','password' => 'admin','users_ids[0]' => '1','room_type' => '1','room_title' => 'Test API group 9','room_pipe' => '','room_is_public ' => '1','room_id' => '613'),
  CURLOPT_HTTPHEADER => array(
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

Response example:

{
    "code": 200,
    "message": "Success",
    "data": [
        {
            "success": true,
            "roomId": 613,
            "room_id": 613
        }
    ]
}

Response example:

{
    "code": 200,
    "message": "Success",
    "data": [
        {
            "error": false,
            "success": true,
            "room_id": "613",
        }
    ]
}

API for getting a list of users with filters applied

Description

This method returns a list of users that matched the filters that were passed in the request.

Authorization:

To gain access to the request, you need to pass Basic authentication. Login - widget ID, password - secret key

Filters:

  1. login - username registered in the chat
  2. id - Identification number in the imbachat system
  3. imba_id - Widget ID
  4. status - User status (user / administrator)
  5. last_message_date - date of the last message
  6. banned - ban status

Request example: CURL:

curl --location --request POST 'http://api.imbachat.com/imbachat/v2/627/get_users' \
--user imba_id:secret_key \
--form 'imba_id="627"' \
--form 'status="user"' \

PHP:

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'http://api.imbachat.com/imbachat/v2/627/get_users',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS => array('imba_id' => 627, 'status' => 'user'),
  CURLOPT_USERPWD => "imba_id:secret_key",
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

Response example:

{
    "success": "true",
    "data": [
        {
            "id": 2046,
            "deleted_at": null,
            "created_at": "2020-11-23 05:26:41",
            "updated_at": "2020-11-24 06:59:54",
            "remote_user_id": "1",
            "user_data": null,
            "imba_id": 627,
            "login": "NULL",
            "password": "NULL",
            "status": "admin",
            "avatar_url": "https://secure.gravatar.com/avatar/3875115bacc48cca24ac51ee4b0e7975?s=48&d=identicon"
        }
    ],
    "code": 200
}

API for getting a list of rooms with filters applied

Description

This method returns a list of rooms that match the filters that were passed in the request, and a successful response is also returned if the "JWT" header with a token was passed.

Filters:

  1. room_type - type of rooms (dialogue - 0 / conference - 1)
  2. status - the status of the user in the room
  3. imba_id - Widget ID
  4. count_users - number of users
  5. last_message_date - date of the last message
  6. banned - ban status

Request example: CURL:

curl --location --request POST 'http://api.imbachat.com/imbachat/v2/627/get_rooms' \
--user imba_id:secret_key \
--form 'imba_id="627"' \
--form 'room_type="0"'

PHP:

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'http://api.imbachat.com/imbachat/v2/627/get_rooms',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS => array('imba_id' => 627, 'room_type' => '0'),
  CURLOPT_USERPWD => "imba_id:secret_key",
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

Response example:

{
    "success": "true",
    "data": [
        {
            "id": 1853,
            "pipe": "5fde659f0ba18_1608410527",
            "name": "Technical support",
            "admin_id": 2157,
            "type": 3,
            "tab": 0,
            "is_public": 0,
            "created_at": "2020-12-19 20:42:07",
            "updated_at": "2020-12-19 20:42:07",
            "deleted_at": null,
            "status": 0,
            "imba_id": 627
        }, 
        {
            "id": 1314,
            "pipe": "5fbcaf6a4ba35_1606201194",
            "name": "New conversation",
            "admin_id": 2046,
            "type": 0,
            "tab": 0,
            "is_public": 0,
            "created_at": "2020-11-24 06:59:54",
            "updated_at": "2020-11-24 06:59:54",
            "deleted_at": null,
            "status": 0,
            "imba_id": 627
        }
    ],
    "code": 200
}

API for getting a list of messages with filters applied

Description

This method returns a list of messages that match the filters that were passed in the request, and a successful response is also returned if the "JWT" header with a token was passed.

Filters:

  1. date - date of the message
  2. id - Identification number in the imbachat system
  3. room_type - type of rooms (dialogue - 0 / conference - 1)
  4. user_name - Username of the user who wrote the message
  5. user_role - The role of the user in the room

Other documentation:

ImbaChat general documentation

API for sending messages (for chat bot)

Group chat function