Send a template
templateMessage() builds the nested wire shape the API expects — content.template.name, content.template.language.code, and content.template.components.
import { templateMessage } from "@wazapin/sdk";
await wazapin.messages.send(
templateMessage({
channel_id: "wzp_ch_123",
to: "6281234567890",
name: "order_confirmation",
language: "en_US",
components: [
{
type: "body",
parameters: [{ type: "text", text: "Order #123" }],
},
],
}),
);Equivalent JSON body:
{
"channel_id": "wzp_ch_123",
"to": "6281234567890",
"type": "template",
"content": {
"template": {
"name": "order_confirmation",
"language": { "code": "en_US" },
"components": [
{
"type": "body",
"parameters": [{ "type": "text", "text": "Order #123" }]
}
]
}
}
}List templates
const { data: page } = await wazapin.templates.list({ limit: 50 });
for (const template of page.items) {
console.log(template.id);
}Get one template
const template = await wazapin.templates.get("tpl_123");Sync templates
await wazapin.templates.sync();