Skip to content

EditTemplate#

The method is intended to edit the exists template.

Request#

To edit the template, you need to execute a request to:

POST {{apiUrl}}/waInstance{{idInstance}}/editTemplate/{{apiTokenInstance}}

For idInstance, apiTokenInstance and apiUrl request parameters, refer to Before you start section.

Request parameters#

Parameter Type Mandatory Description
templateId string Yes ID of a previously created, existing template. You can use GetTemplates method to find id
templateParams object Yes An object with a list of parameters that should be changed

TemplateParams object parameters#

Parameter Type Mandatory Description
content string Yes Template body, character limit 1028.
templateType string No Template type: TEXT, IMAGE, VIDEO, DOCUMENT
example string Yes Your text with substituted examples values ​​of variables instead params in SendTemplates method
enableSample boolean No An option that is required to create all types of templates.
header string No Template header. Applicable for template type = Text. Character limit: 60.
exampleHeader string No * Not applicable for template type: CATALOG. Use in exampleHeader only lowercase letters, because using capital letters made the error. * Example template title text. If you are sending a header, you need to use this parameter.
footer string No Template footer. Character limit: 60.
buttons string No Only used if your template has a call to action. Also provided is an example if the URL button has a variable parameter.
exampleMedia string No Using the handleId, you can create and submit a template along with a sample media. The handleId is passed in the exampleMedia parameter of the Apply for templates with sample media API.
mediaId string No Media ID
mediaUrl string No Media URL
category string No The category of your template. Possible values: AUTHENTICATION, MARKETING, UTILITY.

Request body example#

{
    "templateId": "f******b-6**5-4**2-b**2-5**********7",
    "templateParams": {
        "content": "your second ticket has been confirmed for {{1}} persons on date {{2}}.",
        "header": "This is the header",
        "exampleHeader": "This is the header",
        "footer": "This is the footer",
        "buttons": "[{'type':'PHONE_NUMBER','text':'Call Us','phone_number':'+919872329959'},{'type':'URL','text':'Book A Demo','url':'https://greenwaba.io/{{1}}','example':['https://greenwaba.io/abc']}, {'type':'QUICK_REPLY','text':'Demo Button'}]",
        "example": "your second ticket has been confirmed for 4 persons on date 2020-05-04.",
        "enableSample": true,
        "allowTemplateCategoryChange": false
    }
}

Response#

Response parameters#

Parameter Type Description
status string Status of the sent request
reason string Reason for unsuccessful template editing (optional field)

Response body example#

Status code success: 200 OK.

{
  "status": "success"
}

EditTemplate errors#

For a list of errors common to all methods, refer to Common errors section.

After editing the template goes into the Pending status and becomes uneditable before the status changes. Templates can only be edited in Rejected, Approved, or Paused statuses.

  {
      "status": "failed",
      "reason": "Only Rejected, Approved and Paused templates can be edited"
  }

Request examples#

curl --location '{{apiUrl}}/waInstance{{idInstance}}/editTemplate/{{apiTokenInstance}}' \
    --header 'Content-Type: application/json' \
    --data 'content=your ticket has been confirmed for {{1}} persons on date {{2}}.' \
    --data templateType=TEXT \
    --data 'example=your ticket has been confirmed for 4 persons on date 2020-05-04' \
    --data enableSample=true \
    --data 'header=This is the header' \
    --data 'footer=This is the footer' \
    --data 'buttons=[{"type":"PHONE_NUMBER","text":"Call Us","phone_number":"+xxxxxxxxxxx"},{"type":"URL","text":"Book A Demo","url":"https://greenwaba.io/{{1}}","example":["https://greenwaba.io/abc"]}]' \
    --data 'exampleMedia=4::aW1hZ2UvcadG5n:ARYaMMMA2QvIXuQZdPjWVXTOqfoBU3n0L1Ftyg4w57yxi9nD105yQDvW2nu3-HNo9HGefxZ-Ig-HAi3YSsckwIsOEUwxSPatsxT0Niob30E63A:e:1634884682:2281283925530161:100033655335566:ARaBAxW-1L-ZRu6SMSg' \
    --data mediaId=TEXT \
    --data mediaUrl=TEXT \
    --data category=AUTHENTICATION