×

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