Skip to main content
DELETE
/
chat
/
Message
/
{chat_message_id}
,
{chat_message_id}
.json
curl -X DELETE \
-H "Content-Type: application/json" \
-H "QB-Token: eddf864695d72d33b959eec2ae6c640d817dfada" \
https://api.quickblox.com/chat/Message/5d76b949a0eb4721f80b72ab,5d76b657a28f9a0cc7cb0f99,5d76b6sdfff9a0cc7cb023.json
{
  "SuccessfullyDeleted": {
    "ids": [
      "5d76b657a28f9a0cc7cb0f99",
      "5d76b949a0eb4721f80b72ab"
    ]
  },
  "NotFound": {
    "ids": [
      "5d76b6sdfff9a0cc7cb023"
    ]
  }
}

Recipes

1

1. Specify if you want to delete messages from all chat histories

Set a force parameter to 1 to delete messages from all chat histories.
curl -X DELETE \
-H "Content-Type: application/json" \
-H "QB-Token: eddf864695d72d33b959eec2ae6c640d817dfada" \
-d "force=1" \
https://api.quickblox.com/chat/Message/5d76b949a0eb4721f80b72ab,5d76b657a28f9a0cc7cb0f99,5d76b6sdfff9a0cc7cb023.json
2

2. Set the IDs of the messages

Specify the IDs of the messages via comma to refer to specific messages that should be deleted from all users’ histories.
curl -X DELETE \
-H "Content-Type: application/json" \
-H "QB-Token: eddf864695d72d33b959eec2ae6c640d817dfada" \
-d "force=1" \
https://api.quickblox.com/chat/Message/5d76b949a0eb4721f80b72ab,5d76b657a28f9a0cc7cb0f99,5d76b6sdfff9a0cc7cb023.json
3

3. As a result, the messages will be deleted from all chat histories.

If you’re not the owner of the dialog, the API will return the following message: “WrongPermissions”. This means that a user doesn’t have permissions to delete a message from all users’ histories.
curl -X DELETE \
-H "Content-Type: application/json" \
-H "QB-Token: eddf864695d72d33b959eec2ae6c640d817dfada" \
-d "force=1" \
https://api.quickblox.com/chat/Message/5d76b949a0eb4721f80b72ab,5d76b657a28f9a0cc7cb0f99,5d76b6sdfff9a0cc7cb023.json
1

1. Set the IDs of the messages

Specify the IDs of the messages via comma to refer to specific messages that should be deleted from your own chat history.
curl -X DELETE \
-H "Content-Type: application/json" \
-H "QB-Token: eddf864695d72d33b959eec2ae6c640d817dfada" \
https://api.quickblox.com/chat/Message/5d76b949a0eb4721f80b72ab,5d76b657a28f9a0cc7cb0f99,5d76b6sdfff9a0cc7cb023.json
2

2. As a result, the messages are removed for a user who has sent the request without affecting chat histories of other users.

curl -X DELETE \
-H "Content-Type: application/json" \
-H "QB-Token: eddf864695d72d33b959eec2ae6c640d817dfada" \
https://api.quickblox.com/chat/Message/5d76b949a0eb4721f80b72ab,5d76b657a28f9a0cc7cb0f99,5d76b6sdfff9a0cc7cb023.json
1

1. Use 'Authorization' header to pass API key

curl -X DELETE \
-H "Content-Type: application/json" \
-H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
-H "On-Behalf-Of: 123" \
https://api.quickblox.com/chat/Message/5d76b949a0eb4721f80b72ab,5d76b657a28f9a0cc7cb0f99,5d76b6sdfff9a0cc7cb023.json
2

2. Use 'On-Behalf-Of' header to pass user id

To execute a request on behalf of a specific user.
curl -X DELETE \
-H "Content-Type: application/json" \
-H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
-H "On-Behalf-Of: 123" \
https://api.quickblox.com/chat/Message/5d76b949a0eb4721f80b72ab,5d76b657a28f9a0cc7cb0f99,5d76b6sdfff9a0cc7cb023.json
3

3. Set the IDs of the messages

Specify the IDs of the messages via comma to refer to specific messages that should be deleted from the chat history of the user with ID 123.
curl -X DELETE \
-H "Content-Type: application/json" \
-H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
-H "On-Behalf-Of: 123" \
https://api.quickblox.com/chat/Message/5d76b949a0eb4721f80b72ab,5d76b657a28f9a0cc7cb0f99,5d76b6sdfff9a0cc7cb023.json
4

4. As a result, the messages are removed for a user who has sent the request without affecting chat histories of other users.

curl -X DELETE \
-H "Content-Type: application/json" \
-H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
-H "On-Behalf-Of: 123" \
https://api.quickblox.com/chat/Message/5d76b949a0eb4721f80b72ab,5d76b657a28f9a0cc7cb0f99,5d76b6sdfff9a0cc7cb023.json
1

1. Use 'Authorization' header to pass API key

curl -X DELETE \
-H "Content-Type: application/json" \
-H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
https://api.quickblox.com/chat/Message/5d76b949a0eb4721f80b72ab,5d76b657a28f9a0cc7cb0f99,5d76b6sdfff9a0cc7cb023.json
2

2. Set the IDs of the messages

Specify the IDs of the messages via comma to refer to specific messages that should be deleted from all users’ histories.
curl -X DELETE \
-H "Content-Type: application/json" \
-H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
https://api.quickblox.com/chat/Message/5d76b949a0eb4721f80b72ab,5d76b657a28f9a0cc7cb0f99,5d76b6sdfff9a0cc7cb023.json
3

3. As a result, the messages will be deleted from all chat histories.

If the API key is not related to the same application as the messages, the API will return the following message: “WrongPermissions”. This means that a user doesn’t have permission to delete a message.
curl -X DELETE \
-H "Content-Type: application/json" \
-H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
https://api.quickblox.com/chat/Message/5d76b949a0eb4721f80b72ab,5d76b657a28f9a0cc7cb0f99,5d76b6sdfff9a0cc7cb023.json
1

1. Specify if you want to delete messages from all chat histories

Set a force parameter to 1 to delete messages from all chat histories.
curl -X DELETE \
-H "Content-Type: application/json" \
-H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
https://api.quickblox.com/chat/Message/5d76b949a0eb4721f80b72ab,5d76b657a28f9a0cc7cb0f99,5d76b6sdfff9a0cc7cb023.json
-d "force=1" \
2

2. Use 'Authorization' header to pass API key

curl -X DELETE \
-H "Content-Type: application/json" \
-H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
https://api.quickblox.com/chat/Message/5d76b949a0eb4721f80b72ab,5d76b657a28f9a0cc7cb0f99,5d76b6sdfff9a0cc7cb023.json
-d "force=1" \
3

3. Set the IDs of the messages

Specify the IDs of the messages via comma to refer to specific messages that should be deleted from all users’ histories.
curl -X DELETE \
-H "Content-Type: application/json" \
-H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
https://api.quickblox.com/chat/Message/5d76b949a0eb4721f80b72ab,5d76b657a28f9a0cc7cb0f99,5d76b6sdfff9a0cc7cb023.json
-d "force=1" \
4

4. As a result, the messages will be deleted from all chat histories.

If the API key is not related to the same application as the messages, the API will return the following message: “WrongPermissions”. This means that a user doesn’t have permission to delete a message.
curl -X DELETE \
-H "Content-Type: application/json" \
-H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
https://api.quickblox.com/chat/Message/5d76b949a0eb4721f80b72ab,5d76b657a28f9a0cc7cb0f99,5d76b6sdfff9a0cc7cb023.json
-d "force=1" \
Any user in the dialog’s occupant_ids is able to remove a message from the dialog. The message will only be removed for the current user. The message will still be viewable in the chat history for all other users in the dialog. You may be wondering why this request only deletes the message for the current user. It is to allow deletion functionality within your app and ensure the message does not reappear in the user chat history, but without affecting the history of other users. It is possible to completely remove a message by the owner - pass force=1.

Path Parameters

chat_message_id
string
ID of the message. Generated automatically by the server after message creation.

Body Parameters

force
integer
Delete message for everyone. Set force=1 to perform. Only the owner can do it.

Headers

QB-Token
string
required
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.
On-Behalf-Of
string
User ID. The user ID of the user on whose behalf the request is being made.

Responses

A successful response
SuccessfullyDeleted
object
NotFound
object
An error response
errors
array of strings
curl -X DELETE \
-H "Content-Type: application/json" \
-H "QB-Token: eddf864695d72d33b959eec2ae6c640d817dfada" \
https://api.quickblox.com/chat/Message/5d76b949a0eb4721f80b72ab,5d76b657a28f9a0cc7cb0f99,5d76b6sdfff9a0cc7cb023.json
{
  "SuccessfullyDeleted": {
    "ids": [
      "5d76b657a28f9a0cc7cb0f99",
      "5d76b949a0eb4721f80b72ab"
    ]
  },
  "NotFound": {
    "ids": [
      "5d76b6sdfff9a0cc7cb023"
    ]
  }
}
I