Skip to main content

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

Use Templates.whatsapp for WhatsApp Business templates.

list()

List WhatsApp templates for a channel with optional pagination and search.
channelId
string
required
The WhatsApp channel identifier
options
object
Optional pagination and search options
options.page
number
default:1
Page number (1-indexed)
options.limit
number
default:10
Items per page
Search query to filter templates by name
Returns:
Examples:

get()

Retrieve a specific WhatsApp template by ID.
channelId
string
required
The WhatsApp channel identifier
templateId
string
required
The template identifier
Returns: WhatsAppTemplate object Example:

send()

Send a WhatsApp template message to one or more phone numbers.
channelId
string
required
The WhatsApp channel identifier
templateId
string
required
The template identifier
data
object
required
Send data including recipients and template values
data.phoneNumbers
string[]
required
Array of recipients. For WhatsApp: phone numbers in E.164 format (e.g., +447551166594)
data.values
object
Template parameter values
data.values.header
object
Header component parameter values. For media headers, use image_url (IMAGE format), video_url (VIDEO format), or document_url + optional document_filename (DOCUMENT format).
data.values.body
object
Body component parameter values
data.values.buttons
SendTemplateButtonValue[]
Array of button parameter values. Each entry has sub_type ('QUICK_REPLY' | 'URL' | 'PHONE_NUMBER' | 'COPY_CODE'), index, and optional text or coupon_code.
Returns:
Examples:

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')
When creating a template with a media header, you provide:
  • 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)
    • Be within Meta’s size limits (images ≤ 5 MB, videos ≤ 16 MB, documents ≤ 10 MB)
Once the template is approved, when you send it via the Templates.whatsapp.send() API, you provide the actual media URL in the values.header object:
  • image_url for IMAGE format templates
  • video_url for VIDEO format templates
  • document_url (and optionally document_filename) for DOCUMENT format templates
The media URL provided at send time must also be publicly reachable over HTTPS.

Template Parameters

Templates use named parameters in the format {{parameter_name}}. When sending, provide values for each parameter:
All required parameters must be provided when sending a template. Missing parameters will cause the send to fail.

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

  1. Create a webhook to handle delivery events
  2. Subscribe it to the status events you care about

Example: Campaign Analytics

After sending a batch of templates, your webhook receives individual status updates for each recipient as messages are sent, delivered, and read. Use this data to measure open rates, delivery rates, and catch failures.
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

When sending to multiple recipients, always check for partial failures:
Use E.164 format for phone numbers:
Only send approved templates:
Parameter names in values must match template parameters exactly:

TypeScript Types

Next Steps

User API

Send messages to users

Jobs API

Schedule template sends