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 Message
Create a chat message.
curl -X POST \
-H "Content-Type: application/json" \
-H "QB-Token: eddf864695d72d33b959eec2ae6c640d817dfada" \
-d '{
"chat_dialog_id":"5d75327ba28f9a0f32cb0f99",
"message":"look at this photos",
"send_to_chat":1,
"markable":1,
"attachments":{
"0":{
"type":"image",
"id":"47863"
},
"1":{
"type":"image",
"id":"47864"
}
}
}' \
https://api.quickblox.com/chat/Message.json
{
"_id": "5d76b657a28f9a0cc7cb0f99",
"attachments": [
{
"type": "image",
"id": "47863"
},
{
"type": "image",
"id": "47864"
}
],
"chat_dialog_id": "5d75327ba28f9a0f32cb0f99",
"created_at": null,
"date_sent": 1568061015,
"delivered_ids": [],
"markable": 1,
"message": "look at this photos",
"read_ids": [],
"recipient_id": 0,
"sender_id": 96830631,
"updated_at": null,
"read": 0
}
Recipes
1. Set the ID of the dialog
Set a chat_dialog_id
to send a message to the specific dialog.
curl -X POST \
-H "Content-Type: application/json" \
-H "QB-Token: 2e80acd7f3d9c1e79312e0d1dafd6691ba012bba" \
-d '{
"chat_dialog_id":"5d75327ba28f9a0f32cb0f99",
"message":"Allison will take it",
"send_to_chat":1,
"is_pinned":false
}' \
https://api.quickblox.com/chat/Message.json
2. Type a message
Enter a message text using the message parameter.
curl -X POST \
-H "Content-Type: application/json" \
-H "QB-Token: 2e80acd7f3d9c1e79312e0d1dafd6691ba012bba" \
-d '{
"chat_dialog_id":"5d75327ba28f9a0f32cb0f99",
"message":"Allison will take it",
"send_to_chat":1,
"is_pinned":false
}' \
https://api.quickblox.com/chat/Message.json
3. Specify if you want to send a message
Set a send_to_chat
parameter to 1
to send a message to the dialog.
curl -X POST \
-H "Content-Type: application/json" \
-H "QB-Token: 2e80acd7f3d9c1e79312e0d1dafd6691ba012bba" \
-d '{
"chat_dialog_id":"5d75327ba28f9a0f32cb0f99",
"message":"Allison will take it",
"send_to_chat":1,
"is_pinned":false
}' \
https://api.quickblox.com/chat/Message.json
4. Add extra data to a message
You can extend a message with additional fields by setting key-value custom parameters.
Here, the is_pinned
is a custom parameter key and the false
is a custom parameter value.
curl -X POST \
-H "Content-Type: application/json" \
-H "QB-Token: 2e80acd7f3d9c1e79312e0d1dafd6691ba012bba" \
-d '{
"chat_dialog_id":"5d75327ba28f9a0f32cb0f99",
"message":"Allison will take it",
"send_to_chat":1,
"is_pinned":false
}' \
https://api.quickblox.com/chat/Message.json
5. As a result, the API returns a message with additional fields.
curl -X POST \
-H "Content-Type: application/json" \
-H "QB-Token: 2e80acd7f3d9c1e79312e0d1dafd6691ba012bba" \
-d '{
"chat_dialog_id":"5d75327ba28f9a0f32cb0f99",
"message":"Allison will take it",
"send_to_chat":1,
"is_pinned":false
}' \
https://api.quickblox.com/chat/Message.json
1. Set ID of the dialog
Use a chat_dialog_id
parameter to create a message for the specific dialog.
curl -X POST \
-H "Content-Type: application/json" \
-H "QB-Token: eddf864695d72d33b959eec2ae6c640d817dfada" \
-d '{
"chat_dialog_id":"5d75327ba28f9a0f32cb0f99",
"message":"look at this photos",
"send_to_chat":1,
"markable":1,
"attachments":{
"0":{
"type":"image",
"id":"47863"
},
"1":{
"type":"image",
"id":"47864"
}
}
}' \
https://api.quickblox.com/chat/Message.json
2. Type a message
Enter a message
text using the message parameter.
curl -X POST \
-H "Content-Type: application/json" \
-H "QB-Token: eddf864695d72d33b959eec2ae6c640d817dfada" \
-d '{
"chat_dialog_id":"5d75327ba28f9a0f32cb0f99",
"message":"look at this photos",
"send_to_chat":1,
"markable":1,
"attachments":{
"0":{
"type":"image",
"id":"47863"
},
"1":{
"type":"image",
"id":"47864"
}
}
}' \
https://api.quickblox.com/chat/Message.json
3. Specify if you want to send a message
Set a send_to_chat
parameter to 1
to send a message to the dialog.
curl -X POST \
-H "Content-Type: application/json" \
-H "QB-Token: eddf864695d72d33b959eec2ae6c640d817dfada" \
-d '{
"chat_dialog_id":"5d75327ba28f9a0f32cb0f99",
"message":"look at this photos",
"send_to_chat":1,
"markable":1,
"attachments":{
"0":{
"type":"image",
"id":"47863"
},
"1":{
"type":"image",
"id":"47864"
}
}
}' \
https://api.quickblox.com/chat/Message.json
4. Specify if you want to mark messages as read/delivered
Set a markable
parameter to 1
to mark all messages as read/delivered.
curl -X POST \
-H "Content-Type: application/json" \
-H "QB-Token: eddf864695d72d33b959eec2ae6c640d817dfada" \
-d '{
"chat_dialog_id":"5d75327ba28f9a0f32cb0f99",
"message":"look at this photos",
"send_to_chat":1,
"markable":1,
"attachments":{
"0":{
"type":"image",
"id":"47863"
},
"1":{
"type":"image",
"id":"47864"
}
}
}' \
https://api.quickblox.com/chat/Message.json
5. Set message attachment
You can add an attachement to the message using the attachment
parameter.
Just specify the ID
of the file on QuickBlox server and its type
.
You can add as many attachments as you need.
curl -X POST \
-H "Content-Type: application/json" \
-H "QB-Token: eddf864695d72d33b959eec2ae6c640d817dfada" \
-d '{
"chat_dialog_id":"5d75327ba28f9a0f32cb0f99",
"message":"look at this photos",
"send_to_chat":1,
"markable":1,
"attachments":{
"0":{
"type":"image",
"id":"47863"
},
"1":{
"type":"image",
"id":"47864"
}
}
}' \
https://api.quickblox.com/chat/Message.json
6. As a result, the API returns a newly created message
curl -X POST \
-H "Content-Type: application/json" \
-H "QB-Token: eddf864695d72d33b959eec2ae6c640d817dfada" \
-d '{
"chat_dialog_id":"5d75327ba28f9a0f32cb0f99",
"message":"look at this photos",
"send_to_chat":1,
"markable":1,
"attachments":{
"0":{
"type":"image",
"id":"47863"
},
"1":{
"type":"image",
"id":"47864"
}
}
}' \
https://api.quickblox.com/chat/Message.json
1. Set the ID of the message recipient
Use a recipient_id
parameter to set the ID of the message recipient.
curl -X POST \
-H "Content-Type: application/json" \
-H "QB-Token: ee4b9e6cad16378aab011c236b186aec09012bba" \
-d '{
"recipient_id":102460596,
"message":"Hello!"
}' \
https://api.quickblox.com/chat/Message.json
2. Type a message
Enter a message text using the message
parameter.
curl -X POST \
-H "Content-Type: application/json" \
-H "QB-Token: ee4b9e6cad16378aab011c236b186aec09012bba" \
-d '{
"recipient_id":102460596,
"message":"Hello!"
}' \
https://api.quickblox.com/chat/Message.json
3. As a result, the API returns a newly created message.
curl -X POST \
-H "Content-Type: application/json" \
-H "QB-Token: ee4b9e6cad16378aab011c236b186aec09012bba" \
-d '{
"recipient_id":102460596,
"message":"Hello!"
}' \
https://api.quickblox.com/chat/Message.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 '{
"recipient_id":102460596,
"message":"Hello!"
}' \
https://api.quickblox.com/chat/Message.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 '{
"recipient_id":102460596,
"message":"Hello!"
}' \
https://api.quickblox.com/chat/Message.json
3. Set the ID of the message recipient
Use a recipient_id
parameter to set the ID of the message recipient.
curl -X POST \
-H "Content-Type: application/json" \
-H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
-H "On-Behalf-Of: 123" \
-d '{
"recipient_id":102460596,
"message":"Hello!"
}' \
https://api.quickblox.com/chat/Message.json
4. Type a message
Enter a message text using the message parameter.
curl -X POST \
-H "Content-Type: application/json" \
-H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
-H "On-Behalf-Of: 123" \
-d '{
"recipient_id":102460596,
"message":"Hello!"
}' \
https://api.quickblox.com/chat/Message.json
5. As a result, the API returns a newly created message.
curl -X POST \
-H "Content-Type: application/json" \
-H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
-H "On-Behalf-Of: 123" \
-d '{
"recipient_id":102460596,
"message":"Hello!"
}' \
https://api.quickblox.com/chat/Message.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 '{
"chat_dialog_id":"5d75327ba28f9a0f32cb0f99",
"message":"Allison will take it",
"send_to_chat":1,
"is_pinned":false
}' \
https://api.quickblox.com/chat/Message.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 '{
"chat_dialog_id":"5d75327ba28f9a0f32cb0f99",
"message":"Allison will take it",
"send_to_chat":1,
"is_pinned":false
}' \
https://api.quickblox.com/chat/Message.json
3. Set the ID of the dialog
Set a chat_dialog_id
to send a message to the specific dialog.
curl -X POST \
-H "Content-Type: application/json" \
-H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
-H "On-Behalf-Of: 123" \
-d '{
"chat_dialog_id":"5d75327ba28f9a0f32cb0f99",
"message":"Allison will take it",
"send_to_chat":1,
"is_pinned":false
}' \
https://api.quickblox.com/chat/Message.json
4. Type a message
Enter a message text using the message parameter.
curl -X POST \
-H "Content-Type: application/json" \
-H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
-H "On-Behalf-Of: 123" \
-d '{
"chat_dialog_id":"5d75327ba28f9a0f32cb0f99",
"message":"Allison will take it",
"send_to_chat":1,
"is_pinned":false
}' \
https://api.quickblox.com/chat/Message.json
5. Specify if you want to send a message
Set a send_to_chat
parameter to 1 to send a message to the dialog.
curl -X POST \
-H "Content-Type: application/json" \
-H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
-H "On-Behalf-Of: 123" \
-d '{
"chat_dialog_id":"5d75327ba28f9a0f32cb0f99",
"message":"Allison will take it",
"send_to_chat":1,
"is_pinned":false
}' \
https://api.quickblox.com/chat/Message.json
6. Add extra data to a message
You can extend a message with additional fields by setting key-value custom parameters.
Here, the is_pinned
is a custom parameter key and the false is a custom parameter value.
curl -X POST \
-H "Content-Type: application/json" \
-H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
-H "On-Behalf-Of: 123" \
-d '{
"chat_dialog_id":"5d75327ba28f9a0f32cb0f99",
"message":"Allison will take it",
"send_to_chat":1,
"is_pinned":false
}' \
https://api.quickblox.com/chat/Message.json
7. As a result, the API returns a message with additional fields.
curl -X POST \
-H "Content-Type: application/json" \
-H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
-H "On-Behalf-Of: 123" \
-d '{
"chat_dialog_id":"5d75327ba28f9a0f32cb0f99",
"message":"Allison will take it",
"send_to_chat":1,
"is_pinned":false
}' \
https://api.quickblox.com/chat/Message.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 '{
"chat_dialog_id":"5d75327ba28f9a0f32cb0f99",
"message":"look at this photos",
"send_to_chat":1,
"markable":1,
"attachments":{
"0":{
"type":"image",
"id":"47863"
},
"1":{
"type":"image",
"id":"47864"
}
}
}' \
https://api.quickblox.com/chat/Message.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 '{
"chat_dialog_id":"5d75327ba28f9a0f32cb0f99",
"message":"look at this photos",
"send_to_chat":1,
"markable":1,
"attachments":{
"0":{
"type":"image",
"id":"47863"
},
"1":{
"type":"image",
"id":"47864"
}
}
}' \
https://api.quickblox.com/chat/Message.json
3. Set ID of the dialog
Use a chat_dialog_id
parameter to create a message for the specific dialog.
curl -X POST \
-H "Content-Type: application/json" \
-H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
-H "On-Behalf-Of: 123" \
-d '{
"chat_dialog_id":"5d75327ba28f9a0f32cb0f99",
"message":"look at this photos",
"send_to_chat":1,
"markable":1,
"attachments":{
"0":{
"type":"image",
"id":"47863"
},
"1":{
"type":"image",
"id":"47864"
}
}
}' \
https://api.quickblox.com/chat/Message.json
4. Type a message
Enter a message text using the message parameter.
curl -X POST \
-H "Content-Type: application/json" \
-H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
-H "On-Behalf-Of: 123" \
-d '{
"chat_dialog_id":"5d75327ba28f9a0f32cb0f99",
"message":"look at this photos",
"send_to_chat":1,
"markable":1,
"attachments":{
"0":{
"type":"image",
"id":"47863"
},
"1":{
"type":"image",
"id":"47864"
}
}
}' \
https://api.quickblox.com/chat/Message.json
5. Specify if you want to send a message
Set a send_to_chat
parameter to 1 to send a message to the dialog.
curl -X POST \
-H "Content-Type: application/json" \
-H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
-H "On-Behalf-Of: 123" \
-d '{
"chat_dialog_id":"5d75327ba28f9a0f32cb0f99",
"message":"look at this photos",
"send_to_chat":1,
"markable":1,
"attachments":{
"0":{
"type":"image",
"id":"47863"
},
"1":{
"type":"image",
"id":"47864"
}
}
}' \
https://api.quickblox.com/chat/Message.json
6. Specify if you want to mark messages as read/delivered
Set a markable
parameter to 1
to mark all messages as read/delivered.
curl -X POST \
-H "Content-Type: application/json" \
-H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
-H "On-Behalf-Of: 123" \
-d '{
"chat_dialog_id":"5d75327ba28f9a0f32cb0f99",
"message":"look at this photos",
"send_to_chat":1,
"markable":1,
"attachments":{
"0":{
"type":"image",
"id":"47863"
},
"1":{
"type":"image",
"id":"47864"
}
}
}' \
https://api.quickblox.com/chat/Message.json
7. Set message attachment
You can add an attachement to the message using the attachment
parameter.
Just specify the ID
of the file on QuickBlox server and its type
.
You can add as many attachments as you need.
curl -X POST \
-H "Content-Type: application/json" \
-H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
-H "On-Behalf-Of: 123" \
-d '{
"chat_dialog_id":"5d75327ba28f9a0f32cb0f99",
"message":"look at this photos",
"send_to_chat":1,
"markable":1,
"attachments":{
"0":{
"type":"image",
"id":"47863"
},
"1":{
"type":"image",
"id":"47864"
}
}
}' \
https://api.quickblox.com/chat/Message.json
8. As a result, the API returns a newly created message.
curl -X POST \
-H "Content-Type: application/json" \
-H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
-H "On-Behalf-Of: 123" \
-d '{
"chat_dialog_id":"5d75327ba28f9a0f32cb0f99",
"message":"look at this photos",
"send_to_chat":1,
"markable":1,
"attachments":{
"0":{
"type":"image",
"id":"47863"
},
"1":{
"type":"image",
"id":"47864"
}
}
}' \
https://api.quickblox.com/chat/Message.json
It’s possible to inject a new chat message into the chat history. In this case, this new message won’t be delivered to the recipient(s) by XMPP real-time transport, it will be just added to the history. If you want to send a message, pass send_to_chat=1
parameter.
Body Parameters
type=3
(PRIVATE). Array index 0..N.
audio
, video
, image
or other. markable=1
to perform. Name of a custom field. Chat message can be extended with additional fields and contain any other user key-value custom parameters. Can be many 1..N.
Headers
ApiKey {your_api_key}
. Must be used either QB-Token or Authorization.Responses
An error response
curl -X POST \
-H "Content-Type: application/json" \
-H "QB-Token: eddf864695d72d33b959eec2ae6c640d817dfada" \
-d '{
"chat_dialog_id":"5d75327ba28f9a0f32cb0f99",
"message":"look at this photos",
"send_to_chat":1,
"markable":1,
"attachments":{
"0":{
"type":"image",
"id":"47863"
},
"1":{
"type":"image",
"id":"47864"
}
}
}' \
https://api.quickblox.com/chat/Message.json
{
"_id": "5d76b657a28f9a0cc7cb0f99",
"attachments": [
{
"type": "image",
"id": "47863"
},
{
"type": "image",
"id": "47864"
}
],
"chat_dialog_id": "5d75327ba28f9a0f32cb0f99",
"created_at": null,
"date_sent": 1568061015,
"delivered_ids": [],
"markable": 1,
"message": "look at this photos",
"read_ids": [],
"recipient_id": 0,
"sender_id": 96830631,
"updated_at": null,
"read": 0
}
Was this page helpful?
curl -X POST \
-H "Content-Type: application/json" \
-H "QB-Token: eddf864695d72d33b959eec2ae6c640d817dfada" \
-d '{
"chat_dialog_id":"5d75327ba28f9a0f32cb0f99",
"message":"look at this photos",
"send_to_chat":1,
"markable":1,
"attachments":{
"0":{
"type":"image",
"id":"47863"
},
"1":{
"type":"image",
"id":"47864"
}
}
}' \
https://api.quickblox.com/chat/Message.json
{
"_id": "5d76b657a28f9a0cc7cb0f99",
"attachments": [
{
"type": "image",
"id": "47863"
},
{
"type": "image",
"id": "47864"
}
],
"chat_dialog_id": "5d75327ba28f9a0f32cb0f99",
"created_at": null,
"date_sent": 1568061015,
"delivered_ids": [],
"markable": 1,
"message": "look at this photos",
"read_ids": [],
"recipient_id": 0,
"sender_id": 96830631,
"updated_at": null,
"read": 0
}