POST
/
chat
/
Dialog.json
curl -X POST \
-H "Content-Type: application/json" \
-H "QB-Token: eddf864695d72d33b959eec2ae6c640d817dfada" \
-d '{  
  "type":3,
  "occupants_ids":"102433721"
}' \
https://api.quickblox.com/chat/Dialog.json
{
  "_id": "5e261c72a28f9a4f779f10bb",
  "created_at": "2020-01-20T21:32:34Z",
  "last_message": "Hello world",
  "last_message_date_sent": 1597748932,
  "last_message_id": "5f3bb6c4a28f9a69552944d1",
  "last_message_user_id": 102433734,
  "name": "Bob",
  "occupants_ids": [
    102433721,
    102433734
  ],
  "photo": null,
  "type": 3,
  "updated_at": "2020-08-18T11:08:52Z",
  "user_id": 102433721,
  "xmpp_room_jid": null,
  "unread_messages_count": null
}

Recipes

Use type=1 (PUBLIC_GROUP) to create a public dialog. All users from your application will be able to join it. The server will create a public chat and return a detailed information about the newly created dialog. Field xmpp_room_jid will contain a Chat room JID to which you should connect to start chatting.

Use type=2 (GROUP) to create a group dialog only for specific users provided in occupants_ids. The server will create a group chat (involving only members of this chat) and return a detailed information about the newly created dialog. Field xmpp_room_jids will contain a Chat room JID to which you should connect to start chatting.

Use type=3 (PRIVATE) to create a private dialog between 2 users. The server will return a detailed information about the newly created dialog. If a user sends a chat message to some user and the private dialog wasn’t created, it will be created automatically with the 1st chat message.

Custom parameters

Dialogs can store additional parameters. These parameters can be used to store additional data. Also, these parameters can be used in dialogs retrieval requests.

To start using additional parameters, create an additional schema of your parameters. This is a custom objects class. Just create an empty class with all fields that you need. These fields will be your dialog’s additional parameters.

Next, to set additional parameters to a dialog, use next additional parameters in a creation request:

data[class_name] - should contain Custom Objects class name created above.
data[...]
data[{field_name_N}] - field N from Custom Object class.

Body Parameters

type
integer
required
Type of a new dialog. Possible values are: - 1: PUBLIC_GROUP - 2: GROUP - 3: PRIVATE
name
string
Name of a new dialog. Ignored when type=3 (PRIVATE). The maximum length is 200 symbols.
photo
string
Photo of a new dialog.
occupants_ids
string
IDs of dialog occupants (users who will be able to chat in this dialog). Don’t need to pass current user ID, it will be added automatically. Can be a String or Array of Integers.
data
object

Headers

QB-Token
string
required
A user or application session token. See our Authentication page to learn more about session tokens. Must be used either QB-Token or Authorization.
Authorization
string
default:"ApiKey {your_api_key}"
API key from Dashboard. Expected format: ApiKey {your_api_key}. Must be used either QB-Token or Authorization.
On-Behalf-Of
string
User ID. The user ID of the user on whose behalf the request is being made.

Responses

curl -X POST \
-H "Content-Type: application/json" \
-H "QB-Token: eddf864695d72d33b959eec2ae6c640d817dfada" \
-d '{  
  "type":3,
  "occupants_ids":"102433721"
}' \
https://api.quickblox.com/chat/Dialog.json
{
  "_id": "5e261c72a28f9a4f779f10bb",
  "created_at": "2020-01-20T21:32:34Z",
  "last_message": "Hello world",
  "last_message_date_sent": 1597748932,
  "last_message_id": "5f3bb6c4a28f9a69552944d1",
  "last_message_user_id": 102433734,
  "name": "Bob",
  "occupants_ids": [
    102433721,
    102433734
  ],
  "photo": null,
  "type": 3,
  "updated_at": "2020-08-18T11:08:52Z",
  "user_id": 102433721,
  "xmpp_room_jid": null,
  "unread_messages_count": null
}