DevelopersSend a template message Browse docs

Send a template message

Send an approved WhatsApp template to a customer at any time — ideal for confirmations, updates and reminders.

Sends an approved template to a WhatsApp number. Templates can be sent at any time, even outside the 24-hour window, which makes this the endpoint for notifications such as order confirmations, delivery updates and appointment reminders.

POST/api/external/send-template

Request body

FieldTypeRequiredDescription
template_namestringYesThe exact name of an approved template, for example order_confirmation. It must be synced into Wazline for the token’s WhatsApp number.
tostringYesThe recipient’s number with country code, for example +971501234567. 971501234567 and 00971501234567 work too.
paramsarray of stringsIf the template has variablesValues for the template’s variables, in order: the first fills {{1}}, the second {{2}}, and so on. Each value must be non-empty.
{
  "template_name": "order_confirmation",
  "to": "+971501234567",
  "params": ["Sara", "#4821", "AED 249"]
}

Examples

curl -X POST "https://YOUR_WORKSPACE_DOMAIN/api/external/send-template" \
  -H "Authorization: Bearer $WAZLINE_TOKEN" \
  -H "Origin: https://yourstore.com" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -d '{
    "template_name": "order_confirmation",
    "to": "+971501234567",
    "params": ["Sara", "#4821", "AED 249"]
  }'
// Node.js 18 or later
const res = await fetch('https://YOUR_WORKSPACE_DOMAIN/api/external/send-template', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.WAZLINE_TOKEN}`,
    Origin: 'https://yourstore.com',
    'Content-Type': 'application/json',
    Accept: 'application/json',
  },
  body: JSON.stringify({
    template_name: 'order_confirmation',
    to: '+971501234567',
    params: ['Sara', '#4821', 'AED 249'],
  }),
});

const data = await res.json();
if (!data.success) {
  console.error(res.status, data.error_code, data.message);
}
<?php
$ch = curl_init('https://YOUR_WORKSPACE_DOMAIN/api/external/send-template');
curl_setopt_array($ch, [
    CURLOPT_POST => true,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer ' . getenv('WAZLINE_TOKEN'),
        'Origin: https://yourstore.com',
        'Content-Type: application/json',
        'Accept: application/json',
    ],
    CURLOPT_POSTFIELDS => json_encode([
        'template_name' => 'order_confirmation',
        'to' => '+971501234567',
        'params' => ['Sara', '#4821', 'AED 249'],
    ]),
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
import os
import requests

res = requests.post(
    "https://YOUR_WORKSPACE_DOMAIN/api/external/send-template",
    headers={
        "Authorization": f"Bearer {os.environ['WAZLINE_TOKEN']}",
        "Origin": "https://yourstore.com",
        "Accept": "application/json",
    },
    json={
        "template_name": "order_confirmation",
        "to": "+971501234567",
        "params": ["Sara", "#4821", "AED 249"],
    },
    timeout=15,
)
print(res.status_code, res.json())

Response

A 200 response means WhatsApp accepted the message for delivery.

{
  "success": true,
  "message_id": 18342,
  "wa_message_id": "wamid.HBgMOTcxNTAxMjM0NTY3FQIAERgS..."
}
FieldDescription
successtrue when the message was sent
message_idThe message’s ID in Wazline
wa_message_idWhatsApp’s ID for the message

Errors

Statuserror_codeWhat to do
404template_not_foundCheck the name, that the template is approved, and that it’s synced into Wazline for this number.
422params_mismatchSend one non-empty value for every variable in the template.
422invalid_numberInclude the country code. The message explains the problem and shows an example.
422invalid_payloadA required field is missing or has the wrong type.
502send_failedWhatsApp rejected the send. Check the template and number, then try again.

Authentication and rate-limit errors are covered in Errors & rate limits.

Notes

  • Templates with an image header are sent with your workspace’s default header image.
  • When the customer replies, the chat appears in New Customers in the Team Inbox for an agent to pick up.
  • A request to this endpoint with body and no template_name is handled as a text message.
Still have questions?

Our team is happy to walk you through Wazline and help you set up your workspace.

Contact us