Skip to content

Templates

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

Retrieve all templates for your account.

Terminal window
GET /api/templates
ParameterTypeDescription
pageintegerPage number (default: 1)
limitintegerItems per page (default: 20)
accountstringFilter by WhatsApp account name
statusstringFilter by status (APPROVED, PENDING, REJECTED, DRAFT, etc.)
categorystringFilter by category (MARKETING, UTILITY, AUTHENTICATION)
searchstringSearch template name or display name (case-insensitive)
{
"status": "success",
"data": {
"templates": [
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"whatsapp_account": "default_account",
"meta_template_id": "123456789012345",
"name": "order_confirmation",
"display_name": "Order Confirmation",
"language": "en",
"category": "UTILITY",
"status": "APPROVED",
"header_type": "IMAGE",
"header_content": "440e8400-e29b-41d4-a716-446655440000",
"body_content": "Hi {{1}}, your order #{{2}} has been confirmed!",
"footer_content": "Thank you for shopping with us",
"buttons": [
{
"type": "URL",
"text": "Track Order",
"url": "https://example.com/track/{{1}}"
}
],
"sample_values": [
"John",
"12345"
],
"add_security_recommendation": false,
"code_expiration_minutes": 0,
"quality_rating": "GREEN",
"created_by_name": "Admin User",
"updated_by_name": "Admin User",
"created_at": "2024-01-01T00:00:00Z",
"updated_at": "2024-01-01T00:00:00Z"
}
],
"total": 50,
"page": 1,
"limit": 20
}
}

Retrieve a single template by ID.

Terminal window
GET /api/templates/{id}
{
"status": "success",
"data": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"whatsapp_account": "default_account",
"meta_template_id": "123456789012345",
"name": "order_confirmation",
"display_name": "Order Confirmation",
"language": "en",
"category": "UTILITY",
"status": "APPROVED",
"header_type": "IMAGE",
"header_content": "440e8400-e29b-41d4-a716-446655440000",
"body_content": "Hi {{1}}, your order #{{2}} has been confirmed!",
"footer_content": "Thank you for shopping with us",
"buttons": [
{
"type": "URL",
"text": "Track Order",
"url": "https://example.com/track/{{1}}"
}
],
"sample_values": [
"John",
"12345"
],
"add_security_recommendation": false,
"code_expiration_minutes": 0,
"quality_rating": "GREEN",
"created_by_name": "Admin User",
"updated_by_name": "Admin User",
"created_at": "2024-01-01T00:00:00Z",
"updated_at": "2024-01-01T00:00:00Z"
}
}

Create a new local draft template. Note that fields are flat rather than nested under components.

Terminal window
POST /api/templates
FieldTypeRequiredDescription
whatsapp_accountstringYesWhatsApp account name
namestringYesTemplate API name (lowercase, alphanumeric, and underscores only)
display_namestringNoUser-friendly template name (defaults to name)
languagestringYesLanguage code (e.g. en, es)
categorystringYesMARKETING, UTILITY, or AUTHENTICATION
header_typestringNoTEXT, IMAGE, VIDEO, DOCUMENT, or NONE (default: NONE)
header_contentstringNoHeader text, or media handle (from the upload-media API)
body_contentstringYes*Message body. Supports variables ({{1}}, {{2}}). Required unless AUTHENTICATION.
footer_contentstringNoFooter text
buttonsarrayNoTemplate buttons array
sample_valuesarrayNoSample values for body and header variables
add_security_recommendationbooleanNoAUTHENTICATION category only: appends Meta security disclaimer
code_expiration_minutesintegerNoAUTHENTICATION category only: expiration time in minutes (1-90)
{
"whatsapp_account": "default_account",
"name": "welcome_message",
"display_name": "Welcome Message",
"language": "en",
"category": "MARKETING",
"header_type": "TEXT",
"header_content": "Welcome to {{1}}!",
"body_content": "Welcome to our store, {{1}}! Use code {{2}} for 10% off your first order.",
"footer_content": "Reply STOP to unsubscribe",
"buttons": [
{
"type": "QUICK_REPLY",
"text": "Unsubscribe"
}
],
"sample_values": [
"CloudWA",
"John",
"WELCOME10"
]
}

Returns the fully created TemplateResponse object with status DRAFT.

{
"status": "success",
"data": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"whatsapp_account": "default_account",
"meta_template_id": "",
"name": "welcome_message",
"display_name": "Welcome Message",
"language": "en",
"category": "MARKETING",
"status": "DRAFT",
"header_type": "TEXT",
"header_content": "Welcome to {{1}}!",
"body_content": "Welcome to our store, {{1}}! Use code {{2}} for 10% off your first order.",
"footer_content": "Reply STOP to unsubscribe",
"buttons": [
{
"type": "QUICK_REPLY",
"text": "Unsubscribe"
}
],
"sample_values": [
"CloudWA",
"John",
"WELCOME10"
],
"add_security_recommendation": false,
"code_expiration_minutes": 0,
"quality_rating": "UNKNOWN",
"created_at": "2024-01-01T12:00:00Z",
"updated_at": "2024-01-01T12:00:00Z"
}
}

Update an existing draft template.

Terminal window
PUT /api/templates/{id}

Same structure as template creation.

Delete a template locally and request deletion from Meta if already published.

Terminal window
DELETE /api/templates/{id}
{
"status": "success",
"data": {
"message": "Template deleted successfully"
}
}

Upload a media file (image, video, document) for use as a template header sample value. This endpoint returns a handle string that you must pass into header_content during template creation.

This endpoint accepts multipart/form-data.

Terminal window
POST /api/templates/upload-media
ParameterTypeRequiredDescription
filefile binaryYesThe sample media file to upload
accountstringYesWhatsApp account name (can be passed as a query param or form value)
{
"status": "success",
"data": {
"handle": "440e8400-e29b-41d4-a716-446655440000",
"filename": "sample_invoice.pdf",
"mime_type": "application/pdf",
"size": 12345
}
}

Submit a local DRAFT template to Meta for approval, or publish update revisions to Meta.

Terminal window
POST /api/templates/{id}/publish
{
"status": "success",
"data": {
"message": "Template submitted to Meta for approval",
"meta_template_id": "123456789012345",
"status": "PENDING",
"template": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"whatsapp_account": "default_account",
"meta_template_id": "123456789012345",
"name": "welcome_message",
"status": "PENDING",
"created_at": "2024-01-01T12:00:00Z",
"updated_at": "2024-01-01T12:05:00Z"
}
}
}

Sync templates from Meta’s API to your local CloudWA database.

Terminal window
POST /api/templates/sync
{
"whatsapp_account": "default_account"
}
{
"status": "success",
"data": {
"message": "Synced 25 templates",
"count": 25
}
}