Criar automações a partir de receitas
curl --request POST \
--url https://api.bevits.com/v1/recipe-deployments \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"recipes": [
{
"recipe": "cashback",
"params": {
"cashbackPercent": 10,
"validityDays": 30
}
},
{
"recipe": "abandoned-checkout"
}
],
"operation_id": "0d6f3c1e-5b7a-4c2e-9f10-6a8b4d2e7c91",
"validate_only": true
}
'import requests
url = "https://api.bevits.com/v1/recipe-deployments"
payload = {
"recipes": [{
"recipe": "cashback",
"params": {
"cashbackPercent": 10,
"validityDays": 30
}
}, { "recipe": "abandoned-checkout" }],
"operation_id": "0d6f3c1e-5b7a-4c2e-9f10-6a8b4d2e7c91",
"validate_only": True
}
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({
recipes: [
{recipe: 'cashback', params: {cashbackPercent: 10, validityDays: 30}},
{recipe: 'abandoned-checkout'}
],
operation_id: '0d6f3c1e-5b7a-4c2e-9f10-6a8b4d2e7c91',
validate_only: true
})
};
fetch('https://api.bevits.com/v1/recipe-deployments', 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/recipe-deployments",
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([
'recipes' => [
[
'recipe' => 'cashback',
'params' => [
'cashbackPercent' => 10,
'validityDays' => 30
]
],
[
'recipe' => 'abandoned-checkout'
]
],
'operation_id' => '0d6f3c1e-5b7a-4c2e-9f10-6a8b4d2e7c91',
'validate_only' => true
]),
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/recipe-deployments"
payload := strings.NewReader("{\n \"recipes\": [\n {\n \"recipe\": \"cashback\",\n \"params\": {\n \"cashbackPercent\": 10,\n \"validityDays\": 30\n }\n },\n {\n \"recipe\": \"abandoned-checkout\"\n }\n ],\n \"operation_id\": \"0d6f3c1e-5b7a-4c2e-9f10-6a8b4d2e7c91\",\n \"validate_only\": true\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/recipe-deployments")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"recipes\": [\n {\n \"recipe\": \"cashback\",\n \"params\": {\n \"cashbackPercent\": 10,\n \"validityDays\": 30\n }\n },\n {\n \"recipe\": \"abandoned-checkout\"\n }\n ],\n \"operation_id\": \"0d6f3c1e-5b7a-4c2e-9f10-6a8b4d2e7c91\",\n \"validate_only\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.bevits.com/v1/recipe-deployments")
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 \"recipes\": [\n {\n \"recipe\": \"cashback\",\n \"params\": {\n \"cashbackPercent\": 10,\n \"validityDays\": 30\n }\n },\n {\n \"recipe\": \"abandoned-checkout\"\n }\n ],\n \"operation_id\": \"0d6f3c1e-5b7a-4c2e-9f10-6a8b4d2e7c91\",\n \"validate_only\": true\n}"
response = http.request(request)
puts response.read_body{
"object": "recipe_deployment_result",
"validate_only": true,
"next_step": "<string>",
"plan": {
"platform": "nuvemshop",
"locale": "<string>",
"currency": "<string>",
"brand_name": "<string>",
"warnings": [
{
"code": "<string>",
"recipe": "<string>",
"segment_keys": [
"<string>"
]
}
],
"recipes": [
{
"recipe": "<string>",
"flow_name": "<string>",
"steps": [
{
"type": "<string>",
"detail": "<string>"
}
],
"emails": [
{
"key": "<string>",
"name": "<string>",
"subject": "<string>"
}
],
"whatsapp": [
{
"key": "<string>",
"name": "<string>",
"text": "<string>"
}
],
"campaign": {
"name": "<string>",
"segments": [
{
"id": "<string>",
"name": "<string>"
}
],
"missing_segment_keys": [
"<string>"
]
}
}
]
},
"deployment": {
"object": "recipe_deployment",
"id": "<string>",
"status": "applied",
"source": "<string>",
"summary": "<string>",
"items": [
{
"kind": "flow",
"id": "<string>",
"name": "<string>",
"recipe": "<string>",
"html_url": "<string>"
}
],
"created_at": "2023-11-07T05:31:56Z",
"rolled_back_at": "2023-11-07T05:31:56Z"
}
}{
"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 automações a partir de receitas
Com validate_only, devolve o plano sem gravar nada. Sem ele, cria os flows inativos, os e-mails e textos de WhatsApp e as campanhas em rascunho, e registra uma implantação que pode ser desfeita. Nada é enviado. Um operation_id repetido devolve a implantação já criada. Exige uma API key com o escopo write.
POST
/
v1
/
recipe-deployments
Criar automações a partir de receitas
curl --request POST \
--url https://api.bevits.com/v1/recipe-deployments \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"recipes": [
{
"recipe": "cashback",
"params": {
"cashbackPercent": 10,
"validityDays": 30
}
},
{
"recipe": "abandoned-checkout"
}
],
"operation_id": "0d6f3c1e-5b7a-4c2e-9f10-6a8b4d2e7c91",
"validate_only": true
}
'import requests
url = "https://api.bevits.com/v1/recipe-deployments"
payload = {
"recipes": [{
"recipe": "cashback",
"params": {
"cashbackPercent": 10,
"validityDays": 30
}
}, { "recipe": "abandoned-checkout" }],
"operation_id": "0d6f3c1e-5b7a-4c2e-9f10-6a8b4d2e7c91",
"validate_only": True
}
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({
recipes: [
{recipe: 'cashback', params: {cashbackPercent: 10, validityDays: 30}},
{recipe: 'abandoned-checkout'}
],
operation_id: '0d6f3c1e-5b7a-4c2e-9f10-6a8b4d2e7c91',
validate_only: true
})
};
fetch('https://api.bevits.com/v1/recipe-deployments', 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/recipe-deployments",
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([
'recipes' => [
[
'recipe' => 'cashback',
'params' => [
'cashbackPercent' => 10,
'validityDays' => 30
]
],
[
'recipe' => 'abandoned-checkout'
]
],
'operation_id' => '0d6f3c1e-5b7a-4c2e-9f10-6a8b4d2e7c91',
'validate_only' => true
]),
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/recipe-deployments"
payload := strings.NewReader("{\n \"recipes\": [\n {\n \"recipe\": \"cashback\",\n \"params\": {\n \"cashbackPercent\": 10,\n \"validityDays\": 30\n }\n },\n {\n \"recipe\": \"abandoned-checkout\"\n }\n ],\n \"operation_id\": \"0d6f3c1e-5b7a-4c2e-9f10-6a8b4d2e7c91\",\n \"validate_only\": true\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/recipe-deployments")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"recipes\": [\n {\n \"recipe\": \"cashback\",\n \"params\": {\n \"cashbackPercent\": 10,\n \"validityDays\": 30\n }\n },\n {\n \"recipe\": \"abandoned-checkout\"\n }\n ],\n \"operation_id\": \"0d6f3c1e-5b7a-4c2e-9f10-6a8b4d2e7c91\",\n \"validate_only\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.bevits.com/v1/recipe-deployments")
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 \"recipes\": [\n {\n \"recipe\": \"cashback\",\n \"params\": {\n \"cashbackPercent\": 10,\n \"validityDays\": 30\n }\n },\n {\n \"recipe\": \"abandoned-checkout\"\n }\n ],\n \"operation_id\": \"0d6f3c1e-5b7a-4c2e-9f10-6a8b4d2e7c91\",\n \"validate_only\": true\n}"
response = http.request(request)
puts response.read_body{
"object": "recipe_deployment_result",
"validate_only": true,
"next_step": "<string>",
"plan": {
"platform": "nuvemshop",
"locale": "<string>",
"currency": "<string>",
"brand_name": "<string>",
"warnings": [
{
"code": "<string>",
"recipe": "<string>",
"segment_keys": [
"<string>"
]
}
],
"recipes": [
{
"recipe": "<string>",
"flow_name": "<string>",
"steps": [
{
"type": "<string>",
"detail": "<string>"
}
],
"emails": [
{
"key": "<string>",
"name": "<string>",
"subject": "<string>"
}
],
"whatsapp": [
{
"key": "<string>",
"name": "<string>",
"text": "<string>"
}
],
"campaign": {
"name": "<string>",
"segments": [
{
"id": "<string>",
"name": "<string>"
}
],
"missing_segment_keys": [
"<string>"
]
}
}
]
},
"deployment": {
"object": "recipe_deployment",
"id": "<string>",
"status": "applied",
"source": "<string>",
"summary": "<string>",
"items": [
{
"kind": "flow",
"id": "<string>",
"name": "<string>",
"recipe": "<string>",
"html_url": "<string>"
}
],
"created_at": "2023-11-07T05:31:56Z",
"rolled_back_at": "2023-11-07T05:31:56Z"
}
}{
"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
Plano das receitas ou implantação criada.