Templates
Create, list, and import Meta-approved WhatsApp message templates
Templates
WhatsApp templates are required for initiating conversations outside the 24-hour messaging window. They must be submitted to Meta for approval before use.
List Templates
const { data } = await zernio.whatsapp.getWhatsAppTemplates({
query: { accountId: 'YOUR_ACCOUNT_ID' }
});
data.templates.forEach(t => console.log(`${t.name} (${t.status}) - ${t.language}`));response = client.whatsapp.get_whats_app_templates(
account_id='YOUR_ACCOUNT_ID'
)
for t in response.templates:
print(f"{t.name} ({t.status}) - {t.language}")curl "https://zernio.com/api/v1/whatsapp/templates?accountId=YOUR_ACCOUNT_ID" \
-H "Authorization: Bearer YOUR_API_KEY"Create a Template
const { data } = await zernio.whatsapp.createWhatsAppTemplate({
body: {
accountId: 'YOUR_ACCOUNT_ID',
name: 'order_confirmation',
category: 'UTILITY',
language: 'en',
components: [{ type: 'BODY', text: 'Hi {{1}}, your order {{2}} has been confirmed!' }]
}
});
console.log(`Template created: ${data.template.name} (${data.template.status})`);response = client.whatsapp.create_whats_app_template(
account_id='YOUR_ACCOUNT_ID',
name='order_confirmation',
category='UTILITY',
language='en',
components=[{'type': 'BODY', 'text': 'Hi {{1}}, your order {{2}} has been confirmed!'}]
)
print(f"Template created: {response.template.name} ({response.template.status})")curl -X POST https://zernio.com/api/v1/whatsapp/templates \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"accountId": "YOUR_ACCOUNT_ID",
"name": "order_confirmation",
"category": "UTILITY",
"language": "en",
"components": [{"type": "BODY", "text": "Hi {{1}}, your order {{2}} has been confirmed!"}]
}'Templates are reviewed by Meta and can take up to 24 hours to be approved. Only approved templates can be used for sending messages.
Import from the Template Library
Instead of writing a template, you can create one from Meta's pre-approved Template Library — these skip the review wait. Pass library_template_name instead of components.
Look the template up first to see its structure: a library template with URL or PHONE_NUMBER buttons requires a matching library_template_button_inputs array at create time (one entry per button, in order), or Meta rejects it with "give the same number of button inputs to match the library buttons." A library template usually exists in many languages — pass language to pick the right variant.
// 1. Look up the library template (to see its buttons + the exact language)
const { data: lib } = await zernio.whatsapp.getWhatsAppLibraryTemplate({
query: { accountId: 'YOUR_ACCOUNT_ID', name: 'account_creation_confirmation_3', language: 'en_US' }
});
// 2. Create it, supplying inputs for its URL / PHONE_NUMBER buttons
const { data } = await zernio.whatsapp.createWhatsAppTemplate({
body: {
accountId: 'YOUR_ACCOUNT_ID',
name: 'account_creation_confirmation_3',
category: 'UTILITY',
language: lib.template.language, // use the library template's actual code
library_template_name: 'account_creation_confirmation_3',
library_template_button_inputs: [
{ type: 'URL', url: { base_url: 'https://your-site.com/account', url_suffix_example: 'https://your-site.com/account' } }
]
}
});# 1. Look up the library template (to see its buttons + the exact language)
lib = client.whatsapp.get_whats_app_library_template(
account_id='YOUR_ACCOUNT_ID', name='account_creation_confirmation_3', language='en_US'
)
# 2. Create it, supplying inputs for its URL / PHONE_NUMBER buttons
response = client.whatsapp.create_whats_app_template(
account_id='YOUR_ACCOUNT_ID',
name='account_creation_confirmation_3',
category='UTILITY',
language=lib.template.language,
library_template_name='account_creation_confirmation_3',
library_template_button_inputs=[
{'type': 'URL', 'url': {'base_url': 'https://your-site.com/account', 'url_suffix_example': 'https://your-site.com/account'}}
]
)# 1. Look up the library template
curl "https://zernio.com/api/v1/whatsapp/template-library?accountId=YOUR_ACCOUNT_ID&name=account_creation_confirmation_3&language=en_US" \
-H "Authorization: Bearer YOUR_API_KEY"
# 2. Create it with button inputs
curl -X POST https://zernio.com/api/v1/whatsapp/templates \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"accountId": "YOUR_ACCOUNT_ID",
"name": "account_creation_confirmation_3",
"category": "UTILITY",
"language": "en_US",
"library_template_name": "account_creation_confirmation_3",
"library_template_button_inputs": [
{ "type": "URL", "url": { "base_url": "https://your-site.com/account", "url_suffix_example": "https://your-site.com/account" } }
]
}'