Skip to content

Templates

Overview

WhatsApp Message Templates are pre-approved message formats required for sending business-initiated messages. Templates must be approved by Meta before use.

List Templates

Retrieve all templates for your account.

Terminal window
GET /api/templates

Query Parameters

ParameterTypeDescription
pageintegerPage number (default: 1)
limitintegerItems per page (default: 20)
statusstringFilter by status (APPROVED, PENDING, REJECTED)
categorystringFilter by category (MARKETING, UTILITY, AUTHENTICATION)
account_idstringFilter by WhatsApp account

Response

{
"status": "success",
"data": {
"items": [
{
"id": "uuid",
"name": "order_confirmation",
"language": "en",
"status": "APPROVED",
"category": "UTILITY",
"components": [...],
"created_at": "2024-01-01T00:00:00Z"
}
],
"total": 50,
"page": 1,
"limit": 20
}
}

Get Template

Retrieve a single template by ID.

Terminal window
GET /api/templates/{id}

Response

{
"status": "success",
"data": {
"id": "uuid",
"name": "order_confirmation",
"language": "en",
"status": "APPROVED",
"category": "UTILITY",
"components": [
{
"type": "HEADER",
"format": "IMAGE"
},
{
"type": "BODY",
"text": "Hi {{1}}, your order #{{2}} has been confirmed!"
},
{
"type": "FOOTER",
"text": "Thank you for shopping with us"
},
{
"type": "BUTTONS",
"buttons": [
{
"type": "URL",
"text": "Track Order",
"url": "https://example.com/track/{{1}}"
}
]
}
]
}
}

Create Template

Create a new template (submitted to Meta for approval).

Terminal window
POST /api/templates

Request Body

{
"account_id": "uuid",
"name": "welcome_message",
"language": "en",
"category": "MARKETING",
"components": [
{
"type": "BODY",
"text": "Welcome to our store, {{1}}! Use code {{2}} for 10% off your first order."
},
{
"type": "FOOTER",
"text": "Reply STOP to unsubscribe"
}
]
}

Response

{
"status": "success",
"data": {
"id": "uuid",
"name": "welcome_message",
"status": "PENDING",
"created_at": "2024-01-01T00:00:00Z"
}
}

Update Template

Update an existing template.

Terminal window
PUT /api/templates/{id}

Request Body

{
"components": [
{
"type": "BODY",
"text": "Welcome, {{1}}! Use code {{2}} for 15% off your first order."
}
]
}

Delete Template

Delete a template.

Terminal window
DELETE /api/templates/{id}

Sync Templates

Sync templates from Meta’s WhatsApp Business API.

Terminal window
POST /api/templates/sync

Request Body

{
"account_id": "uuid"
}

Response

{
"status": "success",
"data": {
"synced": 25,
"new": 3,
"updated": 5
}
}

Submit Template

Submit a template for Meta approval.

Terminal window
POST /api/templates/{id}/publish

Response

{
"status": "success",
"data": {
"id": "uuid",
"status": "PENDING"
}
}

Template Components

ComponentDescription
HEADEROptional header (text, image, video, or document)
BODYMain message content with variables
FOOTEROptional footer text
BUTTONSCall-to-action or quick reply buttons

Template Variables

Positional Parameters

Use {{1}}, {{2}}, etc. for dynamic content:

Hello {{1}}, your order #{{2}} is ready for pickup at {{3}}.

When creating templates with positional parameters, provide sample values:

{
"components": [
{
"type": "BODY",
"text": "Hello {{1}}, your order #{{2}} is ready!"
}
],
"sample_values": [
{ "component": "body", "index": 1, "value": "John" },
{ "component": "body", "index": 2, "value": "12345" }
]
}

Named Parameters

Templates also support named parameters for better readability:

Hello {{customer_name}}, your order #{{order_id}} is ready for pickup at {{store_location}}.

When using named parameters, provide sample values with param_name:

{
"parameter_format": "named",
"components": [
{
"type": "BODY",
"text": "Hello {{customer_name}}, your order #{{order_id}} is ready!"
}
],
"sample_values": [
{ "component": "body", "param_name": "customer_name", "value": "John" },
{ "component": "body", "param_name": "order_id", "value": "12345" }
]
}