Overview
The Templates API allows you to list, retrieve, and send template messages programmatically. Templates are pre-approved message formats for proactive communication across different channels.Sending a template as part of a conversation?
Channels.whatsapp.sendTemplate is the canonical way to send a WhatsApp template to a specific user — it resolves the recipient by userId or phone number and records the send to the conversation thread, so your agent remembers the outreach. Use the Templates.whatsapp.send below for bulk / campaign sends by channel ID and a list of phone numbers. Both are supported; pick by use case.Supported Template Types
WhatsApp Templates
Pre-approved message formats for WhatsApp Business Accounts. Required for initiating conversations outside the 24-hour messaging window.
Additional template types may be added in the future. The API is designed to work consistently across different template types.
Quick Start
Template Listing
List and search templates with pagination
Template Retrieval
Get template details including components
Batch Sending
Send to multiple recipients at once
Dynamic Values
Fill template parameters dynamically
WhatsApp Templates
UseTemplates.whatsapp for WhatsApp Business templates.
list()
List WhatsApp templates for a channel with optional pagination and search.The WhatsApp channel identifier
Optional pagination and search options
Page number (1-indexed)
Items per page
Search query to filter templates by name
get()
Retrieve a specific WhatsApp template by ID.The WhatsApp channel identifier
The template identifier
WhatsAppTemplate object
Example:
send()
Send a WhatsApp template message to one or more phone numbers.The WhatsApp channel identifier
The template identifier
Send data including recipients and template values
Array of recipients. For WhatsApp: phone numbers in E.164 format (e.g., +447551166594)
Template parameter values
Header component parameter values. For media headers, use
image_url (IMAGE format), video_url (VIDEO format), or document_url + optional document_filename (DOCUMENT format).Body component parameter values
Array of button parameter values. Each entry has
sub_type ('QUICK_REPLY' | 'URL' | 'PHONE_NUMBER' | 'COPY_CODE'), index, and optional text or coupon_code.Template Structure
WhatsApp Templates
WhatsApp templates have the following structure:Template structure may vary by template type. The above shows the WhatsApp template structure.
Media Headers
WhatsApp templates support media headers in addition to text headers. Headers can contain an image, video, or document:- IMAGE: Static image (
format: 'IMAGE') - VIDEO: Playable video clip (
format: 'VIDEO') - DOCUMENT: Downloadable document like a PDF (
format: 'DOCUMENT')
format— one of'IMAGE','VIDEO', or'DOCUMENT'mediaUrl— a publicly-reachable HTTPS URL to a sample file for approval. This URL must:- Be accessible over HTTPS
- Match the format’s MIME type requirements:
- IMAGE:
.jpg,.png,.webp - VIDEO:
.mp4,.3gp - DOCUMENT:
.pdf,.docx,.xlsx,.pptx(up to 10 MB)
- IMAGE:
- Be within Meta’s size limits (images ≤ 5 MB, videos ≤ 16 MB, documents ≤ 10 MB)
Templates.whatsapp.send() API, you provide the actual media URL in the values.header object:
image_urlfor IMAGE format templatesvideo_urlfor VIDEO format templatesdocument_url(and optionallydocument_filename) for DOCUMENT format templates
Template Parameters
Templates use named parameters in the format{{parameter_name}}. When sending, provide values for each parameter:
WhatsApp Examples
The following examples demonstrate using the Templates API with WhatsApp templates.Order Confirmation Tool
Webhook: Send Welcome Template on New User
List Templates Tool
Use Cases (WhatsApp)
Transactional Notifications
Marketing Campaigns
Authentication / OTP
Tracking Delivery Status
After sending template messages, you can track whether they were delivered, read, or failed using webhook event subscriptions.Setup
- Create a webhook to handle delivery events
- Subscribe it to the status events you care about
Example: Campaign Analytics
The
messageId returned by Templates.whatsapp.send() corresponds to messageWamid in the status event payload, allowing you to correlate sends with delivery outcomes.Best Practices
Handle Batch Send Results
Handle Batch Send Results
When sending to multiple recipients, always check for partial failures:
Validate Phone Numbers
Validate Phone Numbers
Use E.164 format for phone numbers:
Check Template Status
Check Template Status
Only send approved templates:
Match Parameter Names Exactly
Match Parameter Names Exactly
Parameter names in
values must match template parameters exactly:TypeScript Types
Next Steps
User API
Send messages to users
Jobs API
Schedule template sends

