Definir a audiência de uma campanha de WhatsApp
curl --request POST \
--url https://api.bevits.com/v1/whatsapp-campaigns/{campaign_id}/audience \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"audience": "everyone",
"excluded_segment_ids": [
"seg_2d9c4e1a7b"
]
}
'import requests
url = "https://api.bevits.com/v1/whatsapp-campaigns/{campaign_id}/audience"
payload = {
"audience": "everyone",
"excluded_segment_ids": ["seg_2d9c4e1a7b"]
}
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({audience: 'everyone', excluded_segment_ids: ['seg_2d9c4e1a7b']})
};
fetch('https://api.bevits.com/v1/whatsapp-campaigns/{campaign_id}/audience', 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.bevits.com/v1/whatsapp-campaigns/{campaign_id}/audience",
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([
'audience' => 'everyone',
'excluded_segment_ids' => [
'seg_2d9c4e1a7b'
]
]),
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.bevits.com/v1/whatsapp-campaigns/{campaign_id}/audience"
payload := strings.NewReader("{\n \"audience\": \"everyone\",\n \"excluded_segment_ids\": [\n \"seg_2d9c4e1a7b\"\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.bevits.com/v1/whatsapp-campaigns/{campaign_id}/audience")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"audience\": \"everyone\",\n \"excluded_segment_ids\": [\n \"seg_2d9c4e1a7b\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.bevits.com/v1/whatsapp-campaigns/{campaign_id}/audience")
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 \"audience\": \"everyone\",\n \"excluded_segment_ids\": [\n \"seg_2d9c4e1a7b\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"object": "whatsapp_campaign_write",
"campaign": {
"object": "template_campaign",
"id": "<string>",
"status": "<string>",
"channel": "whatsapp",
"is_official": true,
"scheduling_type": "<string>",
"recipient_type": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"name": "<string>",
"scheduled_for": "2023-11-07T05:31:56Z",
"sent_at": "2023-11-07T05:31:56Z",
"templates": [
{
"id": "<string>",
"order": 1,
"weight": 2,
"name": "<string>",
"category": "<string>",
"language": "<string>",
"status": "<string>"
}
],
"metrics": {
"recipients": 1,
"sent": 1,
"delivered": 1,
"read": 1,
"failed": 1
},
"html_url": "<string>"
},
"pending": [
"<string>"
],
"next_step": "<string>"
}{
"error": {
"type": "authentication_error",
"message": "<string>",
"request_id": "<string>",
"code": "<string>",
"param": "<string>",
"suggestion": "<string>"
}
}{
"error": {
"type": "authentication_error",
"message": "Invalid API key.",
"request_id": "req_07f6cdc3c20249d6afcd90b4"
}
}{
"error": {
"type": "permission_denied",
"code": "missing_scope",
"message": "This API key does not have the required \"write\" scope.",
"param": "scope",
"request_id": "req_07f6cdc3c20249d6afcd90b4"
}
}{
"error": {
"type": "authentication_error",
"message": "<string>",
"request_id": "<string>",
"code": "<string>",
"param": "<string>",
"suggestion": "<string>"
}
}{
"error": {
"type": "authentication_error",
"message": "<string>",
"request_id": "<string>",
"code": "<string>",
"param": "<string>",
"suggestion": "<string>"
}
}{
"error": {
"type": "validation_error",
"message": "Invalid query parameters.",
"param": "limit",
"request_id": "req_07f6cdc3c20249d6afcd90b4"
}
}{
"error": {
"type": "authentication_error",
"message": "<string>",
"request_id": "<string>",
"code": "<string>",
"param": "<string>",
"suggestion": "<string>"
},
"retry_after": 2
}{
"error": {
"type": "authentication_error",
"message": "<string>",
"request_id": "<string>",
"code": "<string>",
"param": "<string>",
"suggestion": "<string>"
}
}Campanhas
Definir a audiência de uma campanha de WhatsApp
Define para quem uma campanha de WhatsApp em rascunho, oficial ou não oficial, vai: todos os clientes ou até 20 segmentos (quem está em mais de um recebe uma vez só), menos os clientes de até 20 segmentos excluídos. Cada chamada define a audiência inteira, inclusive as exclusões. Só rascunhos mudam; nada é enviado. Exige uma API key com o escopo write.
POST
/
v1
/
whatsapp-campaigns
/
{campaign_id}
/
audience
Definir a audiência de uma campanha de WhatsApp
curl --request POST \
--url https://api.bevits.com/v1/whatsapp-campaigns/{campaign_id}/audience \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"audience": "everyone",
"excluded_segment_ids": [
"seg_2d9c4e1a7b"
]
}
'import requests
url = "https://api.bevits.com/v1/whatsapp-campaigns/{campaign_id}/audience"
payload = {
"audience": "everyone",
"excluded_segment_ids": ["seg_2d9c4e1a7b"]
}
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({audience: 'everyone', excluded_segment_ids: ['seg_2d9c4e1a7b']})
};
fetch('https://api.bevits.com/v1/whatsapp-campaigns/{campaign_id}/audience', 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.bevits.com/v1/whatsapp-campaigns/{campaign_id}/audience",
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([
'audience' => 'everyone',
'excluded_segment_ids' => [
'seg_2d9c4e1a7b'
]
]),
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.bevits.com/v1/whatsapp-campaigns/{campaign_id}/audience"
payload := strings.NewReader("{\n \"audience\": \"everyone\",\n \"excluded_segment_ids\": [\n \"seg_2d9c4e1a7b\"\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.bevits.com/v1/whatsapp-campaigns/{campaign_id}/audience")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"audience\": \"everyone\",\n \"excluded_segment_ids\": [\n \"seg_2d9c4e1a7b\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.bevits.com/v1/whatsapp-campaigns/{campaign_id}/audience")
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 \"audience\": \"everyone\",\n \"excluded_segment_ids\": [\n \"seg_2d9c4e1a7b\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"object": "whatsapp_campaign_write",
"campaign": {
"object": "template_campaign",
"id": "<string>",
"status": "<string>",
"channel": "whatsapp",
"is_official": true,
"scheduling_type": "<string>",
"recipient_type": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"name": "<string>",
"scheduled_for": "2023-11-07T05:31:56Z",
"sent_at": "2023-11-07T05:31:56Z",
"templates": [
{
"id": "<string>",
"order": 1,
"weight": 2,
"name": "<string>",
"category": "<string>",
"language": "<string>",
"status": "<string>"
}
],
"metrics": {
"recipients": 1,
"sent": 1,
"delivered": 1,
"read": 1,
"failed": 1
},
"html_url": "<string>"
},
"pending": [
"<string>"
],
"next_step": "<string>"
}{
"error": {
"type": "authentication_error",
"message": "<string>",
"request_id": "<string>",
"code": "<string>",
"param": "<string>",
"suggestion": "<string>"
}
}{
"error": {
"type": "authentication_error",
"message": "Invalid API key.",
"request_id": "req_07f6cdc3c20249d6afcd90b4"
}
}{
"error": {
"type": "permission_denied",
"code": "missing_scope",
"message": "This API key does not have the required \"write\" scope.",
"param": "scope",
"request_id": "req_07f6cdc3c20249d6afcd90b4"
}
}{
"error": {
"type": "authentication_error",
"message": "<string>",
"request_id": "<string>",
"code": "<string>",
"param": "<string>",
"suggestion": "<string>"
}
}{
"error": {
"type": "authentication_error",
"message": "<string>",
"request_id": "<string>",
"code": "<string>",
"param": "<string>",
"suggestion": "<string>"
}
}{
"error": {
"type": "validation_error",
"message": "Invalid query parameters.",
"param": "limit",
"request_id": "req_07f6cdc3c20249d6afcd90b4"
}
}{
"error": {
"type": "authentication_error",
"message": "<string>",
"request_id": "<string>",
"code": "<string>",
"param": "<string>",
"suggestion": "<string>"
},
"retry_after": 2
}{
"error": {
"type": "authentication_error",
"message": "<string>",
"request_id": "<string>",
"code": "<string>",
"param": "<string>",
"suggestion": "<string>"
}
}Cabeçalhos
Parâmetros de caminho
Corpo
application/json
Segmentos que ficam de fora, até 20: quem estiver em algum deles não recebe a campanha, mesmo que todos os clientes ou um segmento incluído o tenham. Um segmento incluído e excluído ao mesmo tempo fica excluído. Omita ou envie [] para não excluir ninguém.
Maximum array length:
20Pattern:
^seg_[A-Za-z0-9_-]+$