Create, update, list, and delete message templates on your WABA. Templates must be approved before use.
- GET /{WABA_ID}/message_templates?...
- POST /{WABA_ID}/message_templates
- GET /{TEMPLATE_ID}
- POST /{TEMPLATE_ID}
- DELETE /{WABA_ID}/message_templates?...
- Template requests use the WABA business account ID.
- Components define the template body, header, footer, and buttons.
- Updates are partial; pass only fields to change.
import WhatsApp from 'meta-cloud-api';
const client = new WhatsApp({
accessToken: process.env.CLOUD_API_ACCESS_TOKEN!,
phoneNumberId: Number(process.env.WA_PHONE_NUMBER_ID),
businessAcctId: process.env.WA_BUSINESS_ACCOUNT_ID!,
});
const templates = await client.templates.getTemplates({
name: 'order_update',
limit: 10,
});
const created = await client.templates.createTemplate({
name: 'welcome_message',
category: 'MARKETING',
language: 'en_US',
components: [
{ type: 'BODY', text: 'Hi {{1}}, welcome aboard!' },
],
});
await client.templates.updateTemplate(created.id, {
components: [
{ type: 'BODY', text: 'Hi {{1}}, thanks for joining!' },
],
});getTemplatescan filter bynameandlimitto page results.createTemplaterequiresname,category,language, andcomponentsto match the template format.updateTemplateuses the template ID and only the fields you want to change.