REST API
- Overview
- Limits
- Errors
- GETGet Account Settings
- Authentication
- Users
- Chat
- Overview
- Dialog Model
- POSTCreate Dialog
- GETList Dialogs
- GETGet Dialog by ID
- PUTUpdate Dialog
- DELDelete Dialog
- GETGet Notification Settings
- PUTUpdate Notification Settings
- Message Model
- POSTCreate Message
- GETList Messages
- GETGet Message by ID
- PUTUpdate Message
- PATCHMark All Messages as Delivered
- PATCHMark All Messages as Read
- DELDelete Message
- GETGet Unread Messages Count
- Content
- Push Notifications
- Custom Objects
- Address Book
- AI
Create Dialog
Create a public/group/private dialog.
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
1. Set a private dialog type
Use a type
parameter to set a dialog type. Set it to 3
to create a private dialog.
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
2. Set the ID of the opponent
Use an occupants_ids
parameter to set the ID of the opponent who is going to participate in the dialog.
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
3. As a result, the API returns a newly created private dialog.
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
1. Set a public dialog type
Use a type
parameter to set a dialog type. Set it to 1
to create a public dialog.
curl -X POST \
-H "Content-Type: application/json" \
-H "QB-Token: eddf864695d72d33b959eec2ae6c640d817dfada" \
-d '{
"type":1,
"name":"Soccer news",
"photo":"67834"
}' \
https://api.quickblox.com/chat/Dialog.json
2. Set a name of the public dialog
Use a name
parameter to set a name for the group dialog.
curl -X POST \
-H "Content-Type: application/json" \
-H "QB-Token: eddf864695d72d33b959eec2ae6c640d817dfada" \
-d '{
"type":1,
"name":"Soccer news",
"photo":"67834"
}' \
https://api.quickblox.com/chat/Dialog.json
3. Set an avatar for the dialog
You can set an avatar for a public dialog. Just set the ID of the file in the photo
field.
curl -X POST \
-H "Content-Type: application/json" \
-H "QB-Token: eddf864695d72d33b959eec2ae6c640d817dfada" \
-d '{
"type":1,
"name":"Soccer news",
"photo":"67834"
}' \
https://api.quickblox.com/chat/Dialog.json
4. As a result, the API returns a newly created public dialog.
curl -X POST \
-H "Content-Type: application/json" \
-H "QB-Token: eddf864695d72d33b959eec2ae6c640d817dfada" \
-d '{
"type":1,
"name":"Soccer news",
"photo":"67834"
}' \
https://api.quickblox.com/chat/Dialog.json
1. Set a group dialog type
Set a type
parameter to 2
to create a group dialog.
curl -X POST \
-H "Content-Type: application/json" \
-H "QB-Token: 1319b4991186601ccf4df2d0fa89565f68012bba" \
-d '{
"type":2,
"name":"New Year party",
"occupants_ids":"96831397,96831328,96830631,96754523",
"photo":"68123"
}' \
https://api.quickblox.com/chat/Dialog.json
2. Set a name of the group dialog
Use a name
parameter to set a name for the group dialog.
curl -X POST \
-H "Content-Type: application/json" \
-H "QB-Token: 1319b4991186601ccf4df2d0fa89565f68012bba" \
-d '{
"type":2,
"name":"New Year party",
"occupants_ids":"96831397,96831328,96830631,96754523",
"photo":"68123"
}' \
https://api.quickblox.com/chat/Dialog.json
3. Set IDs of opponents
Use an occupants_ids
parameter to set a list of opponents IDs who are going to participate in the dialog.
curl -X POST \
-H "Content-Type: application/json" \
-H "QB-Token: 1319b4991186601ccf4df2d0fa89565f68012bba" \
-d '{
"type":2,
"name":"New Year party",
"occupants_ids":"96831397,96831328,96830631,96754523",
"photo":"68123"
}' \
https://api.quickblox.com/chat/Dialog.json
4. As a result, the API returns a newly created group dialog.
curl -X POST \
-H "Content-Type: application/json" \
-H "QB-Token: 1319b4991186601ccf4df2d0fa89565f68012bba" \
-d '{
"type":2,
"name":"New Year party",
"occupants_ids":"96831397,96831328,96830631,96754523",
"photo":"68123"
}' \
https://api.quickblox.com/chat/Dialog.json
1. Set a type of the dialog
You can set a type of dialog using a type
parameter. Here, a group
dialog is created since the type
is set to 2
.
curl -X POST \
-H "Content-Type: application/json" \
-H "QB-Token: 2e80acd7f3d9c1e79312e0d1dafd6691ba012bba" \
-d '{
"type":2,
"name":"Chat with Bob, Sam, Garry",
"occupants_ids":"96754523,96830631,96831328",
"data":{
"class_name":"ScoreTable",
"game_mode_name":"rainbow dash",
"expert_mode":"3",
"progress":"56",
}
}' \
https://api.quickblox.com/chat/Dialog.json
2. Set a name of the dialog
Use a name parameter to set a name for the group dialog.
curl -X POST \
-H "Content-Type: application/json" \
-H "QB-Token: 2e80acd7f3d9c1e79312e0d1dafd6691ba012bba" \
-d '{
"type":2,
"name":"Chat with Bob, Sam, Garry",
"occupants_ids":"96754523,96830631,96831328",
"data":{
"class_name":"ScoreTable",
"game_mode_name":"rainbow dash",
"expert_mode":"3",
"progress":"56",
}
}' \
https://api.quickblox.com/chat/Dialog.json
3. Set IDs of opponents
Use an occupants_ids
parameter to set a list of opponents IDs who are going to participate in the dialog.
curl -X POST \
-H "Content-Type: application/json" \
-H "QB-Token: 2e80acd7f3d9c1e79312e0d1dafd6691ba012bba" \
-d '{
"type":2,
"name":"Chat with Bob, Sam, Garry",
"occupants_ids":"96754523,96830631,96831328",
"data":{
"class_name":"ScoreTable",
"game_mode_name":"rainbow dash",
"expert_mode":"3",
"progress":"56",
}
}' \
https://api.quickblox.com/chat/Dialog.json
4. Use a `data` parameter to refer to a custom object that should be added
You need to refer to the specific custom object in the request. See this section to learn how to create a custom object class.
The data
stores a set of unique keys each having an associated value parameter.
curl -X POST \
-H "Content-Type: application/json" \
-H "QB-Token: 2e80acd7f3d9c1e79312e0d1dafd6691ba012bba" \
-d '{
"type":2,
"name":"Chat with Bob, Sam, Garry",
"occupants_ids":"96754523,96830631,96831328",
"data":{
"class_name":"ScoreTable",
"game_mode_name":"rainbow dash",
"expert_mode":"3",
"progress":"56",
}
}' \
https://api.quickblox.com/chat/Dialog.json
5. Set a name of the class
Here, we refer to the ScoreTable
custom object class.
curl -X POST \
-H "Content-Type: application/json" \
-H "QB-Token: 2e80acd7f3d9c1e79312e0d1dafd6691ba012bba" \
-d '{
"type":2,
"name":"Chat with Bob, Sam, Garry",
"occupants_ids":"96754523,96830631,96831328",
"data":{
"class_name":"ScoreTable",
"game_mode_name":"rainbow dash",
"expert_mode":"3",
"progress":"56",
}
}' \
https://api.quickblox.com/chat/Dialog.json
6. Set custom object fields
Here, we refer to custom object fields of the ScoreTable
class.
curl -X POST \
-H "Content-Type: application/json" \
-H "QB-Token: 2e80acd7f3d9c1e79312e0d1dafd6691ba012bba" \
-d '{
"type":2,
"name":"Chat with Bob, Sam, Garry",
"occupants_ids":"96754523,96830631,96831328",
"data":{
"class_name":"ScoreTable",
"game_mode_name":"rainbow dash",
"expert_mode":"3",
"progress":"56",
}
}' \
https://api.quickblox.com/chat/Dialog.json
7. As a result, the API returns a newly created dialog with the specified custom parameters.
curl -X POST \
-H "Content-Type: application/json" \
-H "QB-Token: 2e80acd7f3d9c1e79312e0d1dafd6691ba012bba" \
-d '{
"type":2,
"name":"Chat with Bob, Sam, Garry",
"occupants_ids":"96754523,96830631,96831328",
"data":{
"class_name":"ScoreTable",
"game_mode_name":"rainbow dash",
"expert_mode":"3",
"progress":"56",
}
}' \
https://api.quickblox.com/chat/Dialog.json
1. Use 'Authorization' header to pass API key
curl -X POST \
-H "Content-Type: application/json" \
-H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
-H "On-Behalf-Of: 123" \
-d '{
"type":2,
"name":"New Year party",
"occupants_ids":"96831397,96831328,96830631,96754523",
"photo":"68123"
}' \
https://api.quickblox.com/chat/Dialog.json
2. Use 'On-Behalf-Of' header to pass user id
To execute a request on behalf of a specific user.
curl -X POST \
-H "Content-Type: application/json" \
-H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
-H "On-Behalf-Of: 123" \
-d '{
"type":2,
"name":"New Year party",
"occupants_ids":"96831397,96831328,96830631,96754523",
"photo":"68123"
}' \
https://api.quickblox.com/chat/Dialog.json
3. Set a group dialog type
Set a type
parameter to 2
to create a group dialog.
curl -X POST \
-H "Content-Type: application/json" \
-H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
-H "On-Behalf-Of: 123" \
-d '{
"type":2,
"name":"New Year party",
"occupants_ids":"96831397,96831328,96830631,96754523",
"photo":"68123"
}' \
https://api.quickblox.com/chat/Dialog.json
4. Set a name of the group dialog
Use a name parameter to set a name for the group dialog.
curl -X POST \
-H "Content-Type: application/json" \
-H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
-H "On-Behalf-Of: 123" \
-d '{
"type":2,
"name":"New Year party",
"occupants_ids":"96831397,96831328,96830631,96754523",
"photo":"68123"
}' \
https://api.quickblox.com/chat/Dialog.json
5. Set IDs of opponents
Use an occupants_ids
parameter to set a list of opponents IDs who are going to participate in the dialog.
curl -X POST \
-H "Content-Type: application/json" \
-H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
-H "On-Behalf-Of: 123" \
-d '{
"type":2,
"name":"New Year party",
"occupants_ids":"96831397,96831328,96830631,96754523",
"photo":"68123"
}' \
https://api.quickblox.com/chat/Dialog.json
6. As a result, the API returns a newly created group dialog.
curl -X POST \
-H "Content-Type: application/json" \
-H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
-H "On-Behalf-Of: 123" \
-d '{
"type":2,
"name":"New Year party",
"occupants_ids":"96831397,96831328,96830631,96754523",
"photo":"68123"
}' \
https://api.quickblox.com/chat/Dialog.json
1. Use 'Authorization' header to pass API key
curl -X POST \
-H "Content-Type: application/json" \
-H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
-H "On-Behalf-Of: 123" \
-d '{
"type":3,
"occupants_ids":"102433721"
}' \
https://api.quickblox.com/chat/Dialog.json
2. Use 'On-Behalf-Of' header to pass user_id
To execute a request on behalf of a specific user.
curl -X POST \
-H "Content-Type: application/json" \
-H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
-H "On-Behalf-Of: 123" \
-d '{
"type":3,
"occupants_ids":"102433721"
}' \
https://api.quickblox.com/chat/Dialog.json
3. Set a private dialog type
Use a type
parameter to set a dialog type. Set it to 3
to create a private dialog.
curl -X POST \
-H "Content-Type: application/json" \
-H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
-H "On-Behalf-Of: 123" \
-d '{
"type":3,
"occupants_ids":"102433721"
}' \
https://api.quickblox.com/chat/Dialog.json
4. Set the ID of the opponent
Use an occupants_ids
parameter to set the ID of the opponent who is going to participate in the dialog.
curl -X POST \
-H "Content-Type: application/json" \
-H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
-H "On-Behalf-Of: 123" \
-d '{
"type":3,
"occupants_ids":"102433721"
}' \
https://api.quickblox.com/chat/Dialog.json
5. As a result, the API returns a newly created private dialog.
curl -X POST \
-H "Content-Type: application/json" \
-H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
-H "On-Behalf-Of: 123" \
-d '{
"type":3,
"occupants_ids":"102433721"
}' \
https://api.quickblox.com/chat/Dialog.json
1. Use 'Authorization' header to pass API key
curl -X POST \
-H "Content-Type: application/json" \
-H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
-H "On-Behalf-Of: 123" \
-d '{
"type":1,
"name":"Soccer news",
"photo":"67834"
}' \
https://api.quickblox.com/chat/Dialog.json
2. Use 'On-Behalf-Of' header to pass user_id
To execute a request on behalf of a specific user.
curl -X POST \
-H "Content-Type: application/json" \
-H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
-H "On-Behalf-Of: 123" \
-d '{
"type":1,
"name":"Soccer news",
"photo":"67834"
}' \
https://api.quickblox.com/chat/Dialog.json
3. Set a public dialog type
Use a type
parameter to set a dialog type. Set it to 1
to create a public dialog.
curl -X POST \
-H "Content-Type: application/json" \
-H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
-H "On-Behalf-Of: 123" \
-d '{
"type":1,
"name":"Soccer news",
"photo":"67834"
}' \
https://api.quickblox.com/chat/Dialog.json
4. Set a name of the public dialog
Use a name parameter to set a name for the group dialog.
curl -X POST \
-H "Content-Type: application/json" \
-H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
-H "On-Behalf-Of: 123" \
-d '{
"type":1,
"name":"Soccer news",
"photo":"67834"
}' \
https://api.quickblox.com/chat/Dialog.json
5. Set an avatar for the dialog
You can set an avatar for a public dialog. Just set the ID of the file in the photo field.
curl -X POST \
-H "Content-Type: application/json" \
-H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
-H "On-Behalf-Of: 123" \
-d '{
"type":1,
"name":"Soccer news",
"photo":"67834"
}' \
https://api.quickblox.com/chat/Dialog.json
6. As a result, the API returns a newly created public dialog.
curl -X POST \
-H "Content-Type: application/json" \
-H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
-H "On-Behalf-Of: 123" \
-d '{
"type":1,
"name":"Soccer news",
"photo":"67834"
}' \
https://api.quickblox.com/chat/Dialog.json
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
1
: PUBLIC_GROUP - 2
: GROUP - 3
: PRIVATE type=3
(PRIVATE). The maximum length is 200 symbols. Headers
ApiKey {your_api_key}
. Must be used either QB-Token or Authorization.Responses
An error response
An error response
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
}
Was this page helpful?
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
}