Definir la audiencia de una campaña 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>"
}
}Campañas
Definir la audiencia de una campaña de WhatsApp
Define a quién va una campaña de WhatsApp en borrador, oficial o no oficial: todos los clientes o hasta 20 segmentos (quien está en más de uno la recibe una sola vez), menos los clientes de hasta 20 segmentos excluidos. Cada llamada define la audiencia entera, exclusiones incluidas. Solo cambian los borradores; no se envía nada. Requiere una clave API con el alcance write.
POST
/
v1
/
whatsapp-campaigns
/
{campaign_id}
/
audience
Definir la audiencia de una campaña 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>"
}
}Autorizaciones
Encabezados
Parámetros de ruta
Cuerpo
application/json
Segmentos que quedan fuera, hasta 20: quien esté en alguno de ellos no recibe la campaña, aunque todos los clientes o un segmento incluido lo tengan. Un segmento incluido y excluido a la vez queda excluido. Omítelo o envía [] para no excluir a nadie.
Maximum array length:
20Pattern:
^seg_[A-Za-z0-9_-]+$