Update draft or scheduled campaign
curl --request PATCH \
--url https://api.otpiq.com/api/whatsapp/campaigns/{_id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "<string>",
"templateId": "<string>",
"phoneNumberId": "<string>",
"scheduledFor": "2023-11-07T05:31:56Z"
}
'import requests
url = "https://api.otpiq.com/api/whatsapp/campaigns/{_id}"
payload = {
"name": "<string>",
"templateId": "<string>",
"phoneNumberId": "<string>",
"scheduledFor": "2023-11-07T05:31:56Z"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: '<string>',
templateId: '<string>',
phoneNumberId: '<string>',
scheduledFor: '2023-11-07T05:31:56Z'
})
};
fetch('https://api.otpiq.com/api/whatsapp/campaigns/{_id}', 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}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'name' => '<string>',
'templateId' => '<string>',
'phoneNumberId' => '<string>',
'scheduledFor' => '2023-11-07T05:31:56Z'
]),
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}"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"templateId\": \"<string>\",\n \"phoneNumberId\": \"<string>\",\n \"scheduledFor\": \"2023-11-07T05:31:56Z\"\n}")
req, _ := http.NewRequest("PATCH", 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.patch("https://api.otpiq.com/api/whatsapp/campaigns/{_id}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"templateId\": \"<string>\",\n \"phoneNumberId\": \"<string>\",\n \"scheduledFor\": \"2023-11-07T05:31:56Z\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.otpiq.com/api/whatsapp/campaigns/{_id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"<string>\",\n \"templateId\": \"<string>\",\n \"phoneNumberId\": \"<string>\",\n \"scheduledFor\": \"2023-11-07T05:31:56Z\"\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
Update Campaign
Update metadata for a draft or scheduled campaign
PATCH
/
whatsapp
/
campaigns
/
{_id}
Update draft or scheduled campaign
curl --request PATCH \
--url https://api.otpiq.com/api/whatsapp/campaigns/{_id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "<string>",
"templateId": "<string>",
"phoneNumberId": "<string>",
"scheduledFor": "2023-11-07T05:31:56Z"
}
'import requests
url = "https://api.otpiq.com/api/whatsapp/campaigns/{_id}"
payload = {
"name": "<string>",
"templateId": "<string>",
"phoneNumberId": "<string>",
"scheduledFor": "2023-11-07T05:31:56Z"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: '<string>',
templateId: '<string>',
phoneNumberId: '<string>',
scheduledFor: '2023-11-07T05:31:56Z'
})
};
fetch('https://api.otpiq.com/api/whatsapp/campaigns/{_id}', 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}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'name' => '<string>',
'templateId' => '<string>',
'phoneNumberId' => '<string>',
'scheduledFor' => '2023-11-07T05:31:56Z'
]),
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}"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"templateId\": \"<string>\",\n \"phoneNumberId\": \"<string>\",\n \"scheduledFor\": \"2023-11-07T05:31:56Z\"\n}")
req, _ := http.NewRequest("PATCH", 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.patch("https://api.otpiq.com/api/whatsapp/campaigns/{_id}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"templateId\": \"<string>\",\n \"phoneNumberId\": \"<string>\",\n \"scheduledFor\": \"2023-11-07T05:31:56Z\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.otpiq.com/api/whatsapp/campaigns/{_id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"<string>\",\n \"templateId\": \"<string>\",\n \"phoneNumberId\": \"<string>\",\n \"scheduledFor\": \"2023-11-07T05:31:56Z\"\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"
}You can only edit campaigns that are in
draft or scheduled status. Campaigns that have already started cannot be modified.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 string length:
3 - 80Pattern:
^[a-fA-F0-9]{24}$Pattern:
^[a-fA-F0-9]{24}$Available options:
MARKETING, UTILITY Exactly two allowed values:
now— save as draft; start manually via POST.../start(scheduledFornot used)schedule— requiresscheduledFor(future datetime); saves asscheduled; auto-starts at that time
Available options:
now, schedule ISO-8601 datetime in the future when scheduleType is schedule
⌘I