Skip to content
DutiesBook API
Open app

Templates

WhatsApp requires pre-approved message templates for initiating conversations. Use these endpoints to discover and manage your available templates.

About templates

Templates are pre-approved message formats required by WhatsApp Business Platform. Each template has a unique name, language, category, and may include variables for personalization.

GET /channels/{channelId}/templates

Get all templates for a channel. Use filters to find specific templates by status, category, or language.

channelId string Required
Channel UUID
curl \
https://app.dutiesbook.com/api/external/v1/channels/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/templates \
-H "X-Account-Id: acc_xxxxxxxx" \
-H "X-Api-Key: pk_xxxxxxxxxxxxxxxx" \
-H "X-Secret-Key: sk_xxxxxxxxxxxxxxxx"
200 OK
{
"success": true,
"data": {
"templates": [
{
"id": "xxxxxxxxxxxx",
"name": "welcome_message",
"category": "MARKETING",
"language": "en_US",
"components": {
"header": {
"type": "text",
"text": "Welcome Header"
},
"body": {
"text": "Hello {{1}}, welcome to our service. Your account {{2}} is ready."
},
"footer": {
"text": "Thank you for joining us"
},
"buttons": [
{
"index": 0,
"type": "quick_reply",
"text": "Get Started"
}
]
},
"variables": {
"body": {
"1": "Sample 1",
"2": "Sample 2"
}
}
},
{
"id": "xxxxxxxxxxxx",
"name": "order_confirmation",
"category": "MARKETING",
"language": "en_US",
"components": {
"body": {
"text": "Your order has been confirmed."
}
},
"variables": {}
},
{
"id": "xxxxxxxxxxxx",
"name": "promotion_offer",
"category": "MARKETING",
"language": "en_US",
"components": {
"header": {
"type": "text",
"text": "Special Offer"
},
"body": {
"text": "Check out our latest offers and promotions."
},
"footer": {
"text": "Terms and conditions apply"
},
"buttons": [
{
"index": 0,
"type": "url",
"text": "View Offers",
"url": "https://example.com/offers"
},
{
"index": 1,
"type": "phone_number",
"text": "Contact Us",
"phoneNumber": "+xxxxxxxxxxx"
}
]
},
"variables": {}
}
],
"total": 3
}
}
GET /channels/{channelId}/templates/{templateId}

Get details for a specific template including all components, variables, and quality score.

channelId string Required
Channel UUID
templateId string Required
Template ID
curl \
https://app.dutiesbook.com/api/external/v1/channels/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/templates/template_123 \
-H "X-Account-Id: acc_xxxxxxxx" \
-H "X-Api-Key: pk_xxxxxxxxxxxxxxxx" \
-H "X-Secret-Key: sk_xxxxxxxxxxxxxxxx"
200 OK
{
"success": true,
"data": {
"id": "xxxxxxxxxxxx",
"name": "template_name",
"category": "MARKETING",
"language": "en_US",
"components": {
"header": {
"type": "text",
"text": "Header Text"
},
"body": {
"text": "Body text content"
},
"footer": {
"text": "Footer text"
},
"buttons": [
{
"index": 0,
"type": "quick_reply",
"text": "Button Text"
}
]
},
"variables": {}
}
}

Templates can have various component types that define the message structure.

HEADER

Top section - can be TEXT, IMAGE, VIDEO, or DOCUMENT format.

BODY

Main message content. Supports variables using {{n}} placeholders.

FOOTER

Bottom text section. Usually contains disclaimers or additional info.

BUTTONS

Interactive buttons - call-to-action URLs or quick reply options.

Variable placeholders

Variables in templates use {{n}} placeholders where n is the position number starting from 1.

Template text: Hello {{1}}, your order {{2}} is ready for pickup.

Variables to send:

{
"variables": {
"body": {
"1": "John",
"2": "#12345"
}
}
}

Result: Hello John, your order #12345 is ready for pickup.

RES_001 404
CHANNEL_NOT_FOUND

The specified channel was not found or you don't have access to it.

RES_002 404
TEMPLATE_NOT_FOUND

The specified template was not found on this channel.

AUTH_008 403
CHANNEL_ACCESS_DENIED

This API key is restricted to specific channels and does not have access to this channel.

BIZ_002 422
TEMPLATE_NOT_APPROVED

The template exists but is not approved for use. Only APPROVED templates can be used to send messages.

BIZ_003 422
TEMPLATE_DISABLED

The template has been disabled locally in your organization settings.