Edit Template
PUT Method
The Edit Template API allows you to edit an existing WhatsApp template. Send a PUT request to the WhatsApp Message Template endpoint to edit a WhatsApp template. This document explains sending a PUT request to edit a WhatsApp template.
Note:
When updating a template, the WhatsApp Business API mandates distinct API calls for modifying category and components. These changes cannot be performed in a single request.
Prerequisites
- Before you get started, Create an API Key. To view the API Key and the SID, see View API Key and SID.
A prerequisite for using Kaleyra WhatsApp APIs is to have an active WhatsApp plan on kaleyra platform. - To set up a WhatsApp account on kaleyra.io, see Manual Signup
and Embedded Signup. - An active WhatsApp for Business API plan that includes:
- A WhatsApp business number.
- An associated profile with the business number.
- A WhatsApp verified and approved profile.
Limitations
- Only templates with an APPROVED, REJECTED, or PAUSED status can be edited.
- You can only edit a template's category or components.
- You cannot edit the category of an approved template.
- Approved templates can be edited up to 10 times in a 30-day window or 1 time in a 24-hour window. Rejected or paused templates can be edited an unlimited number of times.
- After editing an approved or paused template, it will automatically be approved unless it fails template review.
- You cannot edit voice_call button templates.
- Rate limit for this API is 100 requests per WABA per hour.
Base URL
https://<api_domain>/v2/<SID>
API Domain and Value
api_domain | Value |
---|---|
IN pod | api.in.kaleyra.io |
SG Pod | api.ap.kaleyra.io |
EU Pod | api.eu.kaleyra.io |
API request to Edit WhatsApp Template
To edit a WhatsApp template, use the https://<api_domain>/v2/<sid>/whatsapp/<waba_id>/message_templates
endpoint with the following request method:
Request Format
The following is the request format for updating the Category object of a WhatsApp template:
curl -X PUT \
https://<api_domain>/v2/<sid>/whatsapp/<WABA-Id>/edit/<whatsapp_message_template_id> \
-H 'Content-Type: application/json' \
-H 'api-key: <api-key>' \
-H 'cache-control: no-cache' \
-d '{
"template_edit_object": {
"category": "<category>"
}
}'
The following is the request format for updating the Components object of a WhatsApp template:
curl -X PUT \
https://<api_domain>/v2/<sid>/whatsapp/<WABA-Id>/edit/<whatsapp_message_template_id> \
-H 'Content-Type: application/json' \
-H 'api-key: <api-key>' \
-H 'cache-control: no-cache' \
-d '{
"template_edit_object": {
"components": [
{
"type": "HEADER",
"format": "<format>",
"text": "<text>",
"example": {
"header_text": [
"<header_text>"
]
}
},
{
"type": "BODY",
"text": "<text>",
"example": {
"body_text": [
[
"<body_text>"
]
]
}
},
{
"type": "FOOTER",
"text": "<type>"
},
{
"type": "BUTTONS",
"buttons": [
{
"type": "QUICK_REPLY",
"text": "<type>"
},
{
"type": "QUICK_REPLY",
"text": "<type>"
}
]
}
]
}
}'
Sample Request Format
The following is the sample request for updating the Category object of a WhatsApp template:
curl -X PUT \
https://api.in.kaleyra.io/v2/HXXXXXXX071US/whatsapp/1090xxxxxxxxxxxx/edit/475XXX23XXXX850\
-H 'Content-Type: application/json' \
-H 'api-key: Axxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx3' \
-H 'cache-control: no-cache' \
-d '{
"template_edit_object": {
"category": "MARKETING"
}
}'
The following is the sample request for updating the Components object of a WhatsApp template:
curl -X PUT \
https://api.in.kaleyra.io/v2/HXXXXXXX071US/whatsapp/1090xxxxxxxxxxxx/edit/475XXX23XXXX850\
-H 'Content-Type: application/json' \
-H 'api-key: Axxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx3' \
-H 'cache-control: no-cache' \
-d '{
"template_edit_object": {
"components": [
{
"type": "HEADER",
"format": "TEXT",
"text": "Our {{1}} is on!",
"example": {
"header_text": [
"Spring Sale"
]
}
},
{
"type": "BODY",
"text": "Shop now through {{1}} and use code {{2}} to get {{3}} off of all merchandise.",
"example": {
"body_text": [
[
"the end of April",
"25OFF",
"25%"
]
]
}
},
{
"type": "FOOTER",
"text": "Use the buttons below to manage your marketing subscriptions"
},
{
"type": "BUTTONS",
"buttons": [
{
"type": "QUICK_REPLY",
"text": "Unsubscribe from Promos"
},
{
"type": "QUICK_REPLY",
"text": "Unsubscribe from All"
}
]
}
]
}
}'
URL Parameters and Headers
Following is the list of parameters and headers to edit a WhatsApp message template:
Parameter / Headers | Data Type | Description | Example | Mandatory? |
---|---|---|---|---|
sid | String | Account SID (Security Identifier). | HXAP16XXXXXX97IN | Yes |
waba_id | String | WhatsApp Business Account. | 1090xxxxxxxxxxxx | Yes |
whatsapp_message_template_id | String | The template ID for which the update is required. Note: Use the Get Template API to retrieve the template ID. | 475XXX23XXXX850 | Yes |
Content-Type | String | Indicates the format of the content the API will be processing. | The only allowed value is application/JSON | Yes |
api-key | String | API key generated from Kaleyra platform account. | Axxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx3 | Yes |
Following is the list of attributes to be used in the payload edit a WhatsApp message template:
Parameter | Data Type | Description | Example | Mandatory? |
---|---|---|---|---|
template_edit_object | JSON object | This will contain the payload to be edited. | See the specific table for details. | Yes |
The following table describes the different attributes used for the template_edit_object
JSON object:
Parameter | Data Type | Description | Example | Mandatory? |
---|---|---|---|---|
category | String | Category of the template being edited: - Marketing - Authentication - Utility | MARKETING | Yes |
components | JSON object | Components that you want to edit in the WhatsApp template. | See the specific table for details. | Yes |
The following table describes the different attributes used for the components
for the HEADER JSON object:
Parameter | Data Type | Description | Example | Mandatory? |
---|---|---|---|---|
type | String | Components that appear at the top of template messages. Headers support text, media (images, videos, documents), and locations. | HEADER | No |
format | String | Format of the Header. Possible values are text, media, and locations. | text | No |
text | String | The text you want to display in the header. The Header can contain TEXT, IMAGE, VIDEO, DOCUMENT, or LOCATION values. Note: The <HEADER_HANDLE> must be defined through the Resumable Upload API for Media headers. | Our {{1}} is on! | No |
example | String | The example content for the header. | Spring Sale | No |
The following table describes the different attributes used for the components
for the BODY JSON object:
Parameter | Data Type | Description | Example | Mandatory? |
---|---|---|---|---|
type | String | Body components are text-only components and are required by all templates. | BODY | Yes |
text | String | The text you want to display in body. Up to 1024 characters are allowed | Shop now through {{1}} and use code {{2}} to get {{3}} off of all merchandise. | Yes |
example | String | The example content for the body. | The end of April, 25OFF, 25% | Yes |
The following table describes the different attributes used for the components
for the FOOTER JSON object:
Parameter | Data Type | Description | Example | Mandatory? |
---|---|---|---|---|
type | String | Components that appear immediately after the body component. Templates are limited to one footer component. | FOOTER | No |
text | String | The text displayed in the footer. | Use the buttons below to manage your marketing subscriptions | No |
The following table describes the different attributes used for the components
for the BUTTONS JSON object:
Parameter | Data Type | Description | Example | Mandatory? |
---|---|---|---|---|
type | String | The type of button used. | QUICK_REPLY | No |
text | String | The text you want to display in button. | Unsubscribe from Promos. | No |
Sample Success Response
The following success message appears with the status 200 Success:
200 Success
{
"code": "WA200",
"message": "Request Processed Successfully",
"data": {
"success": <bool>
},
"error": {}
}
Sample Failure Response
The following are the failure responses:
401 Unauthorized
{
"code": "RBC001",
"message": "Incorrect SID or API key.",
"data": [],
"error": {
"error": "Incorrect SID or API key."
}
}
401 Unauthorized WABA
{
"code": "WA401",
"message": "Waba_Id is not present or does not belong to the account.",
"data": {},
"error": {
"waba_id": "Waba_Id is not present or does not belong to the account."
}
}
400 Incorrect payload
{
"code": "WA-400",
"message": "Refer to correct payload format",
"data": {},
"error": {
"payload": "Incorrect payload format"
}
}
500 Internal Server Error
{
"code": "WA-500",
"message": "Please try again later",
"data": {},
"error": {
"error": "Internal server error"
}
}
429 Too many requests
{
"code": "WA429",
"message": "Too many requests",
"data": {},
"error": {
"error": "Too many requests sent from this waba in a short period of time, please try after sometime"
}
}
Updated about 13 hours ago