Criar segmento por engajamento em campanha
curl --request POST \
--url https://api.bevits.com/v1/segments/campaign-engagement \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "Black Friday: leram ou clicaram, sem compra em novembro",
"campaign_ids": [
"tcp_8f2k1m",
"tcp_3j9x0a"
],
"engagement": "engaged",
"purchases": "none",
"purchases_from": "2026-11-01T00:00:00-03:00"
}
'import requests
url = "https://api.bevits.com/v1/segments/campaign-engagement"
payload = {
"name": "Black Friday: leram ou clicaram, sem compra em novembro",
"campaign_ids": ["tcp_8f2k1m", "tcp_3j9x0a"],
"engagement": "engaged",
"purchases": "none",
"purchases_from": "2026-11-01T00:00:00-03:00"
}
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: leram ou clicaram, sem compra em novembro',
campaign_ids: ['tcp_8f2k1m', 'tcp_3j9x0a'],
engagement: 'engaged',
purchases: 'none',
purchases_from: '2026-11-01T00:00:00-03:00'
})
};
fetch('https://api.bevits.com/v1/segments/campaign-engagement', 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/segments/campaign-engagement",
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: leram ou clicaram, sem compra em novembro',
'campaign_ids' => [
'tcp_8f2k1m',
'tcp_3j9x0a'
],
'engagement' => 'engaged',
'purchases' => 'none',
'purchases_from' => '2026-11-01T00:00:00-03:00'
]),
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/segments/campaign-engagement"
payload := strings.NewReader("{\n \"name\": \"Black Friday: leram ou clicaram, sem compra em novembro\",\n \"campaign_ids\": [\n \"tcp_8f2k1m\",\n \"tcp_3j9x0a\"\n ],\n \"engagement\": \"engaged\",\n \"purchases\": \"none\",\n \"purchases_from\": \"2026-11-01T00:00:00-03:00\"\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/segments/campaign-engagement")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"Black Friday: leram ou clicaram, sem compra em novembro\",\n \"campaign_ids\": [\n \"tcp_8f2k1m\",\n \"tcp_3j9x0a\"\n ],\n \"engagement\": \"engaged\",\n \"purchases\": \"none\",\n \"purchases_from\": \"2026-11-01T00:00:00-03:00\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.bevits.com/v1/segments/campaign-engagement")
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: leram ou clicaram, sem compra em novembro\",\n \"campaign_ids\": [\n \"tcp_8f2k1m\",\n \"tcp_3j9x0a\"\n ],\n \"engagement\": \"engaged\",\n \"purchases\": \"none\",\n \"purchases_from\": \"2026-11-01T00:00:00-03:00\"\n}"
response = http.request(request)
puts response.read_body{
"object": "campaign_engagement_segment",
"segment": {
"object": "segment",
"id": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"html_url": "<string>",
"name": "<string>",
"description": "<string>",
"type": "static",
"match": "all",
"conditions": [
{
"kind": "field",
"field": "<string>",
"operator": "<string>",
"value": "<string>",
"value_to": "<string>"
}
],
"customer_count": 1
},
"customers_added": 1,
"reachable_count": 1,
"breakdown": {
"engaged": 1,
"not_engaged": 1,
"not_received": 1
},
"snapshot_at": "2023-11-07T05:31:56Z",
"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": "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>"
}
}Referência
Criar segmento por engajamento em campanha
Salva os clientes da prévia, com os mesmos critérios, como um novo segmento pronto para ser escolhido como público de uma campanha. Quem interagiu fica congelado no momento da criação; o período de compras é conferido de novo a cada envio, então quem comprar depois sai do público. Nada é enviado. Se o nome já estiver em uso, a Bevits acrescenta um número ao final. Exige uma API key com o escopo write.
POST
/
v1
/
segments
/
campaign-engagement
Criar segmento por engajamento em campanha
curl --request POST \
--url https://api.bevits.com/v1/segments/campaign-engagement \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "Black Friday: leram ou clicaram, sem compra em novembro",
"campaign_ids": [
"tcp_8f2k1m",
"tcp_3j9x0a"
],
"engagement": "engaged",
"purchases": "none",
"purchases_from": "2026-11-01T00:00:00-03:00"
}
'import requests
url = "https://api.bevits.com/v1/segments/campaign-engagement"
payload = {
"name": "Black Friday: leram ou clicaram, sem compra em novembro",
"campaign_ids": ["tcp_8f2k1m", "tcp_3j9x0a"],
"engagement": "engaged",
"purchases": "none",
"purchases_from": "2026-11-01T00:00:00-03:00"
}
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: leram ou clicaram, sem compra em novembro',
campaign_ids: ['tcp_8f2k1m', 'tcp_3j9x0a'],
engagement: 'engaged',
purchases: 'none',
purchases_from: '2026-11-01T00:00:00-03:00'
})
};
fetch('https://api.bevits.com/v1/segments/campaign-engagement', 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/segments/campaign-engagement",
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: leram ou clicaram, sem compra em novembro',
'campaign_ids' => [
'tcp_8f2k1m',
'tcp_3j9x0a'
],
'engagement' => 'engaged',
'purchases' => 'none',
'purchases_from' => '2026-11-01T00:00:00-03:00'
]),
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/segments/campaign-engagement"
payload := strings.NewReader("{\n \"name\": \"Black Friday: leram ou clicaram, sem compra em novembro\",\n \"campaign_ids\": [\n \"tcp_8f2k1m\",\n \"tcp_3j9x0a\"\n ],\n \"engagement\": \"engaged\",\n \"purchases\": \"none\",\n \"purchases_from\": \"2026-11-01T00:00:00-03:00\"\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/segments/campaign-engagement")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"Black Friday: leram ou clicaram, sem compra em novembro\",\n \"campaign_ids\": [\n \"tcp_8f2k1m\",\n \"tcp_3j9x0a\"\n ],\n \"engagement\": \"engaged\",\n \"purchases\": \"none\",\n \"purchases_from\": \"2026-11-01T00:00:00-03:00\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.bevits.com/v1/segments/campaign-engagement")
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: leram ou clicaram, sem compra em novembro\",\n \"campaign_ids\": [\n \"tcp_8f2k1m\",\n \"tcp_3j9x0a\"\n ],\n \"engagement\": \"engaged\",\n \"purchases\": \"none\",\n \"purchases_from\": \"2026-11-01T00:00:00-03:00\"\n}"
response = http.request(request)
puts response.read_body{
"object": "campaign_engagement_segment",
"segment": {
"object": "segment",
"id": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"html_url": "<string>",
"name": "<string>",
"description": "<string>",
"type": "static",
"match": "all",
"conditions": [
{
"kind": "field",
"field": "<string>",
"operator": "<string>",
"value": "<string>",
"value_to": "<string>"
}
],
"customer_count": 1
},
"customers_added": 1,
"reachable_count": 1,
"breakdown": {
"engaged": 1,
"not_engaged": 1,
"not_received": 1
},
"snapshot_at": "2023-11-07T05:31:56Z",
"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": "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
Corpo
application/json
Resposta
Segmento por engajamento criado.