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.
string
required
The WhatsApp channel identifier
object
Optional pagination and search options
number
default:1
Page number (1-indexed)
number
default:10
Items per page
Search query to filter templates by name
Returns:
Examples:

get()

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

send()

Send a WhatsApp template message to one or more phone numbers.
string
required
The WhatsApp channel identifier
string
required
The template identifier
object
required
Send data including recipients and template values
string[]
required
Array of recipients. For WhatsApp: phone numbers in E.164 format (e.g., +447551166594)
object
Template parameter values
object
Header component parameter values. For media headers, either use image_url (IMAGE format), video_url (VIDEO format), or document_url + optional document_filename (DOCUMENT format) — or pass a Meta media ID instead via image_id, video_id, or document_id. A media ID takes precedence if both are given.
object
Body component parameter values
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.

Sending by media ID instead of URL

WhatsApp re-downloads the URL on every send. For bulk campaigns you can upload the asset to Meta once and reuse the returned media ID across every recipient, which skips that per-send fetch entirely:
Use image_id, video_id, or document_id to match the template’s header format. document_filename still applies. If you pass both a media ID and a URL, the media ID wins.
Three constraints decide whether a media ID resolves at send time:
  • Upload it via POST /{phone-number-id}/media. The Resumable Upload API (POST /{app-id}/uploads) returns an h:... file handle instead, which is only valid for creating a template — it will never work as a send-time media ID.
  • Media IDs are scoped to the business phone number they were uploaded on. That must be the phone number behind the channel you’re sending from, or Meta won’t resolve the ID.
  • Meta expires media IDs after 30 days. Plan on re-uploading per campaign rather than once forever.

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