API
Anmelden
Dokumentation › Nachrichten › WhatsApp-Vorlage senden (Meta)
POST

WhatsApp-Vorlage senden (Meta)

POSThttps://app.sendapp.ai/api/whatsapp-meta/send
Senden Sie eine genehmigte Vorlage über die WhatsApp Cloud API von Meta (type=template). Vorlagen dienen dazu, ein Gespräch zu beginnen oder dem Kunden außerhalb des 24-Stunden-Fensters zu schreiben.
Die Vorlage muss bereits von Meta genehmigt sein. Siehe Vorlage erstellen, um eine zu erstellen. Die Textvariablen ({{1}}, {{2}}…) werden über das Array components befüllt.
Parameter
apikey erforderlich
Ihr API Key.
token erforderlich
Konto-Token.
number erforderlich
Empfängernummer im internationalen Format ohne + (z. B. 1234567890).
type erforderlich
Muss template sein.
template.name erforderlich
Genauer Name der genehmigten Vorlage.
template.language.code erforderlich
Sprachcode der Vorlage (z. B. it, en_US).
template.components optional
Werte für die Variablen der Vorlage (body, header, Schaltflächen). Weglassen, wenn die Vorlage keine Variablen hat.
Anfrage
# Vorlage ohne Variablen
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" }
    }
  }'

# Vorlage mit Variablen {{1}} und {{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());
Antwort (200 OK)
{
  "status": "success",
  "message": "Message sent successfully",
  "message_id": "wamid.HBgLMzkxMjM0NTY3ODkwFQIAERgSN0EwMjBBQkZDRDEyMzQ1Njc4"
}
Fehler
{
  "status": "error",
  "message": "The template parameters do not match the approved template."
}