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. Maximum length: 550 characters. If the limit is exceeded, the first 5 lines are displayed, the rest of the text is hidden under the Read more button. Up to 10 emoji are allowed. * For the template with AUTHENTICATION category parameter category the parameter is optional. * It is recommended to leave the field blank to automatically apply the default value: *{{1}}* is your verification code. |
templateType | string | No | Template type: TEXT , IMAGE , VIDEO , DOCUMENT |
example | string | Yes* | Your text with substituted examples of variable values instead of parameters in the SendTemplates method * For the template with AUTHENTICATION category parameter category the parameter is optional. * It is recommended to leave the field blank to automatically apply the default value: *1234* is your verification code. |
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 * | Example of template title text. Not applicable for template type: CATALOG . Use only lowercase letters in exampleHeader , as using uppercase letters results in an error. * When using the header field in a request, the field is mandatory |
footer | string | No | Template footer. Character limit: 60 . |
buttons | array | No* | Message buttons The AUTHENTICATION category template must have at least one button of the OTP type. Request parameter example: "buttons": "[{'type':'OTP','otp_type':'COPY_CODE'}]" |
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 . |
buttons
array parameters#
Parameter | Type | Required | Description |
---|---|---|---|
type | string | Yes | The type of button to send. Possible types: - QUICK_REPLY - allows you to send a quick response by pressing a button with a prepared text. - URL - allows you to open a link by pressing a button. - PHONE_NUMBER - allows you to start a call by pressing a button. |
text | string | Yes | The text on the button. For the QUICK_REPLY and URL types, the maximum length is 25 characters. For the PHONE_NUMBER type, the maximum length is 20 characters. |
phone_number | string | No | Field for a button of the PHONE_NUMBER type. The phone number that will be called when the button is clicked |
url | string | No | Field for a button of the URL type. The link that will be accessed when the button is clicked |
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://GREEN-API.io/{{1}}','example':['https://GREEN-API.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": true
}
}
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://GREEN-API.io/{{1}}","example":["https://GREEN-API.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