curl --request POST \
--url https://api.ararahq.com/v1/messages/batch \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"templateName": "pedido_confirmado",
"messages": [
{
"receiver": "+5511999999999",
"templateVariables": [
"João",
"1"
]
},
{
"receiver": "+5511888888888",
"templateVariables": [
"Maria",
"2"
]
}
]
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
templateName: 'pedido_confirmado',
messages: [
{receiver: '+5511999999999', templateVariables: ['João', '1']},
{receiver: '+5511888888888', templateVariables: ['Maria', '2']}
]
})
};
fetch('https://api.ararahq.com/v1/messages/batch', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.ararahq.com/v1/messages/batch"
payload = {
"templateName": "pedido_confirmado",
"messages": [
{
"receiver": "+5511999999999",
"templateVariables": ["João", "1"]
},
{
"receiver": "+5511888888888",
"templateVariables": ["Maria", "2"]
}
]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.ararahq.com/v1/messages/batch",
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([
'templateName' => 'pedido_confirmado',
'messages' => [
[
'receiver' => '+5511999999999',
'templateVariables' => [
'João',
'1'
]
],
[
'receiver' => '+5511888888888',
'templateVariables' => [
'Maria',
'2'
]
]
]
]),
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;
}{
"batchId": "ara_msg_b7C1d2E",
"templateName": "pedido_confirmado",
"total": 2,
"accepted": 2,
"totalCost": 0.136,
"messages": [
{
"id": "ara_msg_a1B2c3D",
"receiver": "whatsapp:+5511999999999",
"status": "PENDING",
"cost": 0.068
},
{
"id": "ara_msg_e4F5g6H",
"receiver": "whatsapp:+5511888888888",
"status": "PENDING",
"cost": 0.068
}
]
}Enviar lote de mensagens
Envia o mesmo template para até 1.000 destinatários em uma chamada. Para mais que isso, use Campanhas.
O lote é tudo ou nada: um telefone inválido ou saldo insuficiente recusa o
lote inteiro com 422 UNPROCESSABLE_ENTITY.
Com Idempotency-Key, repetir a chamada devolve o lote original sem
reenviar. Acompanhe o lote em GET /v1/messages?batchId=.
Permissão: MESSAGES_SEND.
curl --request POST \
--url https://api.ararahq.com/v1/messages/batch \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"templateName": "pedido_confirmado",
"messages": [
{
"receiver": "+5511999999999",
"templateVariables": [
"João",
"1"
]
},
{
"receiver": "+5511888888888",
"templateVariables": [
"Maria",
"2"
]
}
]
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
templateName: 'pedido_confirmado',
messages: [
{receiver: '+5511999999999', templateVariables: ['João', '1']},
{receiver: '+5511888888888', templateVariables: ['Maria', '2']}
]
})
};
fetch('https://api.ararahq.com/v1/messages/batch', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.ararahq.com/v1/messages/batch"
payload = {
"templateName": "pedido_confirmado",
"messages": [
{
"receiver": "+5511999999999",
"templateVariables": ["João", "1"]
},
{
"receiver": "+5511888888888",
"templateVariables": ["Maria", "2"]
}
]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.ararahq.com/v1/messages/batch",
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([
'templateName' => 'pedido_confirmado',
'messages' => [
[
'receiver' => '+5511999999999',
'templateVariables' => [
'João',
'1'
]
],
[
'receiver' => '+5511888888888',
'templateVariables' => [
'Maria',
'2'
]
]
]
]),
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;
}{
"batchId": "ara_msg_b7C1d2E",
"templateName": "pedido_confirmado",
"total": 2,
"accepted": 2,
"totalCost": 0.136,
"messages": [
{
"id": "ara_msg_a1B2c3D",
"receiver": "whatsapp:+5511999999999",
"status": "PENDING",
"cost": 0.068
},
{
"id": "ara_msg_e4F5g6H",
"receiver": "whatsapp:+5511888888888",
"status": "PENDING",
"cost": 0.068
}
]
}Authorizations
Chave de API da Arara (ara_live_...), enviada no header Authorization: Bearer ara_live_.... Crie e gerencie as chaves no painel: https://app.ararahq.com/dashboard/apikeys. O valor completo aparece uma única vez, na criação.
Headers
Chave de idempotência, de 1 a 255 caracteres, sem caracteres de controle (fora disso: 400 INVALID_IDEMPOTENCY_KEY). Derive de um evento do seu sistema (id do pedido, id da tentativa) e reuse a mesma chave nas retentativas.
255Body
Response
Lote aceito