×

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

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.

 


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

 

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

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

 


Upload Template Sample New

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.

POST

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

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

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


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