Create a campaign
A campaign is a /v1 broadcast; the id works on /v1/broadcasts/{broadcastId}. Runs POST /v1/broadcasts with the sender resolved from from. A repeated idempotencyKey answers 409 conflict with the original in details.campaign. A channel the resolved sender does not carry (smart: no channel at all) is refused at creation with 409 no_channel, as on POST /v2/messages, rather than created and failed at send. from with a channel it does not carry (a sms campaign from: "sms_oneway") is that same 409 no_channel, in the words POST /v2/messages uses (details.connected, and sms vs sms_oneway told apart); channel only picks between senders that share an address, it never makes an existing address 404.
curl --request POST \
--url https://api.zavu.dev/v2/campaigns \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "Black Friday Sale",
"messageType": "text",
"text": "Hi {{name}}, check out our Black Friday deals!",
"content": {
"mediaUrl": "<string>",
"mediaId": "<string>",
"mimeType": "<string>",
"filename": "<string>",
"templateId": "<string>",
"templateVariables": {},
"templateButtonVariables": {},
"templateHeaderVariables": {}
},
"emailSubject": "<string>",
"emailHtmlBody": "<string>",
"scheduledAt": "2023-11-07T05:31:56Z",
"metadata": {},
"idempotencyKey": "<string>",
"from": "<string>"
}
'import requests
url = "https://api.zavu.dev/v2/campaigns"
payload = {
"name": "Black Friday Sale",
"messageType": "text",
"text": "Hi {{name}}, check out our Black Friday deals!",
"content": {
"mediaUrl": "<string>",
"mediaId": "<string>",
"mimeType": "<string>",
"filename": "<string>",
"templateId": "<string>",
"templateVariables": {},
"templateButtonVariables": {},
"templateHeaderVariables": {}
},
"emailSubject": "<string>",
"emailHtmlBody": "<string>",
"scheduledAt": "2023-11-07T05:31:56Z",
"metadata": {},
"idempotencyKey": "<string>",
"from": "<string>"
}
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({
name: 'Black Friday Sale',
messageType: 'text',
text: 'Hi {{name}}, check out our Black Friday deals!',
content: {
mediaUrl: '<string>',
mediaId: '<string>',
mimeType: '<string>',
filename: '<string>',
templateId: '<string>',
templateVariables: {},
templateButtonVariables: {},
templateHeaderVariables: {}
},
emailSubject: '<string>',
emailHtmlBody: '<string>',
scheduledAt: '2023-11-07T05:31:56Z',
metadata: {},
idempotencyKey: '<string>',
from: '<string>'
})
};
fetch('https://api.zavu.dev/v2/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://api.zavu.dev/v2/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([
'name' => 'Black Friday Sale',
'messageType' => 'text',
'text' => 'Hi {{name}}, check out our Black Friday deals!',
'content' => [
'mediaUrl' => '<string>',
'mediaId' => '<string>',
'mimeType' => '<string>',
'filename' => '<string>',
'templateId' => '<string>',
'templateVariables' => [
],
'templateButtonVariables' => [
],
'templateHeaderVariables' => [
]
],
'emailSubject' => '<string>',
'emailHtmlBody' => '<string>',
'scheduledAt' => '2023-11-07T05:31:56Z',
'metadata' => [
],
'idempotencyKey' => '<string>',
'from' => '<string>'
]),
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.zavu.dev/v2/campaigns"
payload := strings.NewReader("{\n \"name\": \"Black Friday Sale\",\n \"messageType\": \"text\",\n \"text\": \"Hi {{name}}, check out our Black Friday deals!\",\n \"content\": {\n \"mediaUrl\": \"<string>\",\n \"mediaId\": \"<string>\",\n \"mimeType\": \"<string>\",\n \"filename\": \"<string>\",\n \"templateId\": \"<string>\",\n \"templateVariables\": {},\n \"templateButtonVariables\": {},\n \"templateHeaderVariables\": {}\n },\n \"emailSubject\": \"<string>\",\n \"emailHtmlBody\": \"<string>\",\n \"scheduledAt\": \"2023-11-07T05:31:56Z\",\n \"metadata\": {},\n \"idempotencyKey\": \"<string>\",\n \"from\": \"<string>\"\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.zavu.dev/v2/campaigns")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"Black Friday Sale\",\n \"messageType\": \"text\",\n \"text\": \"Hi {{name}}, check out our Black Friday deals!\",\n \"content\": {\n \"mediaUrl\": \"<string>\",\n \"mediaId\": \"<string>\",\n \"mimeType\": \"<string>\",\n \"filename\": \"<string>\",\n \"templateId\": \"<string>\",\n \"templateVariables\": {},\n \"templateButtonVariables\": {},\n \"templateHeaderVariables\": {}\n },\n \"emailSubject\": \"<string>\",\n \"emailHtmlBody\": \"<string>\",\n \"scheduledAt\": \"2023-11-07T05:31:56Z\",\n \"metadata\": {},\n \"idempotencyKey\": \"<string>\",\n \"from\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.zavu.dev/v2/campaigns")
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 \"name\": \"Black Friday Sale\",\n \"messageType\": \"text\",\n \"text\": \"Hi {{name}}, check out our Black Friday deals!\",\n \"content\": {\n \"mediaUrl\": \"<string>\",\n \"mediaId\": \"<string>\",\n \"mimeType\": \"<string>\",\n \"filename\": \"<string>\",\n \"templateId\": \"<string>\",\n \"templateVariables\": {},\n \"templateButtonVariables\": {},\n \"templateHeaderVariables\": {}\n },\n \"emailSubject\": \"<string>\",\n \"emailHtmlBody\": \"<string>\",\n \"scheduledAt\": \"2023-11-07T05:31:56Z\",\n \"metadata\": {},\n \"idempotencyKey\": \"<string>\",\n \"from\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"campaign": {
"id": "brd_abc123",
"name": "<string>",
"status": "draft",
"channel": "smart",
"messageType": "text",
"totalContacts": 123,
"createdAt": "2023-11-07T05:31:56Z",
"text": "<string>",
"content": {
"mediaUrl": "<string>",
"mediaId": "<string>",
"mimeType": "<string>",
"filename": "<string>",
"templateId": "<string>",
"templateVariables": {},
"templateButtonVariables": {},
"templateHeaderVariables": {}
},
"emailSubject": "<string>",
"pendingCount": 123,
"sendingCount": 123,
"sentCount": 123,
"deliveredCount": 123,
"failedCount": 123,
"estimatedCost": 123,
"reservedAmount": 123,
"actualCost": 123,
"scheduledAt": "2023-11-07T05:31:56Z",
"startedAt": "2023-11-07T05:31:56Z",
"completedAt": "2023-11-07T05:31:56Z",
"metadata": {},
"updatedAt": "2023-11-07T05:31:56Z",
"reviewResult": {
"score": 123,
"categories": [
"<string>"
],
"reasoning": "<string>",
"reviewedAt": "2023-11-07T05:31:56Z",
"flaggedContent": [
"<string>"
]
},
"reviewAttempts": 123,
"from": "<string>"
}
}{
"code": "invalid_request",
"message": "<string>",
"details": {
"errors": [
{
"path": [
"<string>"
],
"message": "<string>",
"code": "<string>"
}
]
}
}{
"code": "invalid_request",
"message": "<string>",
"details": {
"errors": [
{
"path": [
"<string>"
],
"message": "<string>",
"code": "<string>"
}
]
}
}{
"code": "invalid_request",
"message": "<string>",
"details": {
"errors": [
{
"path": [
"<string>"
],
"message": "<string>",
"code": "<string>"
}
]
}
}{
"code": "invalid_request",
"message": "<string>",
"details": {
"errors": [
{
"path": [
"<string>"
],
"message": "<string>",
"code": "<string>"
}
]
}
}{
"code": "invalid_request",
"message": "<string>",
"details": {
"errors": [
{
"path": [
"<string>"
],
"message": "<string>",
"code": "<string>"
}
]
}
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
A campaign is a /v1 broadcast. Create it, add recipients, then send.
Name of the broadcast campaign.
"Black Friday Sale"
Broadcast delivery channel. Use 'smart' for per-contact intelligent routing.
smart, sms, sms_oneway, whatsapp, telegram, email Type of message for broadcast.
text, image, video, audio, document, template Text content or caption. Supports template variables: {{name}}, {{1}}, etc.
"Hi {{name}}, check out our Black Friday deals!"
Content for non-text broadcast message types.
Show child attributes
Show child attributes
Email subject line. Required for email broadcasts.
HTML body for email broadcasts.
Schedule the broadcast for future delivery.
Show child attributes
Show child attributes
Idempotency key to prevent duplicate broadcasts.
The address that sends the campaign (GET /v2/channels). The project default when omitted. Resolved like from on POST /v2/messages, with the campaign's channel as the transport (none for smart).
Response
Created as draft.
A campaign. The same object as a /v1 broadcast: its id works on /v1/broadcasts/{broadcastId}.
Show child attributes
Show child attributes
curl --request POST \
--url https://api.zavu.dev/v2/campaigns \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "Black Friday Sale",
"messageType": "text",
"text": "Hi {{name}}, check out our Black Friday deals!",
"content": {
"mediaUrl": "<string>",
"mediaId": "<string>",
"mimeType": "<string>",
"filename": "<string>",
"templateId": "<string>",
"templateVariables": {},
"templateButtonVariables": {},
"templateHeaderVariables": {}
},
"emailSubject": "<string>",
"emailHtmlBody": "<string>",
"scheduledAt": "2023-11-07T05:31:56Z",
"metadata": {},
"idempotencyKey": "<string>",
"from": "<string>"
}
'import requests
url = "https://api.zavu.dev/v2/campaigns"
payload = {
"name": "Black Friday Sale",
"messageType": "text",
"text": "Hi {{name}}, check out our Black Friday deals!",
"content": {
"mediaUrl": "<string>",
"mediaId": "<string>",
"mimeType": "<string>",
"filename": "<string>",
"templateId": "<string>",
"templateVariables": {},
"templateButtonVariables": {},
"templateHeaderVariables": {}
},
"emailSubject": "<string>",
"emailHtmlBody": "<string>",
"scheduledAt": "2023-11-07T05:31:56Z",
"metadata": {},
"idempotencyKey": "<string>",
"from": "<string>"
}
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({
name: 'Black Friday Sale',
messageType: 'text',
text: 'Hi {{name}}, check out our Black Friday deals!',
content: {
mediaUrl: '<string>',
mediaId: '<string>',
mimeType: '<string>',
filename: '<string>',
templateId: '<string>',
templateVariables: {},
templateButtonVariables: {},
templateHeaderVariables: {}
},
emailSubject: '<string>',
emailHtmlBody: '<string>',
scheduledAt: '2023-11-07T05:31:56Z',
metadata: {},
idempotencyKey: '<string>',
from: '<string>'
})
};
fetch('https://api.zavu.dev/v2/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://api.zavu.dev/v2/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([
'name' => 'Black Friday Sale',
'messageType' => 'text',
'text' => 'Hi {{name}}, check out our Black Friday deals!',
'content' => [
'mediaUrl' => '<string>',
'mediaId' => '<string>',
'mimeType' => '<string>',
'filename' => '<string>',
'templateId' => '<string>',
'templateVariables' => [
],
'templateButtonVariables' => [
],
'templateHeaderVariables' => [
]
],
'emailSubject' => '<string>',
'emailHtmlBody' => '<string>',
'scheduledAt' => '2023-11-07T05:31:56Z',
'metadata' => [
],
'idempotencyKey' => '<string>',
'from' => '<string>'
]),
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.zavu.dev/v2/campaigns"
payload := strings.NewReader("{\n \"name\": \"Black Friday Sale\",\n \"messageType\": \"text\",\n \"text\": \"Hi {{name}}, check out our Black Friday deals!\",\n \"content\": {\n \"mediaUrl\": \"<string>\",\n \"mediaId\": \"<string>\",\n \"mimeType\": \"<string>\",\n \"filename\": \"<string>\",\n \"templateId\": \"<string>\",\n \"templateVariables\": {},\n \"templateButtonVariables\": {},\n \"templateHeaderVariables\": {}\n },\n \"emailSubject\": \"<string>\",\n \"emailHtmlBody\": \"<string>\",\n \"scheduledAt\": \"2023-11-07T05:31:56Z\",\n \"metadata\": {},\n \"idempotencyKey\": \"<string>\",\n \"from\": \"<string>\"\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.zavu.dev/v2/campaigns")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"Black Friday Sale\",\n \"messageType\": \"text\",\n \"text\": \"Hi {{name}}, check out our Black Friday deals!\",\n \"content\": {\n \"mediaUrl\": \"<string>\",\n \"mediaId\": \"<string>\",\n \"mimeType\": \"<string>\",\n \"filename\": \"<string>\",\n \"templateId\": \"<string>\",\n \"templateVariables\": {},\n \"templateButtonVariables\": {},\n \"templateHeaderVariables\": {}\n },\n \"emailSubject\": \"<string>\",\n \"emailHtmlBody\": \"<string>\",\n \"scheduledAt\": \"2023-11-07T05:31:56Z\",\n \"metadata\": {},\n \"idempotencyKey\": \"<string>\",\n \"from\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.zavu.dev/v2/campaigns")
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 \"name\": \"Black Friday Sale\",\n \"messageType\": \"text\",\n \"text\": \"Hi {{name}}, check out our Black Friday deals!\",\n \"content\": {\n \"mediaUrl\": \"<string>\",\n \"mediaId\": \"<string>\",\n \"mimeType\": \"<string>\",\n \"filename\": \"<string>\",\n \"templateId\": \"<string>\",\n \"templateVariables\": {},\n \"templateButtonVariables\": {},\n \"templateHeaderVariables\": {}\n },\n \"emailSubject\": \"<string>\",\n \"emailHtmlBody\": \"<string>\",\n \"scheduledAt\": \"2023-11-07T05:31:56Z\",\n \"metadata\": {},\n \"idempotencyKey\": \"<string>\",\n \"from\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"campaign": {
"id": "brd_abc123",
"name": "<string>",
"status": "draft",
"channel": "smart",
"messageType": "text",
"totalContacts": 123,
"createdAt": "2023-11-07T05:31:56Z",
"text": "<string>",
"content": {
"mediaUrl": "<string>",
"mediaId": "<string>",
"mimeType": "<string>",
"filename": "<string>",
"templateId": "<string>",
"templateVariables": {},
"templateButtonVariables": {},
"templateHeaderVariables": {}
},
"emailSubject": "<string>",
"pendingCount": 123,
"sendingCount": 123,
"sentCount": 123,
"deliveredCount": 123,
"failedCount": 123,
"estimatedCost": 123,
"reservedAmount": 123,
"actualCost": 123,
"scheduledAt": "2023-11-07T05:31:56Z",
"startedAt": "2023-11-07T05:31:56Z",
"completedAt": "2023-11-07T05:31:56Z",
"metadata": {},
"updatedAt": "2023-11-07T05:31:56Z",
"reviewResult": {
"score": 123,
"categories": [
"<string>"
],
"reasoning": "<string>",
"reviewedAt": "2023-11-07T05:31:56Z",
"flaggedContent": [
"<string>"
]
},
"reviewAttempts": 123,
"from": "<string>"
}
}{
"code": "invalid_request",
"message": "<string>",
"details": {
"errors": [
{
"path": [
"<string>"
],
"message": "<string>",
"code": "<string>"
}
]
}
}{
"code": "invalid_request",
"message": "<string>",
"details": {
"errors": [
{
"path": [
"<string>"
],
"message": "<string>",
"code": "<string>"
}
]
}
}{
"code": "invalid_request",
"message": "<string>",
"details": {
"errors": [
{
"path": [
"<string>"
],
"message": "<string>",
"code": "<string>"
}
]
}
}{
"code": "invalid_request",
"message": "<string>",
"details": {
"errors": [
{
"path": [
"<string>"
],
"message": "<string>",
"code": "<string>"
}
]
}
}{
"code": "invalid_request",
"message": "<string>",
"details": {
"errors": [
{
"path": [
"<string>"
],
"message": "<string>",
"code": "<string>"
}
]
}
}