Send a message
curl --request POST \
--url https://web-api.clerk.chat/public/messages \
--header 'Content-Type: application/json' \
--header 'apiKey: <api-key>' \
--data '
{
"sender": "+1415456789",
"mediaUrls": [
"https://example.com/image.jpg"
],
"recipients": [
"+9134567654"
],
"body": "Hello, world!",
"sentByName": "Clerk",
"templateId": 123
}
'import requests
url = "https://web-api.clerk.chat/public/messages"
payload = {
"sender": "+1415456789",
"mediaUrls": ["https://example.com/image.jpg"],
"recipients": ["+9134567654"],
"body": "Hello, world!",
"sentByName": "Clerk",
"templateId": 123
}
headers = {
"apiKey": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {apiKey: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
sender: '+1415456789',
mediaUrls: ['https://example.com/image.jpg'],
recipients: ['+9134567654'],
body: JSON.stringify('Hello, world!'),
sentByName: 'Clerk',
templateId: 123
})
};
fetch('https://web-api.clerk.chat/public/messages', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://web-api.clerk.chat/public/messages",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'sender' => '+1415456789',
'mediaUrls' => [
'https://example.com/image.jpg'
],
'recipients' => [
'+9134567654'
],
'body' => 'Hello, world!',
'sentByName' => 'Clerk',
'templateId' => 123
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"apiKey: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://web-api.clerk.chat/public/messages"
payload := strings.NewReader("{\n \"sender\": \"+1415456789\",\n \"mediaUrls\": [\n \"https://example.com/image.jpg\"\n ],\n \"recipients\": [\n \"+9134567654\"\n ],\n \"body\": \"Hello, world!\",\n \"sentByName\": \"Clerk\",\n \"templateId\": 123\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("apiKey", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://web-api.clerk.chat/public/messages")
.header("apiKey", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"sender\": \"+1415456789\",\n \"mediaUrls\": [\n \"https://example.com/image.jpg\"\n ],\n \"recipients\": [\n \"+9134567654\"\n ],\n \"body\": \"Hello, world!\",\n \"sentByName\": \"Clerk\",\n \"templateId\": 123\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://web-api.clerk.chat/public/messages")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["apiKey"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"sender\": \"+1415456789\",\n \"mediaUrls\": [\n \"https://example.com/image.jpg\"\n ],\n \"recipients\": [\n \"+9134567654\"\n ],\n \"body\": \"Hello, world!\",\n \"sentByName\": \"Clerk\",\n \"templateId\": 123\n}"
response = http.request(request)
puts response.read_body{
"data": {
"id": 1,
"body": "Hello, world!",
"conversationId": "1",
"inbound": true,
"members": [
"+1415456789"
],
"sender": "+1415456789",
"senderType": "user",
"status": "delivered",
"created": "2021-01-01T00:00:00.000Z",
"updated": "2021-01-01T00:00:00.000Z",
"seen": true,
"segments": 1,
"timestamp": "2021-01-01T00:00:00.000Z",
"userId": "1",
"campaignMessageId": 1,
"campaignId": 1,
"channelId": "00000000-0000-0000-0000-000000000000",
"inboxId": "00000000-0000-0000-0000-000000000000",
"error": "<string>",
"sentByName": "Clerk",
"errorCode": 123,
"externalId": "external-id"
}
}Messages
Send a message
Send a message to a contact
POST
/
public
/
messages
Send a message
curl --request POST \
--url https://web-api.clerk.chat/public/messages \
--header 'Content-Type: application/json' \
--header 'apiKey: <api-key>' \
--data '
{
"sender": "+1415456789",
"mediaUrls": [
"https://example.com/image.jpg"
],
"recipients": [
"+9134567654"
],
"body": "Hello, world!",
"sentByName": "Clerk",
"templateId": 123
}
'import requests
url = "https://web-api.clerk.chat/public/messages"
payload = {
"sender": "+1415456789",
"mediaUrls": ["https://example.com/image.jpg"],
"recipients": ["+9134567654"],
"body": "Hello, world!",
"sentByName": "Clerk",
"templateId": 123
}
headers = {
"apiKey": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {apiKey: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
sender: '+1415456789',
mediaUrls: ['https://example.com/image.jpg'],
recipients: ['+9134567654'],
body: JSON.stringify('Hello, world!'),
sentByName: 'Clerk',
templateId: 123
})
};
fetch('https://web-api.clerk.chat/public/messages', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://web-api.clerk.chat/public/messages",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'sender' => '+1415456789',
'mediaUrls' => [
'https://example.com/image.jpg'
],
'recipients' => [
'+9134567654'
],
'body' => 'Hello, world!',
'sentByName' => 'Clerk',
'templateId' => 123
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"apiKey: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://web-api.clerk.chat/public/messages"
payload := strings.NewReader("{\n \"sender\": \"+1415456789\",\n \"mediaUrls\": [\n \"https://example.com/image.jpg\"\n ],\n \"recipients\": [\n \"+9134567654\"\n ],\n \"body\": \"Hello, world!\",\n \"sentByName\": \"Clerk\",\n \"templateId\": 123\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("apiKey", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://web-api.clerk.chat/public/messages")
.header("apiKey", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"sender\": \"+1415456789\",\n \"mediaUrls\": [\n \"https://example.com/image.jpg\"\n ],\n \"recipients\": [\n \"+9134567654\"\n ],\n \"body\": \"Hello, world!\",\n \"sentByName\": \"Clerk\",\n \"templateId\": 123\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://web-api.clerk.chat/public/messages")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["apiKey"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"sender\": \"+1415456789\",\n \"mediaUrls\": [\n \"https://example.com/image.jpg\"\n ],\n \"recipients\": [\n \"+9134567654\"\n ],\n \"body\": \"Hello, world!\",\n \"sentByName\": \"Clerk\",\n \"templateId\": 123\n}"
response = http.request(request)
puts response.read_body{
"data": {
"id": 1,
"body": "Hello, world!",
"conversationId": "1",
"inbound": true,
"members": [
"+1415456789"
],
"sender": "+1415456789",
"senderType": "user",
"status": "delivered",
"created": "2021-01-01T00:00:00.000Z",
"updated": "2021-01-01T00:00:00.000Z",
"seen": true,
"segments": 1,
"timestamp": "2021-01-01T00:00:00.000Z",
"userId": "1",
"campaignMessageId": 1,
"campaignId": 1,
"channelId": "00000000-0000-0000-0000-000000000000",
"inboxId": "00000000-0000-0000-0000-000000000000",
"error": "<string>",
"sentByName": "Clerk",
"errorCode": 123,
"externalId": "external-id"
}
}Authorizations
Body
application/json
The Clerk phone number or identifier the message should be sent from
Example:
"+1415456789"
The media URLs to send with the message
Example:
["https://example.com/image.jpg"]
The recipients of the message
Example:
["+9134567654"]
The message text
Example:
"Hello, world!"
The name of the sender displayed in the UI
Example:
"Clerk"
The ID of the template to use for the message
Example:
123
Response
The sent message
Represents a message resource
Show child attributes
Show child attributes
⌘I