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.
List templates
Section titled “List templates”/channels/{channelId}/templates Get all templates for a channel. Use filters to find specific templates by status, category, or language.
Path parameters
Section titled “Path parameters”channelId string Required 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"// Node.js 18 or later (built-in fetch)const response = await fetch('https://app.dutiesbook.com/api/external/v1/channels/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/templates', { method: 'GET', headers: { 'X-Account-Id': process.env.DUTIES_ACCOUNT_ID, 'X-Api-Key': process.env.DUTIES_API_KEY, 'X-Secret-Key': process.env.DUTIES_SECRET_KEY, },});
const result = await response.json();import osimport requests
response = requests.get( "https://app.dutiesbook.com/api/external/v1/channels/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/templates", headers={ "X-Account-Id": os.environ["DUTIES_ACCOUNT_ID"], "X-Api-Key": os.environ["DUTIES_API_KEY"], "X-Secret-Key": os.environ["DUTIES_SECRET_KEY"], },)
result = response.json(){ "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 template
Section titled “Get template”/channels/{channelId}/templates/{templateId} Get details for a specific template including all components, variables, and quality score.
Path parameters
Section titled “Path parameters”channelId string Required templateId string Required 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"// Node.js 18 or later (built-in fetch)const response = await fetch('https://app.dutiesbook.com/api/external/v1/channels/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/templates/template_123', { method: 'GET', headers: { 'X-Account-Id': process.env.DUTIES_ACCOUNT_ID, 'X-Api-Key': process.env.DUTIES_API_KEY, 'X-Secret-Key': process.env.DUTIES_SECRET_KEY, },});
const result = await response.json();import osimport requests
response = requests.get( "https://app.dutiesbook.com/api/external/v1/channels/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/templates/template_123", headers={ "X-Account-Id": os.environ["DUTIES_ACCOUNT_ID"], "X-Api-Key": os.environ["DUTIES_API_KEY"], "X-Secret-Key": os.environ["DUTIES_SECRET_KEY"], },)
result = response.json(){ "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": {} }}Template components
Section titled “Template components”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.
Variables format
Section titled “Variables format”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.
Errors
Section titled “Errors”RES_001 404 The specified channel was not found or you don't have access to it.
RES_002 404 The specified template was not found on this channel.
AUTH_008 403 This API key is restricted to specific channels and does not have access to this channel.
BIZ_002 422 The template exists but is not approved for use. Only APPROVED templates can be used to send messages.
BIZ_003 422 The template has been disabled locally in your organization settings.