×

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