Documentación ›
Mensajes › Enviar plantilla de WhatsApp (Meta)
POST
Enviar plantilla de WhatsApp (Meta)
POSThttps://app.sendapp.ai/api/whatsapp-meta/send
Envía una plantilla aprobada a través de la WhatsApp Cloud API de Meta (
type=template). Las plantillas sirven para iniciar una conversación o escribir al cliente fuera de la ventana de 24 horas. La plantilla debe estar ya aprobada por Meta. Consulta Crear plantilla para crear una. Las variables del texto (
{{1}}, {{2}}…) se rellenan con el array components.Parámetros
apikey
obligatorio
Tu API Key.
token
obligatorio
Token de la cuenta.
number
obligatorio
Número del destinatario en formato internacional sin + (p. ej. 1234567890).
type
obligatorio
Debe ser
template.
template.name
obligatorio
Nombre exacto de la plantilla aprobada.
template.language.code
obligatorio
Código de idioma de la plantilla (p. ej.
it, en_US).
template.components
opcional
Valores de las variables de la plantilla (body, header, botones). Omítelo si la plantilla no tiene variables.
Solicitud
# Plantilla sin variables
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" }
}
}'
# Plantilla con variables {{1}} y {{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());Respuesta (200 OK)
{
"status": "success",
"message": "Message sent successfully",
"message_id": "wamid.HBgLMzkxMjM0NTY3ODkwFQIAERgSN0EwMjBBQkZDRDEyMzQ1Njc4"
}Error
{
"status": "error",
"message": "The template parameters do not match the approved template."
}