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. |