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

  1. 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.
  2. To set up a WhatsApp account on kaleyra.io, see Manual Signup
    and Embedded Signup.
  3. 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_domainValue
IN podapi.in.kaleyra.io
SG Podapi.ap.kaleyra.io
EU Podapi.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 / HeadersData TypeDescriptionExampleMandatory?
sidStringAccount SID (Security Identifier).HXAP16XXXXXX97INYes
waba_idStringWhatsApp Business Account.1090xxxxxxxxxxxxYes
whatsapp_message_template_idStringThe template ID for which the update is required.
Note: Use the Get Template API to retrieve the template ID.
475XXX23XXXX850Yes
Content-TypeStringIndicates the format of the content the API will be processing.The only allowed value is application/JSONYes
api-keyStringAPI key generated from Kaleyra platform account.Axxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx3Yes

Following is the list of attributes to be used in the payload edit a WhatsApp message template:

ParameterData TypeDescriptionExampleMandatory?
template_edit_objectJSON objectThis 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:

ParameterData TypeDescriptionExampleMandatory?
categoryStringCategory of the template being edited:

- Marketing
- Authentication
- Utility
MARKETINGYes
componentsJSON objectComponents 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:

ParameterData TypeDescriptionExampleMandatory?
typeStringComponents that appear at the top of template messages. Headers support text, media (images, videos, documents), and locations.HEADERNo
formatStringFormat of the Header. Possible values are text, media, and locations.textNo
textStringThe 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
exampleStringThe example content for the header.Spring SaleNo

The following table describes the different attributes used for the components for the BODY JSON object:

ParameterData TypeDescriptionExampleMandatory?
typeStringBody components are text-only components and are required by all templates.BODYYes
textStringThe text you want to display in body. Up to 1024 characters are allowedShop now through {{1}} and use code {{2}} to get {{3}} off of all merchandise.Yes
exampleStringThe 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:

ParameterData TypeDescriptionExampleMandatory?
typeStringComponents that appear immediately after the body component. Templates are limited to one footer component.FOOTERNo
textStringThe text displayed in the footer.Use the buttons below to manage your marketing subscriptionsNo

The following table describes the different attributes used for the components for the BUTTONS JSON object:

ParameterData TypeDescriptionExampleMandatory?
typeStringThe type of button used.QUICK_REPLYNo
textStringThe 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"
    }
}