Recipes
1. Set a name of the dialog
You can set a name
field for a group
or public
dialog only. curl -X PUT \
-H "Content-Type: application/json" \
-H "QB-Token: 1319b4991186601ccf4df2d0fa89565f68012bba" \
-d '{
"name":"New Year 2020 party"
}' \
https://api.quickblox.com/chat/Dialog/5d75393ba28f9a17e1cb0f9e.json
2. Set the ID of the dialog that should be updated
To get a dialog ID, use a List Dialogs request. curl -X PUT \
-H "Content-Type: application/json" \
-H "QB-Token: 1319b4991186601ccf4df2d0fa89565f68012bba" \
-d '{
"name":"New Year 2020 party"
}' \
https://api.quickblox.com/chat/Dialog/5d75393ba28f9a17e1cb0f9e.json
3. As a result, the API returns a dialog with an updated name.
curl -X PUT \
-H "Content-Type: application/json" \
-H "QB-Token: 1319b4991186601ccf4df2d0fa89565f68012bba" \
-d '{
"name":"New Year 2020 party"
}' \
https://api.quickblox.com/chat/Dialog/5d75393ba28f9a17e1cb0f9e.json
Add participants to the dialog
1. Append participants to the array with participants IDs
Use a push_all
operator to append participants to the array with participants IDs. curl -X PUT \
-H "Content-Type: application/json" \
-H "QB-Token: 1319b4991186601ccf4df2d0fa89565f68012bba" \
-d '{
"push_all":{
"occupants_ids":[
91375295,
96705448
]
}
}' \
https://api.quickblox.com/chat/Dialog/5d75393ba28f9a17e1cb0f9e.json
2. Set the participants that should be added to the dialog
Set the participants IDs to an occupants_ids
array to add participants to the dialog. curl -X PUT \
-H "Content-Type: application/json" \
-H "QB-Token: 1319b4991186601ccf4df2d0fa89565f68012bba" \
-d '{
"push_all":{
"occupants_ids":[
91375295,
96705448
]
}
}' \
https://api.quickblox.com/chat/Dialog/5d75393ba28f9a17e1cb0f9e.json
3. Set the ID of the dialog that should be updated
To get a dialog ID, use a List Dialogs request. curl -X PUT \
-H "Content-Type: application/json" \
-H "QB-Token: 1319b4991186601ccf4df2d0fa89565f68012bba" \
-d '{
"push_all":{
"occupants_ids":[
91375295,
96705448
]
}
}' \
https://api.quickblox.com/chat/Dialog/5d75393ba28f9a17e1cb0f9e.json
4. As a result, the API returns a dialog with new dialog participants.
curl -X PUT \
-H "Content-Type: application/json" \
-H "QB-Token: 1319b4991186601ccf4df2d0fa89565f68012bba" \
-d '{
"push_all":{
"occupants_ids":[
91375295,
96705448
]
}
}' \
https://api.quickblox.com/chat/Dialog/5d75393ba28f9a17e1cb0f9e.json
Update custom data of the dialog
1. Set a custom object that should be updated
Use a data
parameter to refer to a custom object that should be updated. The data stores data as a set of unique keys each having an associated value parameter. See this section to learn how to create a custom object class. curl -X PUT \
-H "Content-Type: application/json" \
-H "QB-Token: 8be2595b87f403f3c39e38fb39942cf481012bba" \
-d '{
"data":{
"class_name":"CoolDialog",
"category":"co-workers",
"floor":"5",
"is_intern":"true",
"average_kpi":"0.8"
}
}' \
https://api.quickblox.com/chat/Dialog/5cc748eca0eb470d452adaaa.json
2. Set a name of the class
Here, we refer to the CoolDialog
custom object class. curl -X PUT \
-H "Content-Type: application/json" \
-H "QB-Token: 8be2595b87f403f3c39e38fb39942cf481012bba" \
-d '{
"data":{
"class_name":"CoolDialog",
"category":"co-workers",
"floor":"5",
"is_intern":"true",
"average_kpi":"0.8"
}
}' \
https://api.quickblox.com/chat/Dialog/5cc748eca0eb470d452adaaa.json
3. Specify custom object fields and their new values
Here, we refer to custom object fields of the Cooldialog
class and set new values to these fields. curl -X PUT \
-H "Content-Type: application/json" \
-H "QB-Token: 8be2595b87f403f3c39e38fb39942cf481012bba" \
-d '{
"data":{
"class_name":"CoolDialog",
"category":"co-workers",
"floor":"5",
"is_intern":"true",
"average_kpi":"0.8"
}
}' \
https://api.quickblox.com/chat/Dialog/5cc748eca0eb470d452adaaa.json
4. Set the ID of the dialog that should be updated
To get a dialog ID, use a List Dialogs request. curl -X PUT \
-H "Content-Type: application/json" \
-H "QB-Token: 8be2595b87f403f3c39e38fb39942cf481012bba" \
-d '{
"data":{
"class_name":"CoolDialog",
"category":"co-workers",
"floor":"5",
"is_intern":"true",
"average_kpi":"0.8"
}
}' \
https://api.quickblox.com/chat/Dialog/5cc748eca0eb470d452adaaa.json
5. As a result, the API returns a dialog with updated custom data.
curl -X PUT \
-H "Content-Type: application/json" \
-H "QB-Token: 8be2595b87f403f3c39e38fb39942cf481012bba" \
-d '{
"data":{
"class_name":"CoolDialog",
"category":"co-workers",
"floor":"5",
"is_intern":"true",
"average_kpi":"0.8"
}
}' \
https://api.quickblox.com/chat/Dialog/5cc748eca0eb470d452adaaa.json
Remove participants from dialog
1. Specify if you want to remove dialog participants
Use a pull_all
operator to remove participants from the array with participants IDs. curl -X PUT \
-H "Content-Type: application/json" \
-H "QB-Token: 1319b4991186601ccf4df2d0fa89565f68012bba" \
-d '{
"pull_all":{
"occupants_ids":[
91375295,
96705448
]
}
}' \
https://api.quickblox.com/chat/Dialog/5d75393ba28f9a17e1cb0f9e.json
2. Set the participants that should be removed from the dialog
Set participants IDs to an occupants_ids
array to remove the participants from the dialog. curl -X PUT \
-H "Content-Type: application/json" \
-H "QB-Token: 1319b4991186601ccf4df2d0fa89565f68012bba" \
-d '{
"pull_all":{
"occupants_ids":[
91375295,
96705448
]
}
}' \
https://api.quickblox.com/chat/Dialog/5d75393ba28f9a17e1cb0f9e.json
3. Set the ID of the dialog that should be updated
To get a dialog ID, use a List Dialogs request. curl -X PUT \
-H "Content-Type: application/json" \
-H "QB-Token: 1319b4991186601ccf4df2d0fa89565f68012bba" \
-d '{
"pull_all":{
"occupants_ids":[
91375295,
96705448
]
}
}' \
https://api.quickblox.com/chat/Dialog/5d75393ba28f9a17e1cb0f9e.json
4. As a result, the API returns a dialog with an updated 'occupants_ids' array list.
curl -X PUT \
-H "Content-Type: application/json" \
-H "QB-Token: 1319b4991186601ccf4df2d0fa89565f68012bba" \
-d '{
"pull_all":{
"occupants_ids":[
91375295,
96705448
]
}
}' \
https://api.quickblox.com/chat/Dialog/5d75393ba28f9a17e1cb0f9e.json
Update dialog name with API key
1. Use 'Authorization' header to pass API key
curl -X PUT \
-H "Content-Type: application/json" \
-H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
-H "On-Behalf-Of: 123" \
-d '{
"name":"New Year 2024 party"
}' \
https://api.quickblox.com/chat/Dialog/5d75393ba28f9a17e1cb0f9e.json
2. Use 'On-Behalf-Of' header to pass user_id
To execute a request on behalf of a specific user curl -X PUT \
-H "Content-Type: application/json" \
-H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
-H "On-Behalf-Of: 123" \
-d '{
"name":"New Year 2024 party"
}' \
https://api.quickblox.com/chat/Dialog/5d75393ba28f9a17e1cb0f9e.json
3. Set a name of the dialog
You can set a name field for a group or public dialog only. curl -X PUT \
-H "Content-Type: application/json" \
-H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
-H "On-Behalf-Of: 123" \
-d '{
"name":"New Year 2024 party"
}' \
https://api.quickblox.com/chat/Dialog/5d75393ba28f9a17e1cb0f9e.json
4. Set the ID of the dialog that should be updated
To get a dialog ID, use a List Dialogs request. curl -X PUT \
-H "Content-Type: application/json" \
-H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
-H "On-Behalf-Of: 123" \
-d '{
"name":"New Year 2024 party"
}' \
https://api.quickblox.com/chat/Dialog/5d75393ba28f9a17e1cb0f9e.json
5. As a result, the API returns a dialog with an updated name.
curl -X PUT \
-H "Content-Type: application/json" \
-H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
-H "On-Behalf-Of: 123" \
-d '{
"name":"New Year 2024 party"
}' \
https://api.quickblox.com/chat/Dialog/5d75393ba28f9a17e1cb0f9e.json
Add participants to the dialog with API key
1. Use 'Authorization' header to pass API key
curl -X PUT \
-H "Content-Type: application/json" \
-H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
-H "On-Behalf-Of: 123" \
-d '{
"push_all":{
"occupants_ids":[
91375295,
96705448
]
}
}' \
https://api.quickblox.com/chat/Dialog/5d75393ba28f9a17e1cb0f9e.json
2. Use 'On-Behalf-Of' header to pass user_id
To execute a request on behalf of a specific user. curl -X PUT \
-H "Content-Type: application/json" \
-H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
-H "On-Behalf-Of: 123" \
-d '{
"push_all":{
"occupants_ids":[
91375295,
96705448
]
}
}' \
https://api.quickblox.com/chat/Dialog/5d75393ba28f9a17e1cb0f9e.json
3. Append participants to the array with participants IDs
Use a push_all
operator to append participants to the array with participants IDs. curl -X PUT \
-H "Content-Type: application/json" \
-H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
-H "On-Behalf-Of: 123" \
-d '{
"push_all":{
"occupants_ids":[
91375295,
96705448
]
}
}' \
https://api.quickblox.com/chat/Dialog/5d75393ba28f9a17e1cb0f9e.json
4. Set the participants that should be added to the dialog
Set the participants IDs to an occupants_ids
array to add participants to the dialog. curl -X PUT \
-H "Content-Type: application/json" \
-H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
-H "On-Behalf-Of: 123" \
-d '{
"push_all":{
"occupants_ids":[
91375295,
96705448
]
}
}' \
https://api.quickblox.com/chat/Dialog/5d75393ba28f9a17e1cb0f9e.json
5. Set the ID of the dialog that should be updated
To get a dialog ID, use a List Dialogs request. curl -X PUT \
-H "Content-Type: application/json" \
-H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
-H "On-Behalf-Of: 123" \
-d '{
"push_all":{
"occupants_ids":[
91375295,
96705448
]
}
}' \
https://api.quickblox.com/chat/Dialog/5d75393ba28f9a17e1cb0f9e.json
6. As a result, the API returns a dialog with new dialog participants.
curl -X PUT \
-H "Content-Type: application/json" \
-H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
-H "On-Behalf-Of: 123" \
-d '{
"push_all":{
"occupants_ids":[
91375295,
96705448
]
}
}' \
https://api.quickblox.com/chat/Dialog/5d75393ba28f9a17e1cb0f9e.json
Remove participants from dialog with API key
1. Use 'Authorization' header to pass API key
curl -X PUT \
-H "Content-Type: application/json" \
-H 'Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI' \
-H 'On-Behalf-Of: 123' \
-d '{
"pull_all":{
"occupants_ids":[
91375295,
96705448
]
}
}' \
https://api.quickblox.com/chat/Dialog/5d75393ba28f9a17e1cb0f9e.json
2. Use 'On-Behalf-Of' header to pass user_id
To execute a request on behalf of a specific user. curl -X PUT \
-H "Content-Type: application/json" \
-H 'Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI' \
-H 'On-Behalf-Of: 123' \
-d '{
"pull_all":{
"occupants_ids":[
91375295,
96705448
]
}
}' \
https://api.quickblox.com/chat/Dialog/5d75393ba28f9a17e1cb0f9e.json
3. Specify if you want to remove dialog participants
Use a pull_all
operator to remove participants from the array with participants IDs. curl -X PUT \
-H "Content-Type: application/json" \
-H 'Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI' \
-H 'On-Behalf-Of: 123' \
-d '{
"pull_all":{
"occupants_ids":[
91375295,
96705448
]
}
}' \
https://api.quickblox.com/chat/Dialog/5d75393ba28f9a17e1cb0f9e.json
4. Set the participants that should be removed from the dialog
Set participants IDs to an occupants_ids
array to remove the participants from the dialog. curl -X PUT \
-H "Content-Type: application/json" \
-H 'Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI' \
-H 'On-Behalf-Of: 123' \
-d '{
"pull_all":{
"occupants_ids":[
91375295,
96705448
]
}
}' \
https://api.quickblox.com/chat/Dialog/5d75393ba28f9a17e1cb0f9e.json
5. Set the ID of the dialog that should be updated
To get a dialog ID, use a List Dialogs request. curl -X PUT \
-H "Content-Type: application/json" \
-H 'Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI' \
-H 'On-Behalf-Of: 123' \
-d '{
"pull_all":{
"occupants_ids":[
91375295,
96705448
]
}
}' \
https://api.quickblox.com/chat/Dialog/5d75393ba28f9a17e1cb0f9e.json
6. As a result, the API returns a dialog with an updated 'occupants_ids' array list.
curl -X PUT \
-H "Content-Type: application/json" \
-H 'Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI' \
-H 'On-Behalf-Of: 123' \
-d '{
"pull_all":{
"occupants_ids":[
91375295,
96705448
]
}
}' \
https://api.quickblox.com/chat/Dialog/5d75393ba28f9a17e1cb0f9e.json
Update custom data of the dialog with API key
1. Use 'Authorization' header to pass API key
curl -X PUT \
-H "Content-Type: application/json" \
-H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
-H "On-Behalf-Of: 123" \
-d '{
"data":{
"class_name":"CoolDialog",
"category":"co-workers",
"floor":"5",
"is_intern":"true",
"average_kpi":"0.8"
}
}' \
https://api.quickblox.com/chat/Dialog/5cc748eca0eb470d452adaaa.json
2. Use 'On-Behalf-Of' header to pass user_id
To execute a request on behalf of a specific user. curl -X PUT \
-H "Content-Type: application/json" \
-H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
-H "On-Behalf-Of: 123" \
-d '{
"data":{
"class_name":"CoolDialog",
"category":"co-workers",
"floor":"5",
"is_intern":"true",
"average_kpi":"0.8"
}
}' \
https://api.quickblox.com/chat/Dialog/5cc748eca0eb470d452adaaa.json
3. Set a custom object that should be updated
Use a data parameter to refer to a custom object that should be updated. The data stores data as a set of unique keys each having an associated value parameter. See this section to learn how to create a custom object class. curl -X PUT \
-H "Content-Type: application/json" \
-H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
-H "On-Behalf-Of: 123" \
-d '{
"data":{
"class_name":"CoolDialog",
"category":"co-workers",
"floor":"5",
"is_intern":"true",
"average_kpi":"0.8"
}
}' \
https://api.quickblox.com/chat/Dialog/5cc748eca0eb470d452adaaa.json
4. Set a name of the class
Here, we refer to the CoolDialog
custom object class. curl -X PUT \
-H "Content-Type: application/json" \
-H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
-H "On-Behalf-Of: 123" \
-d '{
"data":{
"class_name":"CoolDialog",
"category":"co-workers",
"floor":"5",
"is_intern":"true",
"average_kpi":"0.8"
}
}' \
https://api.quickblox.com/chat/Dialog/5cc748eca0eb470d452adaaa.json
5. Specify custom object fields and their new values
Here, we refer to custom object fields of the Cooldialog
class and set new values to these fields. curl -X PUT \
-H "Content-Type: application/json" \
-H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
-H "On-Behalf-Of: 123" \
-d '{
"data":{
"class_name":"CoolDialog",
"category":"co-workers",
"floor":"5",
"is_intern":"true",
"average_kpi":"0.8"
}
}' \
https://api.quickblox.com/chat/Dialog/5cc748eca0eb470d452adaaa.json
6. Set the ID of the dialog that should be updated
To get a dialog ID, use a List Dialogs request. curl -X PUT \
-H "Content-Type: application/json" \
-H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
-H "On-Behalf-Of: 123" \
-d '{
"data":{
"class_name":"CoolDialog",
"category":"co-workers",
"floor":"5",
"is_intern":"true",
"average_kpi":"0.8"
}
}' \
https://api.quickblox.com/chat/Dialog/5cc748eca0eb470d452adaaa.json
7. As a result, the API returns a dialog with updated custom data.
curl -X PUT \
-H "Content-Type: application/json" \
-H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
-H "On-Behalf-Of: 123" \
-d '{
"data":{
"class_name":"CoolDialog",
"category":"co-workers",
"floor":"5",
"is_intern":"true",
"average_kpi":"0.8"
}
}' \
https://api.quickblox.com/chat/Dialog/5cc748eca0eb470d452adaaa.json
Update dialog owner (added in v2.39.0)
1. Set user_id of the dialog
curl -X PUT \
-H "Content-Type: application/json" \
-H "QB-Token: 1319b4991186601ccf4df2d0fa89565f68012bba" \
-d '{
"user_id": 96753877
}' \
https://api.quickblox.com/chat/Dialog/5d75393ba28f9a17e1cb0f9e.json
2. Set the ID of the dialog that should be updated
curl -X PUT \
-H "Content-Type: application/json" \
-H "QB-Token: 1319b4991186601ccf4df2d0fa89565f68012bba" \
-d '{
"user_id": 96753877
}' \
https://api.quickblox.com/chat/Dialog/5d75393ba28f9a17e1cb0f9e.json
3. As a result, the API returns a dialog with an updated user_id.
curl -X PUT \
-H "Content-Type: application/json" \
-H "QB-Token: 1319b4991186601ccf4df2d0fa89565f68012bba" \
-d '{
"user_id": 96753877
}' \
https://api.quickblox.com/chat/Dialog/5d75393ba28f9a17e1cb0f9e.json
The following rules are applied if dialog’s type=3
(PRIVATE):
Any user from occupants_ids
can update custom parameters.
The following rules are applied if dialog’s type=2
(GROUP):
Any user from occupants_ids
can add other users.
Any user from occupants_ids
can remove only himself .
Any user from occupants_ids
can update custom parameters.
Only dialog’s owner (creator) can remove any users from occupants_ids
.
The following rules are applied if dialog’s type=1
(PUBLIC_GROUP):
Only dialog’s owner (creator) can update it.
Path Parameters
ID of the dialog to which a current message is connected. Generated automatically by the server after message creation
Body Parameters
Name of a dialog. The maximum length is 200 symbols.
Update dialog occupants. Use push_all
operator to add new occupants.
Update dialog occupants. Use pull_all
to remove occupants.
Class name in Custom Objects.
Field name of class in Custom Objects. Can be many: 1..N.
A user or application session token. See
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.
User ID. The user ID of the user on whose behalf the request is being made.
Responses
curl -X PUT \
-H "Content-Type: application/json" \
-H "QB-Token: 1319b4991186601ccf4df2d0fa89565f68012bba" \
-d '{
"name":"New Year 2020 party"
}' \
https://api.quickblox.com/chat/Dialog/5d75393ba28f9a17e1cb0f9e.json
{
"_id" : "5d75393ba28f9a17e1cb0f9e" ,
"created_at" : "2019-09-08T17:24:11Z" ,
"last_message" : "sure, I can wait" ,
"last_message_date_sent" : 1567971414 ,
"last_message_id" : "5d755856a0eb47411e0b72a9" ,
"last_message_user_id" : 96753878 ,
"name" : "New Year 2020 party" ,
"occupants_ids" : [
96753878 ,
96754523 ,
96830631 ,
96831328 ,
96831397
],
"photo" : "68123" ,
"type" : 2 ,
"updated_at" : "2019-09-08T19:36:54Z" ,
"user_id" : 96753878 ,
"xmpp_room_jid" : "76730_5d75393ba28f9a17e1cb0f9e@muc.chat.quickblox.com" ,
"unread_messages_count" : 0
}