Documentação ›
Mensagens › Enviar template WhatsApp (Meta)
POST
Enviar template WhatsApp (Meta)
POSThttps://app.sendapp.ai/api/whatsapp-meta/send
Envie um template aprovado através da WhatsApp Cloud API da Meta (
type=template). Os templates servem para iniciar uma conversa ou escrever ao cliente fora da janela de 24 horas. O template deve estar já aprovado pela Meta. Veja Criar template para criar um. As variáveis do texto (
{{1}}, {{2}}…) são preenchidas com o array components.Parâmetros
apikey
obrigatório
A tua API Key.
token
obrigatório
Token da conta.
number
obrigatório
Número do destinatário em formato internacional sem + (ex. 1234567890).
type
obrigatório
Deve ser
template.
template.name
obrigatório
Nome exato do template aprovado.
template.language.code
obrigatório
Código de idioma do template (ex.
it, en_US).
template.components
opcional
Valores das variáveis do template (body, header, botões). Omita se o template não tiver variáveis.
Pedido
# Template sem variáveis
curl -X POST 'https://app.sendapp.ai/api/whatsapp-meta/send' \
-H 'Content-Type: application/json' \
-d '{
"apikey": "YOUR_API_KEY",
"token": "YOUR_ACCOUNT_TOKEN",
"number": "1234567890",
"type": "template",
"template": {
"name": "hello_world",
"language": { "code": "en_US" }
}
}'
# Template com variáveis {{1}} e {{2}}
curl -X POST 'https://app.sendapp.ai/api/whatsapp-meta/send' \
-H 'Content-Type: application/json' \
-d '{
"apikey": "YOUR_API_KEY",
"token": "YOUR_ACCOUNT_TOKEN",
"number": "1234567890",
"type": "template",
"template": {
"name": "promo_sconto",
"language": { "code": "it" },
"components": [
{
"type": "body",
"parameters": [
{ "type": "text", "text": "Mario" },
{ "type": "text", "text": "20" }
]
}
]
}
}'<?php
$ch = curl_init('https://app.sendapp.ai/api/whatsapp-meta/send');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => ['Content-Type: application/json'],
CURLOPT_POSTFIELDS => json_encode([
'apikey' => 'YOUR_API_KEY',
'token' => 'YOUR_ACCOUNT_TOKEN',
'number' => '1234567890',
'type' => 'template',
'template' => [
'name' => 'promo_sconto',
'language' => ['code' => 'it'],
'components' => [[
'type' => 'body',
'parameters' => [
['type' => 'text', 'text' => 'Mario'],
['type' => 'text', 'text' => '20'],
],
]],
],
]),
]);
echo curl_exec($ch);const res = await fetch('https://app.sendapp.ai/api/whatsapp-meta/send', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
apikey: 'YOUR_API_KEY',
token: 'YOUR_ACCOUNT_TOKEN',
number: '1234567890',
type: 'template',
template: {
name: 'promo_sconto',
language: { code: 'it' },
components: [{
type: 'body',
parameters: [
{ type: 'text', text: 'Mario' },
{ type: 'text', text: '20' }
]
}]
}
})
});
console.log(await res.json());Resposta (200 OK)
{
"status": "success",
"message": "Message sent successfully",
"message_id": "wamid.HBgLMzkxMjM0NTY3ODkwFQIAERgSN0EwMjBBQkZDRDEyMzQ1Njc4"
}Erro
{
"status": "error",
"message": "The template parameters do not match the approved template."
}