Example: send a template
Send an order update template with body variables.
Use this flow when you need to notify a customer outside the 24-hour reply window.
1. Confirm the template exists
List approved templates:
curl -sS "https://api.wazapin.com/v1/templates?limit=20" \
-H "X-Api-Key: YOUR_API_KEY"import { WazapinClient } from "@wazapin/sdk";
const wazapin = new WazapinClient({ apiKey: process.env.WAZAPIN_API_KEY! });
const { data } = await wazapin.templates.list({ limit: 20 });
console.log(data);import requests
response = requests.get(
"https://api.wazapin.com/v1/templates",
headers={"X-Api-Key": "YOUR_API_KEY"},
params={"limit": 20},
timeout=30,
)
response.raise_for_status()
print(response.json())Pick name and language from the response. The template must be approved on your channel.
2. Send with components
Template order_shipped with body Hi {{1}}, order {{2}} shipped.
curl -X POST "https://api.wazapin.com/v1/messages" \
-H "X-Api-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"channel_id": "wzp_abc123",
"to": "6281234567890",
"type": "template",
"content": {
"template": {
"name": "order_shipped",
"language": { "code": "en_US" },
"components": [
{
"type": "body",
"parameters": [
{ "type": "text", "text": "John" },
{ "type": "text", "text": "ORD-42" }
]
}
]
}
}
}'import { WazapinClient, templateMessage } from "@wazapin/sdk";
const wazapin = new WazapinClient({ apiKey: process.env.WAZAPIN_API_KEY! });
await wazapin.messages.send(
templateMessage({
channel_id: "wzp_abc123",
to: "6281234567890",
name: "order_shipped",
language: "en_US",
components: [
{
type: "body",
parameters: [
{ type: "text", text: "John" },
{ type: "text", text: "ORD-42" },
],
},
],
}),
);import requests
response = requests.post(
"https://api.wazapin.com/v1/messages",
headers={"X-Api-Key": "YOUR_API_KEY", "Content-Type": "application/json"},
json={
"channel_id": "wzp_abc123",
"to": "6281234567890",
"type": "template",
"content": {
"template": {
"name": "order_shipped",
"language": {"code": "en_US"},
"components": [
{
"type": "body",
"parameters": [
{"type": "text", "text": "John"},
{"type": "text", "text": "ORD-42"},
],
}
],
}
},
},
timeout=30,
)
response.raise_for_status()
print(response.json())If your template has a header image or URL button, add the matching header / button components — see Send template.
3. Check delivery
curl -sS "https://api.wazapin.com/v1/messages/{messageID}" \
-H "X-Api-Key: YOUR_API_KEY"import { WazapinClient } from "@wazapin/sdk";
const wazapin = new WazapinClient({ apiKey: process.env.WAZAPIN_API_KEY! });
const { data: message } = await wazapin.messages.get("{messageID}");
console.log(message.status);import requests
response = requests.get(
"https://api.wazapin.com/v1/messages/{messageID}",
headers={"X-Api-Key": "YOUR_API_KEY"},
timeout=30,
)
response.raise_for_status()
print(response.json())Or configure a webhook for message.status_update events.
Unofficial channels
On unofficial (gateway) channels, template sends may render as fallback text. See Channel support.