POST/ message/
Create message
You can send a message to your user. Message content can be just plain text or HTML.
Hi
<b>user</b>, enjoy our product!
The message will be shown as follow:
Hi user, enjoy our product!
Attributes
Optional unless marked required
- conversation
- A unique identifier for the conversation which is given by User automatically.
- user
- A unique identifier for the agent which is given by User automatically.
- content
- A content of a message sent to the user.
- source
- Where the message was sent from:
1chat,2email,3API (the default),4SMS,8Facebook,9Instagram,10ChatAI. See Message source types. - source_context
- An additional context for your source (only visible for you).
Request
- cURL
- JavaScript
- PHP
- Python
curl -X POST "https://<your_app_subdomain>.user.com/api/public/message/" \
-H "Authorization: Token <your_64_char_api_key>" \
-H "Accept: */*; version=2" \
-H "Content-Type: application/json" \
-d '{
"conversation": 12345,
"user": 2,
"content": "Following up on your question.",
"source": 3
}'
const response = await fetch(
"https://<your_app_subdomain>.user.com/api/public/message/",
{
method: "POST",
headers: {
Authorization: "Token <your_64_char_api_key>",
Accept: "*/*; version=2",
"Content-Type": "application/json",
},
body: JSON.stringify({
conversation: 12345,
user: 2,
content: "Following up on your question.",
source: 3,
}),
},
);
const data = await response.json();
console.log(data);
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://<your_app_subdomain>.user.com/api/public/message/",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"Authorization: Token <your_64_char_api_key>",
"Accept: */*; version=2",
"Content-Type: application/json",
],
CURLOPT_POSTFIELDS => json_encode([
"conversation" => 12345,
"user" => 2,
"content" => "Following up on your question.",
"source" => 3,
]),
]);
$response = curl_exec($curl);
curl_close($curl);
echo $response;
import requests
response = requests.post(
"https://<your_app_subdomain>.user.com/api/public/message/",
headers={
"Authorization": "Token <your_64_char_api_key>",
"Accept": "*/*; version=2",
},
json={
"conversation": 12345,
"user": 2,
"content": "Following up on your question.",
"source": 3,
},
)
print(response.json())
Response examples
- 201 Created
- 400 Bad Request
No response body.
{"content": ["This field is required."]}note
Errors that can come from any endpoint (401, 429, 500, 502, 504) are described in HTTP response codes.