POST
/
chat
/
Message.json
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

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

chat_dialog_id
string
ID of the dialog to which these messages will be added.
message
string
Text of the
recipient_id
string
ID of the recipient. Useful only when dialog’s type=3 (PRIVATE).
attachments
object
send_to_chat
integer
Sends a message to chat. Set send_to_chat=1 to perform.
markable
integer
Mark messages to support read/delivered statuses. Set markable=1 to perform.
{custom_field_N}
string

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

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 '{  
  "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
}