Send a sample campaign
curl --request POST \
--url https://api.otpiq.com/api/whatsapp/campaigns/{_id}/sample \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"recipients": [
{
"phoneNumber": "9647712345678",
"templateParameters": {
"body": {},
"header": {},
"buttons": {}
}
}
]
}
'import requests
url = "https://api.otpiq.com/api/whatsapp/campaigns/{_id}/sample"
payload = { "recipients": [
{
"phoneNumber": "9647712345678",
"templateParameters": {
"body": {},
"header": {},
"buttons": {}
}
}
] }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
recipients: [
{
phoneNumber: '9647712345678',
templateParameters: {body: JSON.stringify({}), header: {}, buttons: {}}
}
]
})
};
fetch('https://api.otpiq.com/api/whatsapp/campaigns/{_id}/sample', 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://api.otpiq.com/api/whatsapp/campaigns/{_id}/sample",
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([
'recipients' => [
[
'phoneNumber' => '9647712345678',
'templateParameters' => [
'body' => [
],
'header' => [
],
'buttons' => [
]
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$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://api.otpiq.com/api/whatsapp/campaigns/{_id}/sample"
payload := strings.NewReader("{\n \"recipients\": [\n {\n \"phoneNumber\": \"9647712345678\",\n \"templateParameters\": {\n \"body\": {},\n \"header\": {},\n \"buttons\": {}\n }\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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://api.otpiq.com/api/whatsapp/campaigns/{_id}/sample")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"recipients\": [\n {\n \"phoneNumber\": \"9647712345678\",\n \"templateParameters\": {\n \"body\": {},\n \"header\": {},\n \"buttons\": {}\n }\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.otpiq.com/api/whatsapp/campaigns/{_id}/sample")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"recipients\": [\n {\n \"phoneNumber\": \"9647712345678\",\n \"templateParameters\": {\n \"body\": {},\n \"header\": {},\n \"buttons\": {}\n }\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"data": {
"_id": "<string>",
"campaignId": "<string>",
"name": "<string>",
"template": "<string>",
"phoneNumber": "<string>",
"scheduledFor": "2023-11-07T05:31:56Z",
"startedAt": "2023-11-07T05:31:56Z",
"completedAt": "2023-11-07T05:31:56Z",
"totalRecipients": 123,
"sentCount": 123,
"deliveredCount": 123,
"failedCount": 123,
"estimatedTotalCost": 123,
"reservedAmount": 123,
"reconciledAmount": 123,
"isSampleCampaign": true,
"sampleOfCampaign": "<string>",
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z"
}
}{
"success": false,
"error": "Recipients cannot exceed 1000 per request"
}{
"message": "Unauthorized, please use your project api key"
}{
"success": false,
"error": "<string>",
"unsupportedPhoneNumbers": [
"<string>"
]
}{
"success": false,
"error": "Campaign not found"
}WhatsApp Campaigns Endpoints
Send Sample
Create and immediately start a child sample campaign from a draft or scheduled main campaign
POST
/
whatsapp
/
campaigns
/
{_id}
/
sample
Send a sample campaign
curl --request POST \
--url https://api.otpiq.com/api/whatsapp/campaigns/{_id}/sample \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"recipients": [
{
"phoneNumber": "9647712345678",
"templateParameters": {
"body": {},
"header": {},
"buttons": {}
}
}
]
}
'import requests
url = "https://api.otpiq.com/api/whatsapp/campaigns/{_id}/sample"
payload = { "recipients": [
{
"phoneNumber": "9647712345678",
"templateParameters": {
"body": {},
"header": {},
"buttons": {}
}
}
] }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
recipients: [
{
phoneNumber: '9647712345678',
templateParameters: {body: JSON.stringify({}), header: {}, buttons: {}}
}
]
})
};
fetch('https://api.otpiq.com/api/whatsapp/campaigns/{_id}/sample', 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://api.otpiq.com/api/whatsapp/campaigns/{_id}/sample",
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([
'recipients' => [
[
'phoneNumber' => '9647712345678',
'templateParameters' => [
'body' => [
],
'header' => [
],
'buttons' => [
]
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$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://api.otpiq.com/api/whatsapp/campaigns/{_id}/sample"
payload := strings.NewReader("{\n \"recipients\": [\n {\n \"phoneNumber\": \"9647712345678\",\n \"templateParameters\": {\n \"body\": {},\n \"header\": {},\n \"buttons\": {}\n }\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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://api.otpiq.com/api/whatsapp/campaigns/{_id}/sample")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"recipients\": [\n {\n \"phoneNumber\": \"9647712345678\",\n \"templateParameters\": {\n \"body\": {},\n \"header\": {},\n \"buttons\": {}\n }\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.otpiq.com/api/whatsapp/campaigns/{_id}/sample")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"recipients\": [\n {\n \"phoneNumber\": \"9647712345678\",\n \"templateParameters\": {\n \"body\": {},\n \"header\": {},\n \"buttons\": {}\n }\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"data": {
"_id": "<string>",
"campaignId": "<string>",
"name": "<string>",
"template": "<string>",
"phoneNumber": "<string>",
"scheduledFor": "2023-11-07T05:31:56Z",
"startedAt": "2023-11-07T05:31:56Z",
"completedAt": "2023-11-07T05:31:56Z",
"totalRecipients": 123,
"sentCount": 123,
"deliveredCount": 123,
"failedCount": 123,
"estimatedTotalCost": 123,
"reservedAmount": 123,
"reconciledAmount": 123,
"isSampleCampaign": true,
"sampleOfCampaign": "<string>",
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z"
}
}{
"success": false,
"error": "Recipients cannot exceed 1000 per request"
}{
"message": "Unauthorized, please use your project api key"
}{
"success": false,
"error": "<string>",
"unsupportedPhoneNumbers": [
"<string>"
]
}{
"success": false,
"error": "Campaign not found"
}Sending a sample campaign does not modify the parent campaign. It’s a great way to test your template and parameters before a full broadcast.
Authorizations
Project API key (sk_live… or sk_dev…). Send it as Authorization: Bearer <api_key>.
Path Parameters
Campaign MongoDB id returned on create
Pattern:
^[a-fA-F0-9]{24}$Body
application/json
Required array length:
1 - 1000 elementsShow child attributes
Show child attributes
⌘I