Campaigns
Create Campaign
Record a campaign; the campaign worker starts dialling it.
POST
/
v1
/
campaigns
Create Campaign
curl --request POST \
--url https://api.example.com/v1/campaigns \
--header 'Content-Type: application/json' \
--data '
{
"name": "<string>",
"from_number_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"targets": [
{
"number": "<string>",
"variables": {},
"timezone": "<string>"
}
],
"agent_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"agents": [
{
"agent_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"weight": 50
}
],
"timezone": "<string>",
"calling_window": {
"start": "<string>",
"end": "<string>",
"days": []
},
"retry_policy": {}
}
'import requests
url = "https://api.example.com/v1/campaigns"
payload = {
"name": "<string>",
"from_number_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"targets": [
{
"number": "<string>",
"variables": {},
"timezone": "<string>"
}
],
"agent_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"agents": [
{
"agent_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"weight": 50
}
],
"timezone": "<string>",
"calling_window": {
"start": "<string>",
"end": "<string>",
"days": []
},
"retry_policy": {}
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
name: '<string>',
from_number_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
targets: [{number: '<string>', variables: {}, timezone: '<string>'}],
agent_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
agents: [{agent_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a', weight: 50}],
timezone: '<string>',
calling_window: {start: '<string>', end: '<string>', days: []},
retry_policy: {}
})
};
fetch('https://api.example.com/v1/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.example.com/v1/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' => '<string>',
'from_number_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'targets' => [
[
'number' => '<string>',
'variables' => [
],
'timezone' => '<string>'
]
],
'agent_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'agents' => [
[
'agent_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'weight' => 50
]
],
'timezone' => '<string>',
'calling_window' => [
'start' => '<string>',
'end' => '<string>',
'days' => [
]
],
'retry_policy' => [
]
]),
CURLOPT_HTTPHEADER => [
"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.example.com/v1/campaigns"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"from_number_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"targets\": [\n {\n \"number\": \"<string>\",\n \"variables\": {},\n \"timezone\": \"<string>\"\n }\n ],\n \"agent_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"agents\": [\n {\n \"agent_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"weight\": 50\n }\n ],\n \"timezone\": \"<string>\",\n \"calling_window\": {\n \"start\": \"<string>\",\n \"end\": \"<string>\",\n \"days\": []\n },\n \"retry_policy\": {}\n}")
req, _ := http.NewRequest("POST", url, payload)
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.example.com/v1/campaigns")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"from_number_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"targets\": [\n {\n \"number\": \"<string>\",\n \"variables\": {},\n \"timezone\": \"<string>\"\n }\n ],\n \"agent_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"agents\": [\n {\n \"agent_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"weight\": 50\n }\n ],\n \"timezone\": \"<string>\",\n \"calling_window\": {\n \"start\": \"<string>\",\n \"end\": \"<string>\",\n \"days\": []\n },\n \"retry_policy\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/v1/campaigns")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"<string>\",\n \"from_number_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"targets\": [\n {\n \"number\": \"<string>\",\n \"variables\": {},\n \"timezone\": \"<string>\"\n }\n ],\n \"agent_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"agents\": [\n {\n \"agent_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"weight\": 50\n }\n ],\n \"timezone\": \"<string>\",\n \"calling_window\": {\n \"start\": \"<string>\",\n \"end\": \"<string>\",\n \"days\": []\n },\n \"retry_policy\": {}\n}"
response = http.request(request)
puts response.read_body{}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>",
"input": "<unknown>",
"ctx": {}
}
]
}Headers
Body
application/json
Required string length:
1 - 255Required array length:
1 - 10000 elementsShow child attributes
Show child attributes
Required array length:
2 - 10 elementsShow child attributes
Show child attributes
Local hours every target may be called in, read in the target's own zone.
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Response
Successful Response
The response is of type Response Create Campaign V1 Campaigns Post · object.
Was this page helpful?
⌘I
Create Campaign
curl --request POST \
--url https://api.example.com/v1/campaigns \
--header 'Content-Type: application/json' \
--data '
{
"name": "<string>",
"from_number_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"targets": [
{
"number": "<string>",
"variables": {},
"timezone": "<string>"
}
],
"agent_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"agents": [
{
"agent_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"weight": 50
}
],
"timezone": "<string>",
"calling_window": {
"start": "<string>",
"end": "<string>",
"days": []
},
"retry_policy": {}
}
'import requests
url = "https://api.example.com/v1/campaigns"
payload = {
"name": "<string>",
"from_number_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"targets": [
{
"number": "<string>",
"variables": {},
"timezone": "<string>"
}
],
"agent_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"agents": [
{
"agent_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"weight": 50
}
],
"timezone": "<string>",
"calling_window": {
"start": "<string>",
"end": "<string>",
"days": []
},
"retry_policy": {}
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
name: '<string>',
from_number_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
targets: [{number: '<string>', variables: {}, timezone: '<string>'}],
agent_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
agents: [{agent_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a', weight: 50}],
timezone: '<string>',
calling_window: {start: '<string>', end: '<string>', days: []},
retry_policy: {}
})
};
fetch('https://api.example.com/v1/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.example.com/v1/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' => '<string>',
'from_number_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'targets' => [
[
'number' => '<string>',
'variables' => [
],
'timezone' => '<string>'
]
],
'agent_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'agents' => [
[
'agent_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'weight' => 50
]
],
'timezone' => '<string>',
'calling_window' => [
'start' => '<string>',
'end' => '<string>',
'days' => [
]
],
'retry_policy' => [
]
]),
CURLOPT_HTTPHEADER => [
"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.example.com/v1/campaigns"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"from_number_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"targets\": [\n {\n \"number\": \"<string>\",\n \"variables\": {},\n \"timezone\": \"<string>\"\n }\n ],\n \"agent_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"agents\": [\n {\n \"agent_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"weight\": 50\n }\n ],\n \"timezone\": \"<string>\",\n \"calling_window\": {\n \"start\": \"<string>\",\n \"end\": \"<string>\",\n \"days\": []\n },\n \"retry_policy\": {}\n}")
req, _ := http.NewRequest("POST", url, payload)
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.example.com/v1/campaigns")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"from_number_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"targets\": [\n {\n \"number\": \"<string>\",\n \"variables\": {},\n \"timezone\": \"<string>\"\n }\n ],\n \"agent_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"agents\": [\n {\n \"agent_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"weight\": 50\n }\n ],\n \"timezone\": \"<string>\",\n \"calling_window\": {\n \"start\": \"<string>\",\n \"end\": \"<string>\",\n \"days\": []\n },\n \"retry_policy\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/v1/campaigns")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"<string>\",\n \"from_number_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"targets\": [\n {\n \"number\": \"<string>\",\n \"variables\": {},\n \"timezone\": \"<string>\"\n }\n ],\n \"agent_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"agents\": [\n {\n \"agent_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"weight\": 50\n }\n ],\n \"timezone\": \"<string>\",\n \"calling_window\": {\n \"start\": \"<string>\",\n \"end\": \"<string>\",\n \"days\": []\n },\n \"retry_policy\": {}\n}"
response = http.request(request)
puts response.read_body{}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>",
"input": "<unknown>",
"ctx": {}
}
]
}