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-templateRequest body
| Field | Type | Required | Description |
|---|---|---|---|
template_name | string | Yes | The exact name of an approved template, for example order_confirmation. It must be synced into Wazline for the token’s WhatsApp number. |
to | string | Yes | The recipient’s number with country code, for example +971501234567. 971501234567 and 00971501234567 work too. |
params | array of strings | If the template has variables | Values 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..."
}
| Field | Description |
|---|---|
success | true when the message was sent |
message_id | The message’s ID in Wazline |
wa_message_id | WhatsApp’s ID for the message |
Errors
| Status | error_code | What to do |
|---|---|---|
| 404 | template_not_found | Check the name, that the template is approved, and that it’s synced into Wazline for this number. |
| 422 | params_mismatch | Send one non-empty value for every variable in the template. |
| 422 | invalid_number | Include the country code. The message explains the problem and shows an example. |
| 422 | invalid_payload | A required field is missing or has the wrong type. |
| 502 | send_failed | WhatsApp 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
bodyand notemplate_nameis handled as a text message.
Still have questions?
Contact usOur team is happy to walk you through Wazline and help you set up your workspace.