Get templates API will fetch the list of templates for a WhatsApp business account (WABA ID) specified in the HTTP GET request.
Filter templates : The API can filter results on the basis of parameters specified. E.g Template Category, Language, Status etc
Pagination : Control paginated response of the API using before, after and limit parameters.
https://<api_key>:<api_token><subdomain>/v2/accounts/<your_sid>/templates
<your_api_key>
and <your_api_token>
with the API key and token created by you.<your_sid>
with your “Account sid”<subdomain>
with the region of your account
<your_api_key>
, <your_api_token>
and <your_sid>
are available in the API settings page of your Exotel Dashboard
Listed below are the parameters for the GET API.
Parameter Name |
Type |
Mandatory/Optional |
Value/ Description |
waba_id |
String |
Mandatory |
WhatsApp Business Account (WABA) ID(s) enabled with Exotel. |
name |
String |
Optional |
Name of the template |
status |
[]String |
Optional |
Status of the template |
quality_score |
[]String |
Optional |
Quality score of the template |
language |
[]String |
Optional |
Language of the template |
fields |
[]String |
Optional |
Fields required in the response |
category |
[]String |
Optional |
Category of the template |
before |
String |
Optional |
Before cursor value in pagination (null if previous page has no value) |
after |
String |
Optional |
After cursor value in pagination (null if next page has no value) |
limit |
String |
Optional |
Number of templates per page |
curl --location -g --request GET 'https://<your_api_key>:<your_api_token><subdomain>/v1/Accounts/<your_sid>/templates?waba_id=<Your WABA ID>
var request = require('request'); var options = { 'method': 'GET', 'url': 'https://<your_api_key>:<your_api_token><subdomain>/v1/Accounts/<your_sid>/templates?waba_id=<Your WABA ID>&limit=50&fields=["language","name","rejected_reason","status","category","last_updated_time","components","quality_score"]', 'headers': { } }; request(options, function (error, response) { if (error) throw new Error(error); console.log(response.body); });
<?php $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => 'https://<your_api_key>:<your_api_token><subdomain>/v1/Accounts/<your_sid>/templates?waba_id=<Your WABA ID>&limit=50&fields=%5B%22language%22,%22name%22,%22rejected_reason%22,%22status%22,%22category%22,%22last_updated_time%22,%22components%22,%22quality_score%22%5D', CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'GET', )); $response = curl_exec($curl); curl_close($curl); echo $response;
import requests url = "https://<your_api_key>:<your_api_token><subdomain>/v1/Accounts/<your_sid>/templates?waba_id=<Your WABA ID>&limit=50&fields=[\"language\",\"name\",\"rejected_reason\",\"status\",\"category\",\"last_updated_time\",\"components\",\"quality_score\"]" payload={} headers = {} response = requests.request("GET", url, headers=headers, data=payload) print(response.text)
require "uri" require "net/http" url = URI("https://<your_api_key>:<your_api_token><subdomain>/v1/Accounts/<your_sid>/templates?waba_id=<Your WABA ID>&limit=50&fields=[\"language\",\"name\",\"rejected_reason\",\"status\",\"category\",\"last_updated_time\",\"components\",\"quality_score\"]") https = Net::HTTP.new(url.host, url.port) https.use_ssl = true request = Net::HTTP::Get.new(url) response = https.request(request) puts response.read_body
HTTP Response
{ "request_id": "0d678b1ff8764eac86ab9db787fd75a8", "method": "GET", "http_code": 200, "response": { "whatsapp": { "templates": [ { "code": 200, "error_data": null, "status": "success", "data": { "waba_id": "439507711055XXXX", "name": "hello_world_templatseqss", "components": [ { "type": "HEADER", "format": "TEXT", "text": "header-text {{1}}", "example": { "header_text": [ "header-example" ] } }, { "type": "BODY", "text": "body-text {{1}} {{2}} {{3}}", "example": { "body_text": [ [ "body-example-1", "body-example-2", "body-example-3" ] ] } }, { "type": "FOOTER", "text": "footer-text" }, { "type": "BUTTONS", "buttons": [ { "type": "URL", "text": "Pay Bill", "url": "https://my.example.com/acme/npay/{{1}}" }, { "type": "PHONE_NUMBER", "text": "test1", "phone_number": "+9199999XXXX" } ] } ], "language": "en", "status": "REJECTED", "category": "MARKETING", "id": "1164768064226960", "last_updated_time": "2023-03-01T05:54:40+0000", "rejected_reason": "INVALID_FORMAT", "quality_score": { "score": "UNKNOWN" } } }, { "code": 200, "error_data": null, "status": "success", "data": { "waba_id": "4395077110553913", "name": "pf_uae", "components": [ { "type": "BODY", "text": "Congratulations {1}, You have been selected" }, { "type": "FOOTER", "text": "Thanks" }, { "type": "BUTTONS", "buttons": [ { "type": "QUICK_REPLY", "text": "Call me" }, { "type": "QUICK_REPLY", "text": "Tell me more" }, { "type": "QUICK_REPLY", "text": "Um, will think about it!" } ] } ], "language": "en", "status": "APPROVED", "category": "MARKETING", "id": "735977928254860", "last_updated_time": "2023-02-28T13:43:03+0000", "rejected_reason": "NONE", "quality_score": { "score": "UNKNOWN" } } } "paging": { "after": "NDkZD", "before": null } } } }
{ "request_id": "0d678b1ff8764eac86ab9db787fd75a8", "method": "GET", "http_code": 200, "response": { "whatsapp": { "templates": [ { "code": 200, "error_data": null, "status": "success", "data": { "waba_id": "111491625171587", "name": "limited_time_offer_test", "components": [ { "type": "BODY", "text": "Good news, {{1}}! Use code {{2}} to get 25% off all Caribbean Destination packages!", "example": { "body_text": [ [ "Kaustubh", "SALE25" ] ] } }, { "type": "LIMITED_TIME_OFFER", "limited_time_offer": { "text": "Expiring offer!", "has_expiration": false } }, { "type": "BUTTONS", "buttons": [ { "type": "COPY_CODE", "text": "Copy offer code", "example": [ "SALE25" ] }, { "type": "URL", "text": "Book now!", "url": "https://awesomedestinations.com/offers?code={{1}}", "example": [ "https://awesomedestinations.com/offers?code=n3mtql" ] } ] } ], "language": "en", "status": "APPROVED", "category": "MARKETING", "id": "1118479766070031", "last_updated_time": "2024-05-13T06:30:44+0000", "rejected_reason": "NONE", "quality_score": { "score": "UNKNOWN" } } } "paging": { "after": "NDkZD", "before": null } } } },
Response parameters are described below:
HTTPResponseObject
Parameter |
Type |
Mandatory/ Optional |
Value/ Description |
request_id |
String |
Mandatory |
ID of the request |
method |
String |
Mandatory |
HTTP Request Method |
http_code |
Integer |
Mandatory |
HTTP Code of the request |
response |
ResponseObject |
Mandatory |
Response for the request |
ResponseObject
Parameter |
Type |
Mandatory/ Optional |
Value/ Description |
|
ChannelResponseObject |
Optional |
Channel Response for Whatsapp |
ChannelResponseObject
Parameter |
Type |
Mandatory/ Optional |
Value/ Description |
templates |
[]CreateTemplateResponseObject |
Optional |
Message Response |
paging |
PagingResponseObject |
Optional |
Paging response |
PagingResponseObject
Parameter |
Type |
Mandatory/ Optional |
Value/ Description |
before |
String |
Optional |
Before cursor |
after |
String |
Optional |
After cursor |
CreateTemplateResponseObject
Parameter |
Type |
Mandatory/ Optional |
Value/ Description |
code |
Integer |
Mandatory |
Response code for the message |
error_data |
ErrorResponseObject |
Optional |
Error related to message |
status |
String |
Mandatory |
Status of the message |
data |
TemplateResponseObject |
Optional |
Data for the message |
TemplateResponseObject
Parameter |
Type |
Mandatory/ Optional |
Values/ Description |
id |
String |
Mandatory |
id (Unique identifier) of the template |
name |
String |
Mandatory |
Name of the Template |
category |
String |
Mandatory |
Category of the template |
status |
String |
Mandatory |
Status of the template |
language |
String |
Mandatory |
Language of the template |
last_updated_time |
String |
Mandatory |
Time when the template was last updated. Eg: |
components |
[]ComponentObject |
Mandatory |
Components of the template |
API Error Codes
Status Code |
Value |
200 |
Status OK |
400 |
Bad Request - Something in your header or request body was malformed. |
401 |
Unauthorized - Necessary credentials were either missing or invalid. |
402 |
Payment Required - The action is not available on your plan, or you have exceeded usage limits for your current plan. |
403 |
Your credentials are valid, but you don’t have access to the requested resource. |
404 |
Not Found - The object you’re requesting doesn’t exist. |
5xx |
Server Errors - Something went wrong on our end. Please try again. |
Use the create templates API to create & submit templates to WhatsApp for approval. The API supports both single and bulk create.
https://<api_key>:<api_token><subdomain>/v2/accounts/<your_sid>/templates
<your_api_key>
and <your_api_token>
with the API key and token created by you.<your_sid>
with your “Account sid”<subdomain>
with the region of your account
<your_api_key>
, <your_api_token>
and <your_sid>
are available in the API settings page of your Exotel Dashboard
Listed below are the parameters for the POST API.
HTTPRequestObject
Parameter Name |
Type |
Mandatory/ Optional |
Value/ Description |
waba_id |
String |
Mandatory |
Waba ID |
Parameter Name |
Type |
Mandatory/ Optional |
Value/ Description |
custom_data |
String |
Optional |
If the client wants to send any custom data at the request level. This will be passed back to the customer in the callback. |
|
ChannelObject |
Optional |
Information related to the messages to be sent out on whatsapp |
ChannelObject
Parameter |
Type |
Mandatory |
Notes |
custom_data |
String |
Optional |
If the client wants to send any custom data at the channel level. This will be passed back to the customer in the callback. |
messages |
[]TemplateObject |
Mandatory |
Array of messages to be sent out |
TemplateObject
Parameter Name |
Type |
Mandatory |
Value/ Description |
custom_data |
String |
Optional |
If the client wants to send any custom data at the message level. This will be passed back to the customer in the callback. |
template |
WhatsappTemplateObject |
Mandatory |
Respective channel specific template body |
WhatsappTemplateObject
Parameter Name |
Type |
Mandatory/ Optional |
Value/ Description |
category |
String |
Mandatory |
Category of the template |
name |
String |
Mandatory |
Name of the template |
language |
String |
Mandatory |
Language of the template |
components |
[]ComponentObject |
Mandatory |
Components of the template |
ComponentObject
Parameter Name |
Type |
Mandatory/ Optional |
Value/ Description |
type |
String |
Mandatory |
Type of the component |
text |
String |
Mandatory/Optional |
Mandatory in case of type FOOTER/BODY/URL and TEXT HEADER |
format |
String |
Mandatory/Optional |
Mandatory in case of type HEADER |
buttons |
[]ButtonObject |
Mandatory/Optional |
Mandatory in case of type BUTTONS |
url |
String |
Mandatory/Optional |
Mandatory in case of type URL |
example |
ExampleObject |
Mandatory/Optional |
Mandatory in case of dynamic variables or media header |
example |
[]String |
Mandatory/Optional |
Mandatory in case of dynamic variables in type URL |
Parameter Name |
Type |
Mandatory/ Optional |
Values/ Description |
type |
String |
Optional |
Fallback value of datetime |
text |
Integer |
Optional |
Day of Week of datetime |
phone_number |
Integer |
Optional |
Day of month of datetime |
ExampleObject
Parameter Name |
Type |
Mandatory |
Value/ Description |
body_text |
[][]String |
Mandatory |
Type of the parameter |
header_text |
[]String |
Optional |
Text for the parameter |
header_handle |
[]String |
Optional |
Caption for the parameter |
curl --location --request POST 'https://<api_key>:<api_token><subdomain>/v2/accounts/<your_sid>/templates?waba_id=<Your WABA ID>' \ --header 'Content-Type: application/json' \ --data-raw '{ "whatsapp": { "templates": [ { "template": { "category": "TRANSACTIONAL", "components": [ { "type": "HEADER", "format": "TEXT", "text": "Greetings from Exotel {{1}}", "example": { "header_text": [ "John Doe" ] } }, { "type": "BODY", "text": "Hi {{1}}, your one time password is {{2}}.", "example": { "body_text": [ [ "John", "1234" ] ] } }, { "type": "FOOTER", "text": "Thanks" } ], "name": "test_template4605", "language": "en" } } ] } }'
var https = require('follow-redirects').https; var fs = require('fs'); var options = { 'method': 'POST', 'hostname': '<Sub domain>', 'path': '/v2/accounts/<Your SID>/templates?waba_id=<Your WABA ID', 'headers': { 'Content-Type': 'application/json' }, 'maxRedirects': 20 }; var req = https.request(options, function (res) { varchunks= []; res.on("data", function (chunk) { chunks.push(chunk); }); res.on("end", function (chunk) { varbody=Buffer.concat(chunks); console.log(body.toString()); }); res.on("error", function (error) { console.error(error); }); }); var postData = "{\n \"whatsapp\": {\n \"templates\": [\n {\n \"template\": {\n \"category\": \"TRANSACTIONAL\",\n \"components\": [\n {\n \"type\": \"HEADER\",\n \"format\": \"TEXT\",\n \"text\": \"Greetings from Exotel {{1}}\",\n \"example\": {\n \"header_text\": [\n \"John Doe\"\n ]\n }\n },\n {\n \"type\": \"BODY\",\n \"text\": \"Hi {{1}}, your one time password is {{2}}.\",\n \"example\": {\n \"body_text\": [\n [\n \"John\",\n \"1234\"\n ]\n ]\n }\n },\n {\n \"type\": \"FOOTER\",\n \"text\": \"Thanks\"\n }\n ],\n \"name\": \"test_template4605\",\n \"language\": \"en\"\n }\n },\n \n \n }\n}";
This section describes limited-time offer templates and how to create them.
This document describes carousel templates and how to use them. Carousel templates allow you to send a single text message accompanied by a set of up to 10 carousel cards in a horizontally scrollable view:
This is an example request to create a limited-time offer template that uses:
curl --location --globoff 'https://{{AuthKey}}:{{AuthToken}}@{{SubDomain}}/v2/accounts/{{AccountSid}}/templates?waba_id=XXXX' \ --header 'Content-Type: application/json' \ --data '{ "whatsapp": { "templates": [ { "template": { "name": "freshlemons", "language": "en", "category": "MARKETING", "components": [ { "type": "BODY", "text": "Summer is here, and we have the freshest produce around! Use code {{1}} to get off your next order.", "example": { "body_text": [ [ "10OFF" ] ] } }, { "type": "CAROUSEL", "cards": [ { "components": [ { "type": "HEADER", "format": "IMAGE", "example": { "header_handle": [ "4::aW1hZ2UvanBlZw==:ARZhLHkWRwgoZRYbxSIxQIdstWiwO5FHUkBDI3ooXC-IGD9M_D5hvl3B8PQagOQNGB-rjsYGU8iL6_0kXgnowUWwyhP7bt8YVZfFdB2wtNDKrw:e:1707639843:3157993617821787:100032495207268:ARYY2kQwqaawGbzDgcg" ] } }, { "type": "BODY", "text": "Fresh lemons for unique drinks. Use code {{1}} to get off all produce. Rare lemons for unique drinks.", "example": { "body_text": [ [ "10OFF" ] ] } }, { "type": "BUTTONS", "buttons": [ { "type": "QUICK_REPLY", "text": "Send more like this" }, { "type": "URL", "text": "Buy now", "url": "https://www.luckyshrub.com/shop?promo={{1}}", "example": [ "https://www.luckyshrub.com/shop?promo=summer_lemons_2023" ] } ] } ] }, { "components": [ { "type": "HEADER", "format": "IMAGE", "example": { "header_handle": [ "4::aW1hZ2UvanBlZw==:ARbm6XvaVpVMwQQMNt0xFZ5tNgludWS9WOAkrAuL7ki7wbHbqatwGARYrYtvzDoLiZn7nHeU4VqUMpF6RlVdMw8UoQThdl5FI6OsHxxG-AL9EA:e:1707640228:3157993617821787:100032495207268:ARaGMPetuhoCIQfYU8I" ] } }, { "type": "BODY", "text": "Exotic fruit for unique cocktails! Use code {{1}} to get off all exotic produce.", "example": { "body_text": [ [ "20FRUITS" ] ] } }, { "type": "BUTTONS", "buttons": [ { "type": "QUICK_REPLY", "text": "Send more like this" }, { "type": "URL", "text": "Buy now", "url": "https://www.luckyshrub.com/shop?promo={{1}}", "example": [ "https://www.luckyshrub.com/shop?promo=exotic_produce_2023" ] } ] } ] } ] } ] } } ] } }'
Placeholder | Description | Example Value |
---|---|---|
String |
Required. Message bubble text string. Supports variables. Maximum 1024 characters. |
|
Array of strings |
Required if the message bubble text string uses variables. Array of example variable strings. Number of strings must match the number of variables included in the string. |
|
String |
Required. Card body text. Support variables. Maximum 160 characters. |
|
Array of strings |
Required if using card body text with variables. Card body text example variables. |
|
Enum |
Required. Card media header format. Must be |
|
Media asset handle |
Required. Uploaded media asset handle. Use the Resumable Upload API to generate an asset handle. See Carousel Cards for media asset requirements. |
|
String |
Required if using a quick reply button. Quick reply button label text. Maximum 25 characters. |
|
Enum |
Required. Must be |
|
Enum |
Required. Template language and locale code. |
|
String |
Required. Template name. Maximum 512 characters. |
|
String |
Required if using a URL button. URL button label text. Supports 1 variable. 25 characters maximum. |
|
String |
Required if using a URL button. URL of website that loads in the device's default mobile web browser when the URL button is tapped by the app user. Supports 1 variable, appended to the end of the URL string. Maximum 2000 characters. |
|
String |
Required if using a URL button. URL of website. Supports 1 variable. If using a variable, add sample variable property to the end of the URL string. The URL loads in the device's default mobile web browser when the customer taps the URL button. Maximum 2000 characters. |
|
This section describes limited-time offer templates and how to use them.
Limited-time offer templates allow you to display expiration dates and running countdown timers for offer codes in template messages, making it easy for you to communicate time-bound offers and drive customer engagement.
Limitations
Offer Expiration Details
The delivered message can display an offer expiration details section with a heading, an optional expiration timer, and the offer code itself.
The expiration timer is a text string that is not customizable, but it will change to red text if the message is viewed and the offer code is expiring within the next hour. (You include the actual offer code and its expiration timestamp when you send the template in a template message.)
Example Request
This is an example request to create a limited-time offer template that uses:
curl --location 'https://<api_key>:<api_token><subdomain>/v2/accounts/<your_sid>/templates?waba_id=11149XXXXXX' \ --header 'Content-Type: application/json' \ --data '{ "whatsapp": { "templates": [ { "template": { "name": "limited_time_offer_test", "language": "en", "category": "marketing", "components": [ { "type": "limited_time_offer", "limited_time_offer": { "text": "Expiring offer!", "has_expiration": false } }, { "type": "body", "text": "Good news, {{1}}! Use code {{2}} to get 25% off all Caribbean Destination packages!", "example": { "body_text": [ [ "Kaustubh", "SALE25" ] ] } }, { "type": "buttons", "buttons": [ { "type": "copy_code", "example": "SALE25" }, { "type": "url", "text": "Book now!", "url": "https://awesomedestinations.com/offers?code={{1}}", "example": [ "https://awesomedestinations.com/offers?code=n3mtql" ] } ] } ] } } ] } }
Placeholder | Description | Example Value |
---|---|---|
String |
Required. Body component text. Supports variables. Maximum 600 characters. |
|
Array of strings |
Required if body component text uses variables. Array of example variable strings. Must supply examples for all placeholders in No maximum, but counts against |
|
Boolean |
Optional. Set to |
|
Media asset handle |
Required if using an image or video header. Uploaded media asset handle. Use the Resumable Upload API to generate an asset handle. |
|
Enum |
Required if using a header. Can be |
|
String |
Required. Offer details text. Maximum 16 characters. |
|
String |
Required. Example offer code. Maximum 15 characters. |
|
Enum |
Required. Template language and locale code. |
|
String |
Required. Template name. Maximum 512 characters. |
|
String |
Required. URL button label text. Supports 1 variable. 25 characters maximum. |
|
String |
Required. URL of website that loads in the device's default mobile web browser when the URL button is tapped by the WhatsApp user. Supports 1 variable appended to the end of the URL string. Maximum 2000 characters. |
|
String |
Required if URL uses a variable. Example URL with example variable appended to the end. No maximum, but value counts against |
|
Authentication templates consist of:
One-tap autofill buttons are the preferred solution as they offer the best user experience. However, one-tap autofill buttons are currently only supported on Android and require additional changes to your app's code.
For more details: Authentication Templates - API Documentation - Meta for Developers
Authentication templates include a one-tap autofill button.
Parameter Name |
Parameter type |
Mandatory/Optional |
Description |
---|---|---|---|
|
String |
Optional |
One-tap autofill button label text. If omitted, the autofill text will default to a pre-set value, localized to the template's language. For example, Maximum 25 characters. |
|
Integer |
Optional |
Indicates the number of minutes the password or code is valid. If included, the code expiration warning and this value will be displayed in the delivered message. The button will be disabled in the delivered message the indicated number of minutes from when the message was sent. If omitted, the code expiration warning will not be displayed in the delivered message. In addition, the button will be disabled 10 minutes from when the message was sent. Minimum 1, maximum 90. for example 10 |
|
String |
Optional |
Copy code button label text. If omitted, the text will default to a pre-set value localized to the template's language. For example, If included, the authentication template message will display a copy code button with this text if the message fails the eligibility check. Maximum 25 characters. for example copy code |
|
String |
Mandatory |
Your Android app's package name. The string must have at least two segments (one or more dots), and each segment must start with a letter. All characters must be alphanumeric or an underscore [ Note that you can define your app's package name without using the Maximum 224 characters. for example
|
|
Boolean |
Optional |
Set to for example
|
|
String |
Mandatory |
Your app signing key hash. See App Signing Key Hash below. All characters must be either alphanumeric, Note that you can define your app's signing key hash without using the Must be exactly 11 characters. for example
|
|
String |
Mandatory |
Template language and locale code for example
|
|
String |
Mandatory |
Template name. Maximum 512 characters. for example
|
|
Integer |
Optional |
Authentication message time-to-live value, in seconds. for example
|
curl --location 'https://{{AuthKey}}:{{AuthToken}}@{{SubDomain}}/v2/accounts/{{AccountSid}}/templates?waba_id=123XXXXXXXXXX' \ --header 'Content-Type: application/json' \ --data '{ "whatsapp": { "templates": [ { "template": { "category": "AUTHENTICATION", "message_send_ttl_seconds": 60, "components": [ { "type": "BODY", "add_security_recommendation": true }, { "type": "FOOTER", "code_expiration_minutes": 15 }, { "type": "BUTTONS", "buttons": [ { "type": "OTP", "otp_type": "ONE_TAP", "text": "copy code", "supported_apps": [ { "package_name": "com.example.luckyshrub", "signature_hash": "K8a/AIXXXX" } ] } ] } ], "name": "verification_code", "language": "en_US" } } ] } }
Copy code authentication templates allow you to send a one-time password or code along with a copy code button to your users.
Parameter Name |
Parameter Type |
Mandatory/Optional |
Description |
---|---|---|---|
|
Integer |
Optional |
Indicates the number of minutes the password or code is valid. If included, the code expiration warning and this value will be displayed in the delivered message. The button will be disabled in the delivered message the indicated number of minutes from when the message was sent. If omitted, the code expiration warning will not be displayed in the delivered message. In addition, the button will be disabled 10 minutes from when the message was sent. Minimum 1, maximum 90. for example 10 |
|
String |
Optional |
Copy code button label text. If omitted, the text will default to a pre-set value localized to the template's language. For example, Maximum 25 characters. |
|
Boolean |
Optional |
Set to
|
|
String |
Mandatory |
Template language and locale code for example
|
|
String |
Mandatory |
Template name. Maximum 512 characters.
|
|
Integer |
Optional |
Authentication message time-to-live value, in seconds for example
|
curl --location --globoff 'https://{{AuthKey}}:{{AuthToken}}@{{SubDomain}}/v2/accounts/{{AccountSid}}/templates?waba_id=' \ --header 'Content-Type: application/json' \ --data '{ "whatsapp": { "templates": [ { "template": { "category": "AUTHENTICATION", "components": [ { "type": "BODY", "add_security_recommendation": true }, { "type": "FOOTER", "code_expiration_minutes": 10 }, { "type": "BUTTONS", "buttons": [ { "type": "OTP", "otp_type": "COPY_CODE" } ] } ], "name": "auth_template_copy_code", "language": "en" } } ] } }'
Zero-tap authentication templates allow your users to receive one-time passwords or codes via WhatsApp without having to leave your app.
When a user in your app requests a password or code and you deliver it using a zero-tap authentication template, the WhatsApp client broadcasts the included password or code, which your app can then capture with a broadcast receiver.
Parameter Name |
Parameter Type |
Mandatory/Optional |
Description |
---|---|---|---|
|
String |
Optional |
One-tap autofill button label text. If omitted, the autofill text will default to a pre-set value, localized to the template's language. For example, Autofill for English (US). Maximum 25 characters. |
|
String |
Optional |
Copy code button label text. If the message fails the eligibility check and displays a copy code button, the button will use this text label. If omitted, and the message fails the eligibility check and displays a copy code button, the text will default to a pre-set value localized to the template's language. For example, Maximum 25 characters. for example copy code |
|
Integer |
Optional |
Indicates the number of minutes the password or code is valid. If included, the code expiration warning and this value will be displayed in the delivered message. If the message fails the eligibility check and displays a one-tap autofill button, the button will be disabled in the delivered message the indicated number of minutes from when the message was sent. If omitted, the code expiration warning will not be displayed in the delivered message. If the message fails the eligibility check and displays a one-tap autofill button, the button will be disabled 10 minutes from when the message was sent. Minimum 1, maximum 9 for example
|
|
String |
Mandatory |
Your Android app's package name. The string must have at least two segments (one or more dots), and each segment must start with a letter. All characters must be alphanumeric or an underscore ( Note that you can define your app's package name without using the Maximum 224 characters. for exam
|
|
Boolean |
Optional |
Set to
|
|
String |
Mandatory |
Your app signing key hash. See App Signing Key Hash below. All characters must be either alphanumeric, Note that you can define your app's signing key hash without using the Must be exactly 11 characters
|
|
String |
Mandatory |
template language and locale code for example
|
|
String |
Mandatory |
Template name. Maximum 512 characters. for example
|
|
Boolean |
Mandatory |
Set to If set to for example
|
|
Integer |
Optional |
Authentication message time-to-live value, in seconds. for example
|
curl --location --globoff 'https://{{AuthKey}}:{{AuthToken}}@{{SubDomain}}/v2/accounts/{{AccountSid}}/templates?waba_id=' \ --header 'Content-Type: application/json' \ --data '{ "whatsapp": { "templates": [ { "template": { "category": "AUTHENTICATION", "components": [ { "type": "BODY", "add_security_recommendation": true }, { "type": "FOOTER", "code_expiration_minutes": 15 }, { "type": "BUTTONS", "buttons": [ { "type": "OTP", "zero_tap_terms_accepted": true, "otp_type": "ZERO_TAP", "supported_apps": [ { "package_name": "com.example.luckyshrub", "signature_hash": "K8a/AINcGX7" } ] } ] } ], "name": "auth_template_zero_tap", "language": "en" } } ] } }'
HTTP Response
{ "request_id": "72f3624613a84932823f838fcecf7389", "method": "POST", "http_code": 200, "metadata": { "failed": 0, "total": 1, "success": 1 }, "response": { "whatsapp": { "templates": [ { "code": 200, "error_data": null, "status": "success", "data": { "id": "903269234317278" } } ] } } }
HTTPResponseObject
Parameter Name |
Type |
Mandatory/ Optional |
Value/ Description |
request_id |
String |
Mandatory |
ID of the request |
method |
String |
Mandatory |
HTTP Request Method |
http_code |
Integer |
Mandatory |
HTTP Code of the request |
metadata |
MetadataObject |
Mandatory |
Metadata pertaining to the request |
response |
ResponseObject |
Mandatory |
Response for the request |
MetadataObject
Parameter Name |
Type |
Mandatory/ Optional |
Value/ Description |
total |
Integer |
Mandatory |
Total number of the messages in the request |
success |
Integer |
Mandatory |
Number of messages successfully accepted |
failed |
Integer |
Mandatory |
Number of messages that couldn’t be accepted |
ResponseObject
Parameter Name |
Type |
Mandatory/ Optional |
Value/ Description |
|
ChannelResponseObject |
Optional |
Channel Response for Whatsapp |
ChannelResponseObject
Parameter Name |
Type |
Mandatory/ Optional |
Description |
templates |
[]CreateTemplateResponseObject |
Optional |
Message Response |
CreateTemplateResponseObject
Parameter Name |
Type |
Mandatory/ Optional |
Value/ Description |
code |
Integer |
Mandatory |
Response code for the message |
error_data |
ErrorResponseObject |
Optional |
Error related to message |
status |
String |
Mandatory |
Status of the message |
data |
TemplateResponseObject |
Optional |
Data for the message |
ErrorResponseObject
Parameter Name |
Type |
Mandatory/ Optional |
Value/ Description |
code |
Numeric |
Mandatory |
Numeric error code |
message |
String |
Mandatory |
Brief explanation of error |
description |
String |
Mandatory |
Detailed explanation of error |
TemplateResponseObject
Parameter Name |
Type |
Mandatory/ Optional |
Value/ Description |
id |
String |
Mandatory |
id (Unique identifier) of the template |
custom_data |
String |
Mandatory |
Custom data passed in the request |
WhatsApp now allows uploading samples for templates with media headers : Document, Video, Image etc
To ensure templates submitted get approved seamlessly, uploading samples is a good practice.
Use this API to submit media sample files and generate media IDs.Media ID would then be used with create templates API to create and submit media templates for approval.
https://<api_key>:<api_token><subdomain>/v2/accounts/<your_sid>/templates/sample
<your_api_key>
and <your_api_token>
with the API key and token created by you.<your_sid>
with your “Account sid”<subdomain>
with the region of your account
<your_api_key>
, <your_api_token>
and <your_sid>
are available in the API settings page of your Exotel Dashboard
Listed below are the parameters for the POST API.
Parameter Name |
Type |
Mandatory/ Optional |
Value/ Description |
file_length |
String |
Mandatory |
Size of the file in bytes |
file_type |
String |
Mandatory |
Type of the file (image/jpeg etc) |
POST DATA
Binary data of the file
HTTPResponseObject
Parameter Name |
Type |
Mandatory/ Optional |
Value/ Description |
request_id |
String |
Mandatory |
ID of the request |
method |
String |
Mandatory |
HTTP Request Method |
http_code |
Integer |
Mandatory |
HTTP Code of the request |
response |
ResponseObject |
Mandatory |
Response for the request |
ResponseObject
Parameter Name |
Type |
Mandatory/ Optional |
Values/ Description |
|
ChannelResponseObject |
Optional |
Channel Response for Whatsapp |
ChannelResponseObject
Parameter Name |
Type |
Mandatory/ Optional |
Values/ Description |
file_handle |
[]FileHandleResponseObject |
Mandatory |
Message Response |
FileHandleResponseObject
Parameter Name |
Type |
Mandatory/ Optional |
Value/ Description |
id |
String |
Mandatory |
Id of the file_handle |
Use this API to edit and update existing templates added to your WhatsApp business account.
https://<api_key>:<api_token><subdomain>/v2/accounts/<your_sid>/templates
<your_api_key>
and <your_api_token>
with the API key and token created by you.<your_sid>
with your “Account sid”<subdomain>
with the region of your account
<your_api_key>
, <your_api_token>
and <your_sid>
are available in the API settings page of your Exotel Dashboard
Listed below are the parameters for the PUT API.
HTTPRequestObject
Parameter |
Type |
Mandatory |
Notes |
custom_data |
String |
Optional |
If the client wants to send any custom data at the request level. This will be passed back to the customer in the callback. |
|
ChannelObject |
Optional |
Information related to the messages to be sent out on whatsapp |
ChannelObject
Parameter Name |
Type |
Mandatory/ Optional |
Notes |
custom_data |
String |
Optional |
If the client wants to send any custom data at the channel level. This will be passed back to the customer in the callback. |
messages |
[]TemplateObject |
Mandatory |
Array of messages to be sent out |
TemplateObject
Parameter |
Type |
Mandatory/ Optional |
Value/ Description |
custom_data |
String |
Optional |
If the client wants to send any custom data at the message level. This will be passed back to the customer in the callback. |
template |
WhatsappEditTemplateObject |
Mandatory |
Respective channel specific template body |
WhatsAppEditTemplateObject
Parameter |
Type |
Mandatory/ Optional |
Value/ Description |
id |
String |
Mandatory |
ID of the template |
category |
String |
Mandatory |
Category of the template |
name |
String |
Mandatory |
Name of the template |
language |
String |
Mandatory |
Language of the template |
components |
[]ComponentObject |
Mandatory |
Components of the template |
curl --location --request PUT 'https://<api_key>:<api_token><subdomain>/v2/accounts/<your_sid>/templates?waba_id=<Your WABA ID>' \ --header 'Content-Type: application/json' \ --data-raw '{ "whatsapp": { "templates": [ { "template": { "id": "1059365578354709", "components": [ { "type": "BODY", "text": "Hi ths is Exotel {{1}} .Thanks & Regards" } ] } } ] } }'
var https = require('follow-redirects').https; var fs = require('fs'); var options = { 'method': 'PUT', 'hostname': '<Sub Domain>', 'path': '/v2/accounts/<Your SID>/templates?waba_id=<Your WABA ID>', 'headers': { 'Content-Type': 'application/json' }, 'maxRedirects': 20 }; var req = https.request(options, function (res) { varchunks= []; res.on("data", function (chunk) { chunks.push(chunk); }); res.on("end", function (chunk) { varbody=Buffer.concat(chunks); console.log(body.toString()); }); res.on("error", function (error) { console.error(error); }); }); var postData = JSON.stringify({ "whatsapp": { "templates": [ { "template": { "id": "1059365578354709", "components": [ { "type": "BODY", "text": "Hi ths is Exotel {{1}}. Thanks & Regards" } ] } } ] } }); req.write(postData); req.end();
HTTP Response
{ "request_id": "c1be33d4acb54a26b9c0ce7c2660e94f", "method": "PUT", "http_code": 200, "metadata": { "failed": 0, "total": 1, "success": 1 }, "response": { "whatsapp": { "templates": [ { "code": 200, "error_data": null, "status": "success", "data": { "id": "903269234317278" } } ] } } }
HTTPResponseObject
Parameter Name |
Type |
Mandatory/ Optional |
Values/ Description |
request_id |
String |
Mandatory |
ID of the request |
method |
String |
Mandatory |
HTTP Request Method |
http_code |
Integer |
Mandatory |
HTTP Code of the request |
metadata |
MetadataObject |
Mandatory |
Metadata pertaining to the request |
response |
ResponseObject |
Mandatory |
Response for the request |
MetadataObject
Parameter Name |
Type |
Mandatory/ Optional |
Values/ Description |
total |
Integer |
Mandatory |
Total number of the messages in the request |
success |
Integer |
Mandatory |
Number of messages successfully accepted |
failed |
Integer |
Mandatory |
Number of messages that couldn’t be accepted |
ResponseObject
Parameter Name |
Type |
Mandatory/ Optional |
Value/ Description |
|
ChannelResponseObject |
Optional |
Channel Response for Whatsapp |
Parameter Name |
Type |
Mandatory/ Optional |
Value/ Description |
templates |
[]CreateTemplateResponseObject |
Optional |
Message Response |
Parameter Name |
Type |
Mandatory/ Optional |
Value/ Description |
code |
Integer |
Mandatory |
Response code for the message |
error_data |
ErrorResponseObject |
Optional |
Error related to message |
status |
String |
Mandatory |
Status of the message |
data |
TemplateResponseObject |
Optional |
Data for the message |
Parameter Name |
Type |
Mandatory/ Optional |
Value/ Description |
code |
Numeric |
Mandatory |
Numeric error code |
message |
String |
Mandatory |
Brief explanation of error |
description |
String |
Mandatory |
Detailed explanation of error |
Parameter |
Type |
Mandatory |
Value/ Description |
id |
String |
Mandatory |
id (Unique identifier) of the template |
custom_data |
String |
Mandatory |
Custom data passed in the request |
Use this Delete API to delete WhatsApp templates from your WhatsApp business account.
https://<api_key>:<api_token><subdomain>/v2/accounts/<your_sid>/templates
<your_api_key>
and <your_api_token>
with the API key and token created by you.<your_sid>
with your “Account sid”<subdomain>
with the region of your account
<your_api_key>
, <your_api_token>
and <your_sid>
are available in the API settings page of your Exotel Dashboard
Listed below are the parameters for the DELETE API.
Query Param |
Type |
Mandatory/ Optional |
Value/ Description |
waba_id |
String |
Mandatory |
Waba ID |
HTTPRequestObject
Parameter |
Type |
Mandatory/ Optional |
Value/ Description |
custom_data |
String |
Optional |
If the client wants to send any custom data at the request level. This will be passed back to the customer in the callback. |
|
ChannelObject |
Optional |
Information related to the messages to be sent out on whatsapp |
ChannelObject
Parameter |
Type |
Mandatory/ Optional |
Value/ Description |
custom_data |
String |
Optional |
If the client wants to send any custom data at the channel level. This will be passed back to the customer in the callback. |
messages |
[]TemplateObject |
Mandatory |
Array of messages to be sent out |
TemplateObject
Parameter |
Type |
Mandatory |
Value/ Description |
custom_data |
String |
Optional |
If the client wants to send any custom data at the message level. This will be passed back to the customer in the callback. |
template |
WhatsappDeleteTemplateObject |
Mandatory |
Respective channel specific template body |
WhatsAppDeleteTemplateObject
Parameter Name |
Type |
Mandatory/ Optional |
Value/ Description |
name |
String |
Mandatory |
Name of the template |
curl --location --request DELETE 'https://<api_key>:<api_token><subdomain>/v2/accounts/<your_sid>/templates?waba_id=<Your WABA ID>' \ --header 'Content-Type: application/json' \ --data-raw '{ "whatsapp": { "templates": [ { "template": { "name": "test_template4606" } }, { "template": { "name": "test_template4605" } }, { "template": { "name": "test_template4607" } }, { "template": { "name": "test_template4604" } } ] } }'
var https = require('follow-redirects').https; var fs = require('fs'); var options = { 'method': 'DELETE', 'hostname': '<Sub Domain>', 'path': '/v2/accounts/<Your SID>/templates?waba_id=<Your WABA ID>', 'headers': { 'Content-Type': 'application/json' }, 'maxRedirects': 20 }; var req = https.request(options, function (res) { varchunks= []; res.on("data", function (chunk) { chunks.push(chunk); }); res.on("end", function (chunk) { varbody=Buffer.concat(chunks); console.log(body.toString()); }); res.on("error", function (error) { console.error(error); }); }); var postData = JSON.stringify({ "whatsapp": { "templates": [ { "template": { "name": "test_template4606" } }, { "template": { "name": "test_template4605" } }, { "template": { "name": "test_template4607" } }, { "template": { "name": "test_template4604" } } ] } }); req.setHeader('Content-Length', postData.length); req.write(postData); req.end();
HTTP Response
{ "request_id": "86b8539c88554aa68188a94b7d523056", "method": "DELETE", "http_code": 207, "metadata": { "failed": 3, "total": 4, "success": 1 }, "response": { "whatsapp": { "templates": [ { "code": 200, "error_data": null, "status": "success", "data": { "name": "test_template4609", "deleted": true } }, { "code": 400, "error_data": { "code": 1003, "description": "The message template test_template4605 wasn't found for this account.", "message": "Invalid request" }, "status": "failure", "data": null }, { "code": 400, "error_data": { "code": 1003, "description": "The message template test_template4607 wasn't found for this account.", "message": "Invalid request" }, "status": "failure", "data": null }, { "code": 400, "error_data": { "code": 1003, "description": "The message template test_template4604 wasn't found for this account.", "message": "Invalid request" }, "status": "failure", "data": null } ] } } }
ResponseObject
Parameter |
Type |
Mandatory/ Optional |
Value/ Description |
|
ChannelResponseObject |
Optional |
Channel Response for Whatsapp |
ChannelResponseObject
Parameter |
Type |
Mandatory |
Value/ Description |
templates |
[]CreateTemplateResponseObject |
Optional |
Message Response |
CreateTemplateResponseObject
Parameter |
Type |
Mandatory |
Value/ Description |
code |
Integer |
Mandatory |
Response code for the message |
error_data |
ErrorResponseObject |
Optional |
Error related to message |
status |
String |
Mandatory |
Status of the message |
data |
TemplateResponseObject |
Optional |
Data for the message |
ErrorResponseObject
Parameter |
Type |
Mandatory |
Value/ Description |
code |
Numeric |
Mandatory |
Numeric error code |
message |
String |
Mandatory |
Brief explanation of error |
description |
String |
Mandatory |
Detailed explanation of error |
TemplateResponseObject
Parameter |
Type |
Mandatory |
Value/ Description |
deleted |
bool |
Mandatory |
id (Unique identifier) of the template |
custom_data |
String |
Mandatory |
Custom data passed in the request |