Create and trigger a Campaign
curl --request POST \
--url https://web-api.clerk.chat/public/campaigns \
--header 'Content-Type: application/json' \
--header 'apiKey: <api-key>' \
--data '
{
"sender": "+1415456789",
"listName": "PremiumTierSubscribers",
"mediaUrls": [
"https://example.com/image.jpg"
],
"body": "Hello, world!",
"provider": "whatsapp",
"name": "Sale Reminder"
}
'import requests
url = "https://web-api.clerk.chat/public/campaigns"
payload = {
"sender": "+1415456789",
"listName": "PremiumTierSubscribers",
"mediaUrls": ["https://example.com/image.jpg"],
"body": "Hello, world!",
"provider": "whatsapp",
"name": "Sale Reminder"
}
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',
listName: 'PremiumTierSubscribers',
mediaUrls: ['https://example.com/image.jpg'],
body: JSON.stringify('Hello, world!'),
provider: 'whatsapp',
name: 'Sale Reminder'
})
};
fetch('https://web-api.clerk.chat/public/campaigns', 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/campaigns",
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',
'listName' => 'PremiumTierSubscribers',
'mediaUrls' => [
'https://example.com/image.jpg'
],
'body' => 'Hello, world!',
'provider' => 'whatsapp',
'name' => 'Sale Reminder'
]),
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/campaigns"
payload := strings.NewReader("{\n \"sender\": \"+1415456789\",\n \"listName\": \"PremiumTierSubscribers\",\n \"mediaUrls\": [\n \"https://example.com/image.jpg\"\n ],\n \"body\": \"Hello, world!\",\n \"provider\": \"whatsapp\",\n \"name\": \"Sale Reminder\"\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/campaigns")
.header("apiKey", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"sender\": \"+1415456789\",\n \"listName\": \"PremiumTierSubscribers\",\n \"mediaUrls\": [\n \"https://example.com/image.jpg\"\n ],\n \"body\": \"Hello, world!\",\n \"provider\": \"whatsapp\",\n \"name\": \"Sale Reminder\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://web-api.clerk.chat/public/campaigns")
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 \"listName\": \"PremiumTierSubscribers\",\n \"mediaUrls\": [\n \"https://example.com/image.jpg\"\n ],\n \"body\": \"Hello, world!\",\n \"provider\": \"whatsapp\",\n \"name\": \"Sale Reminder\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"id": 1,
"body": "Hello, world!",
"teamId": "1",
"userId": "1",
"name": "October Sale Reminder",
"inboxId": "00000000-0000-0000-0000-000000000000",
"status": "scheduled",
"created": "2021-01-01T00:00:00.000Z",
"updated": "2021-01-01T00:00:00.000Z",
"error": "<string>"
}
}Campaigns
Create and trigger a Campaign
Create and trigger a Campaign for a Cohort
POST
/
public
/
campaigns
Create and trigger a Campaign
curl --request POST \
--url https://web-api.clerk.chat/public/campaigns \
--header 'Content-Type: application/json' \
--header 'apiKey: <api-key>' \
--data '
{
"sender": "+1415456789",
"listName": "PremiumTierSubscribers",
"mediaUrls": [
"https://example.com/image.jpg"
],
"body": "Hello, world!",
"provider": "whatsapp",
"name": "Sale Reminder"
}
'import requests
url = "https://web-api.clerk.chat/public/campaigns"
payload = {
"sender": "+1415456789",
"listName": "PremiumTierSubscribers",
"mediaUrls": ["https://example.com/image.jpg"],
"body": "Hello, world!",
"provider": "whatsapp",
"name": "Sale Reminder"
}
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',
listName: 'PremiumTierSubscribers',
mediaUrls: ['https://example.com/image.jpg'],
body: JSON.stringify('Hello, world!'),
provider: 'whatsapp',
name: 'Sale Reminder'
})
};
fetch('https://web-api.clerk.chat/public/campaigns', 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/campaigns",
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',
'listName' => 'PremiumTierSubscribers',
'mediaUrls' => [
'https://example.com/image.jpg'
],
'body' => 'Hello, world!',
'provider' => 'whatsapp',
'name' => 'Sale Reminder'
]),
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/campaigns"
payload := strings.NewReader("{\n \"sender\": \"+1415456789\",\n \"listName\": \"PremiumTierSubscribers\",\n \"mediaUrls\": [\n \"https://example.com/image.jpg\"\n ],\n \"body\": \"Hello, world!\",\n \"provider\": \"whatsapp\",\n \"name\": \"Sale Reminder\"\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/campaigns")
.header("apiKey", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"sender\": \"+1415456789\",\n \"listName\": \"PremiumTierSubscribers\",\n \"mediaUrls\": [\n \"https://example.com/image.jpg\"\n ],\n \"body\": \"Hello, world!\",\n \"provider\": \"whatsapp\",\n \"name\": \"Sale Reminder\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://web-api.clerk.chat/public/campaigns")
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 \"listName\": \"PremiumTierSubscribers\",\n \"mediaUrls\": [\n \"https://example.com/image.jpg\"\n ],\n \"body\": \"Hello, world!\",\n \"provider\": \"whatsapp\",\n \"name\": \"Sale Reminder\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"id": 1,
"body": "Hello, world!",
"teamId": "1",
"userId": "1",
"name": "October Sale Reminder",
"inboxId": "00000000-0000-0000-0000-000000000000",
"status": "scheduled",
"created": "2021-01-01T00:00:00.000Z",
"updated": "2021-01-01T00:00:00.000Z",
"error": "<string>"
}
}Authorizations
Body
application/json
The Clerk phone number or identifier from which campaign messages will be sent
Example:
"+1415456789"
The name of the list containing the contacts the campaign will be sent to
Example:
"PremiumTierSubscribers"
The media URLs to send with the campaign message
Example:
["https://example.com/image.jpg"]
The message text
Example:
"Hello, world!"
The provider to send the message from
Available options:
twilio, bandwidth, msteams, other, non_voip, whatsapp, telnyx, webex, rcs Example:
"whatsapp"
An optional name for the campaign
Example:
"Sale Reminder"
Response
The created campaign
Show child attributes
Show child attributes
⌘I