×

Get WhatsApp Templates New

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. 

GET

https://<api_key>:<api_token><subdomain>/v2/accounts/<your_sid>/templates

  • Replace <your_api_key> and <your_api_token> with the API key and token created by you.
  • Replace <your_sid> with your “Account sid”
  • Replace <subdomain> with the region of your account
    1. <subdomain> of Singapore cluster is @api.exotel.com
    2. <subdomain> of Mumbai cluster is @api.in.exotel.com

<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

  • On success, the HTTP response status code will be 200.
{
    "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

whatsapp

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: 2023-01-03T15:49:39+0000

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.

 


Upload Template Sample New

Including sample media in your template submission allows Meta to preview exactly how your template will look to end-users. This visual reference improves the likelihood of template approval by helping Meta reviewers understand the context and quality of the content, ensuring compliance with guidelines.

This requirement is similar to the sample media upload flow in WhatsApp Manager’s Create Template dashboard, where you preview media assets or text values before submission.

How to Use the Upload Sample API

Step-by-Step Guide

  • API Access: Ensure you have permissions and the necessary access to interact with the Upload Sample API.
  • Prepare the Media File:
    • Make sure your file type and size comply with Meta’s supported formats.
    • Validate that the media content aligns with your intended template structure.
  • Upload Sample Media File:
    • Use the Upload Sample API endpoint to submit your media file.
    • Upon success, a Media ID will be generated.
  • Create Template with Media ID: Use the Media ID in the Create Template API to submit your media template with the associated media file.

This API process replicates the familiar dashboard experience, allowing developers to streamline media template submissions programmatically while adhering to Meta’s guidelines.

POST

'https://<api_key>:<api_token>@<subdomain>/v2/accounts/<accountsid>Exotel/templates/sample?file_length=<file-size-in-bytes>&file_type=<file-type>

  • Replace <your_api_key> and <your_api_token> with the API key and token created by you.
  • Replace <your_sid> with your “Account sid”
  • Replace <subdomain> with the region of your account
    1. <subdomain> of Singapore cluster is @api.exotel.com
    2. <subdomain> of Mumbai cluster is @api.in.exotel.com

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

  • file_type - The file's MIME type. Valid values are: application/pdfimage/jpegimage/jpgimage/png, and video/mp4

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

whatsapp

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

 

Please refer to our working Postman collection to access the API here - Template Management - Upload Sample

curl --location 'https://:@api.exotel.com/v2/accounts//templates/sample?file_length=1024&file_type=png' \
--header 'Content-Type: image/png' \
--data '@/home/exotel/Pictures/leaf.png'
{
   "request_id": "232e2865b3d74516b1d3fcb319493260",
   "method": "POST",
   "http_code": 200,
   "response": {
       "whatsapp": {
           "file_handle": [
               {
                   "code": 200,
                   "error_data": null,
                   "status": "success",
                   "data": {
                       "id": "4::cG5n:ARbMfw_qdKVRCAscOITqcGs_hbOmQO-2iS7aWOmJRPsMNNAfgdQPt1n5iNnELKQ:e:1731231031:3157993617821787:XXXXXX:XXXXXXXX"
                   }
               }
           ]
       }
   }
}

Once you successfully generate the Media ID, copy and use it in the Create Template API under the header_handle parameter.


Create WhatsApp Templates New

Use the create templates API to create & submit templates to WhatsApp for approval. The API supports both single and bulk create.

POST

https://<api_key>:<api_token><subdomain>/v2/accounts/<your_sid>/templates

  • Replace <your_api_key> and <your_api_token> with the API key and token created by you.
  • Replace <your_sid> with your “Account sid”
  • Replace <subdomain> with the region of your account
    1. <subdomain> of Singapore cluster is @api.exotel.com
    2. <subdomain> of Mumbai cluster is @api.in.exotel.com

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

whatsapp

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

 
ButtonObject

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

 

Create Text Templates

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}";

Create Carousel Templates

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:

Limitations

  • Only templates categorized as MARKETING are supported.
  • Footer components are not supported.

Carousel Cards

  • Carousel templates support up to 10 carousel cards. Cards must have a media header (image or video), body text, and at least one button. Supports 2 buttons. Buttons can be the same or a mix of quick reply buttons, phone number buttons, or URL buttons.
  • The media header format and button types must be the same across all cards that make up a carousel template.
  • Media assets will be cropped to a wide ratio based on the customer's device.

Example Request

This is an example request to create a limited-time offer template that uses:

  • a bubble text variable
  • card index: Zero-indexed order in which card appears within the card carousel. 0 indicates the first card, 1 indicates the second card, etc (Required)
  • a card body with variable: There is no maximum character limit on this value, but counts against the card body text limit of 160 characters.
  • an image header
  • body text with variables
  • the offer expiration details: Offer code expiration time as a UNIX timestamp in milliseconds (Required)
  • a copy code button: if the template uses a copy code button. Maximum 15 characters (Required)
  • a URL button with a variable
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"
                                                    ]
                                                }
                                            ]
                                        }
                                    ]
                                }
                            ]
                        }
                    ]
                }
            }
        ]
    }
}'

Body Properties

Placeholder Description Example Value

<BUBBLE_TEXT>

String

Required.


Message bubble text string. Supports variables.


Maximum 1024 characters.

Summer is here, and we've got the freshest produce around! Use code {{1}} to get {{2}} off your next order.

<BUBBLE_TEXT_VAR_EXAMPLE>

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.

"15OFF","15%"

<CARD_BODY_TEXT>

String

Required.


Card body text. Support variables.


Maximum 160 characters.

Rare lemons for unique cocktails. Use code {{1}} to get {{2}} off all produce.

<CARD_BODY_TEXT_VAR_EXAMPLE>

Array of strings

Required if using card body text with variables.


Card body text example variables.

"15OFF","15%"

<CARD_HEADER_FORMAT>

Enum

Required.


Card media header format. Must be IMAGE or VIDEO.

IMAGE

<CARD_HEADER_HANDLE>

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.

4::aW...

<QUICK_REPLY_BUTTON_TEXT>

String

Required if using a quick reply button.


Quick reply button label text.


Maximum 25 characters.

Send more like this

<TEMPLATE_CATEGORY>

Enum

Required.


Must be MARKETING or UTILITY.

MARKETING

<TEMPLATE_LANGUAGE>

Enum

Required.


Template language and locale code.

en_US

<TEMPLATE_NAME>

String

Required.


Template name.


Maximum 512 characters.

summer_carousel_promo_2023

<URL_BUTTON_TEXT>

String

Required if using a URL button.


URL button label text. Supports 1 variable.


25 characters maximum.

Buy now

<URL_BUTTON_URL>

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.

https://www.luckyshrub.com/shop?promo={{1}}

<URL_BUTTON_VAR_EXAMPLE>

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.

https://www.luckyshrub.com/shop?promo=summer_lemons_2023

Create Limited-Time Offer Templates

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

  • Only templates categorized as MARKETING are supported.
  • Footer components are not supported.
  • Users who view a limited-time offer template message using that WhatsApp web app or desktop app will not see the offer, but will instead see a message indicating that they have received a message but that it's not supported in the client they are using.

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:

  • an image header component
  • body text component with variables
  • the limited time offer component
  • a copy code button
  • a button URL with a variable
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"
                  ]
                }
              ]
            }
          ]
        }
      }
    ]
  }
}

Body Properties

Placeholder Description Example Value

<BODY_TEXT>

String

Required.


Body component text. Supports variables.


Maximum 600 characters.

Good news, {{1}}! Use code {{2}} to get 25% off all Caribbean Destination packages!

<BODY_TEXT_VARIABLE_EXAMPLES>

Array of strings

Required if body component text uses variables.


Array of example variable strings.


Must supply examples for all placeholders in <BODY_TEXT> string.


No maximum, but counts against <BODY_TEXT> maximum.

["Pablo","CARIBE25"]

<HAS_EXPIRATION>

Boolean

Optional.


Set to true to have the offer expiration details appear in the delivered message.

true

<HEADER_ASSET_HANDLE>

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.

4::aW...

<HEADER_FORMAT>

Enum

Required if using a header.


Can be IMAGE, or VIDEO.

IMAGE

<LIMITED_TIME_OFFER_TEXT>

String

Required.


Offer details text.


Maximum 16 characters.

Expiring offer!

<OFFER_CODE_EXAMPLE>

String

Required.


Example offer code.


Maximum 15 characters.

CARIBE25

<TEMPLATE_LANGUAGE>

Enum

Required.


Template language and locale code.

en_US

<TEMPLATE_NAME>

String

Required.


Template name.


Maximum 512 characters.

limited_time_offer_caribbean_pkg_2023

<URL_BUTTON_TEXT>

String

Required.


URL button label text. Supports 1 variable.


25 characters maximum.

Book now!

<URL_BUTTON_URL>

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.

https://awesomedestinations.com/offers?code={{1}}

<URL_EXAMPLE_WITH_VARIABLE_EXAMPLE>

String

Required if URL uses a variable.


Example URL with example variable appended to the end.


No maximum, but value counts against <URL_BUTTON_URL> maximum.

https://awesomedestinations.com/offers?ref=n3mtql

Create WhatsApp Authentication Templates

Authentication templates consist of:

  • Fixed preset text: <VERIFICATION_CODE> is your verification code.
  • An optional security disclaimer: For your security, do not share this code.
  • An optional expiration warning: This code expires in <NUM_MINUTES> minutes.
  • Either a one-tap autofill button, a copy code button, or no button at all if using zero-tap.

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:

One-Tap Autofill Authentication Template

Authentication templates include a one-tap autofill button.

 

Parameter Name

Parameter type

Mandatory/Optional

Description

autofill_text

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.

code_expiration_minutes

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

text

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, Copy Code for English (US).

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

package_name

 

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 [a-zA-Z0-9_].

Note that you can define your app's package name without using the supported_apps array, but this is not recommended. See Supported Apps below.

Maximum 224 characters.

for example

com.example.luckyshrub

add_security_recommendation

Boolean

Optional

Set to true if you want the template to include the string, For your security, do not share this code. Set to false to exclude the string

for example

true

signature_hash

String

Mandatory

Your app signing key hash. See App Signing Key Hash below.

All characters must be either alphanumeric, +/, or = (a-zA-Z0-9+/=).

Note that you can define your app's signing key hash without using the supported_apps array, but this is not recommended. See Supported Apps below.

Must be exactly 11 characters.

for example

K8a/AINcGX7

language

 

String

Mandatory

Template language and locale code

for example

en_US

name

 

String

Mandatory

Template name.

Maximum 512 characters.

for example

verification_code

message_send_ttl_seconds

 

Integer

Optional

Authentication message time-to-live value, in seconds.

for example

60

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 Template

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

 

code_expiration_minutes

 

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

text

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, Copy Code for English (US).

Maximum 25 characters.

add_security_recommendation

 

Boolean

Optional

Set to true if you want the template to include the string, For your security, do not share this code. Set to false to exclude the string.

true

language

 

String

Mandatory

Template language and locale code

for example

en_US

name

 

String

Mandatory

Template name.

Maximum 512 characters.

verification_code1

message_send_ttl_seconds

 

Integer

Optional

Authentication message time-to-live value, in seconds

for example

60

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 Template

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

 

autofill_text

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.

text

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, Copy Code for English (US).

Maximum 25 characters.

for example

copy code

code_expiration_minutes

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

10

package_name

 

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 (a-zA-Z0-9_).

Note that you can define your app's package name without using the supported_apps array, but this is not recommended. See Supported Apps below.

Maximum 224 characters.

for exam

com.example.luckyshrub

add_security_recommendation

 

Boolean

Optional

Set to true if you want the template to include the fixed string, For your security, do not share this code. Set to false to exclude the string.

true

signature_hash

 

String

Mandatory

Your app signing key hash. See App Signing Key Hash below.

All characters must be either alphanumeric, +/, or = (a-zA-Z0-9+/=).

Note that you can define your app's signing key hash without using the supported_apps array, but this is not recommended. See Supported Apps below.

Must be exactly 11 characters

K8a/AINcGX7

language

 

String

Mandatory

template language and locale code

for example

en_US

name

 

String

Mandatory

Template name.

Maximum 512 characters.

for example

zero_tap

zero_tap_terms_accepted

 

Boolean

Mandatory

Set to true to indicate that you understand that your use of zero-tap authentication is subject to the WhatsApp Business Terms of Service, and that it's your responsibility to ensure your customers expect that the code will be automatically filled in on their behalf when they choose to receive the zero-tap code through WhatsApp.

If set to false, the template will not be created as you need to accept zero-tap terms before creating zero-tap enabled message templates

for example

true

message_send_ttl_seconds

 

Integer

Optional

Authentication message time-to-live value, in seconds.

for example

60

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

  • On success, the HTTP response status code will be 200.
{
  "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

whatsapp

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

 


Edit WhatsApp Templates New

Use this API to edit and update existing templates added to your WhatsApp business account.

PUT

https://<api_key>:<api_token><subdomain>/v2/accounts/<your_sid>/templates

  • Replace <your_api_key> and <your_api_token> with the API key and token created by you.
  • Replace <your_sid> with your “Account sid”
  • Replace <subdomain> with the region of your account
    1. <subdomain> of Singapore cluster is @api.exotel.com
    2. <subdomain> of Mumbai cluster is @api.in.exotel.com

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

whatsapp

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

  • On success, the HTTP response status code will be 200.
{
"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

whatsapp

ChannelResponseObject

Optional

Channel Response for Whatsapp

 
ChannelResponseObject
 

Parameter Name

Type

Mandatory/ Optional

Value/ 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

Type

Mandatory

Value/ Description

id

String

Mandatory

id (Unique identifier) of the template

custom_data

String

Mandatory

Custom data passed in the request

 

Delete Templates New

Use this Delete API to delete WhatsApp templates from your WhatsApp business account.

DELETE

https://<api_key>:<api_token><subdomain>/v2/accounts/<your_sid>/templates

  • Replace <your_api_key> and <your_api_token> with the API key and token created by you.
  • Replace <your_sid> with your “Account sid”
  • Replace <subdomain> with the region of your account
    1. <subdomain> of Singapore cluster is @api.exotel.com
    2. <subdomain> of Mumbai cluster is @api.in.exotel.com

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

whatsapp

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

  • On success, the HTTP response status code will be 200.
{

"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

whatsapp

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