CreateTemplate#
The method is intended to create the new template.
Request#
To create the template, you need to execute a request to:
POST {{apiUrl}}/waInstance{{idInstance}}/createTemplate/{{apiTokenInstance}}
For idInstance, apiTokenInstance and apiUrl request parameters, refer to Before you start section.
Request parameters#
| Parameter | Type | Mandatory | Description |
|---|---|---|---|
elementName | string | Yes | Template name. The element name is unique within the WABAs namespace. Parameter can only contain small letters, numbers and underscores. |
languageCode | string | Yes | Language code for the template. See all language codes in the table below |
category | string | Yes | The category of your template. Possible values : AUTHENTICATION, MARKETING and UTILITY. If you send a different value, you will receive an error message: Invalid category provided, kindly use category from these options AUTHENTICATION,MARKETING,UTILITY. |
templateType | string | Yes | Template type: TEXT, IMAGE, VIDEO, DOCUMENT. |
vertical | string | Yes | Brief description of the template for passing Meta verification. Character limit: 180 |
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 AUTHENTICATION category template, the field is optional. * It is recommended to leave the field blank to automatically apply the default value: *{{1}}* is your verification code. |
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'}]" |
cards | string | No | Cards for the carousel template |
example | string | Yes* | Your text with substituted examples of variable values instead of parameters in the SendTemplates method * For the AUTHENTICATION category template, the field 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. |
allowTemplateCategoryChange | boolean | No | Deprecated parameter. Ignored during request. |
addSecurityRecommendation | boolean | No | Optionally, a disclaimer is added to the content for the AUTHENTICATION category. For security purposes, do not share this code. |
codeExpirationMinutes | number | No | Optionally, the following text is added to the footer for the AUTHENTICATION category: This code will expire in <NUM_MINUTES> minutes. Codes must be valid for between 1 and 90 minutes. |
Language codes
| Language | Code |
|---|---|
| Afrikaans | af |
| Albanian | sq |
| Arabic | ar |
| Azerbaijani | az |
| Bengali | bn |
| Bulgarian | bg |
| Catalan | ca |
| Chinese (CHN) | zh_CN |
| Chinese (HKG) | zh_HK |
| Chinese (TAI) | zh_TW |
| Croatian | hr |
| Czech | cs |
| Danish | da |
| Dutch | nl |
| English | en |
| English (UK) | en_GB |
| English (US) | en_US |
| Estonian | et |
| Filipino | fil |
| Finnish | fi |
| French | fr |
| Georgian | ka |
| German | de |
| Greek | el |
| Gujarati | gu |
| Hausa | ha |
| Hebrew | he |
| Hindi | hi |
| Hungarian | hu |
| Indonesian | id |
| Irish | ga |
| Italian | it |
| Japanese | ja |
| Kannada | kn |
| Kazakh | kk |
| Kinyarwanda | rw_RW |
| Korean | ko |
| Kyrgyz (Kyrgyzstan) | ky_KG |
| Lao | lo |
| Latvian | lv |
| Lithuanian | lt |
| Macedonian | mk |
| Malay | ms |
| Malayalam | ml |
| Marathi | mr |
| Norwegian | nb |
| Persian | fa |
| Polish | pl |
| Portuguese (BR) | pt_BR |
| Portuguese (POR) | pt_PT |
| Punjabi | pa |
| Romanian | ro |
| Russian | ru |
| Serbian | sr |
| Slovak | sk |
| Slovenian | sl |
| Spanish | es |
| Spanish (ARG) | es_AR |
| Spanish (SPA) | es_ES |
| Spanish (MEX) | es_MX |
| Swahili | sw |
| Swedish | sv |
| Tamil | ta |
| Telugu | te |
| Thai | th |
| Turkish | tr |
| Ukrainian | uk |
| Urdu | ur |
| Uzbek | uz |
| Vietnamese | vi |
| Zulu | zu |
Array fields in the string buttons#
| 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. |
Fields in the string cards#
| Parameter | Type | Required | Description |
|---|---|---|---|
headerType | string | Yes | IMAGE - the type of each card must be a image |
mediaUrl | string | Yes | Link to image |
body | string | No | Card body. If one card has it, all other cards must have it |
sampleText | string | No* | * Required if the 'body' field is present. Card description |
buttons | string | No | It is filled in the same way as the buttons array. If it is present on one card, it must be present on all other cards |
Request body example#
Example body of a request to create a template for the MARKETING category:#
{
"elementName": "ticket_check_url_4245343",
"languageCode": "en_US",
"category": "MARKETING",
"templateType": "TEXT",
"vertical": "TEXT",
"content": "your 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 ticket has been confirmed for 4 persons on date 2020-05-04.",
"enableSample": true,
"allowTemplateCategoryChange": true
}
Example body of a request to create a category template AUTHENTICATION:#
{
"elementName": "ticket_check_url_4245343",
"languageCode": "en_US",
"category": "AUTHENTICATION",
"templateType": "TEXT",
"vertical": "TEXT",
"content": "*{{1}}* is your verification code.",
"buttons": "[
{'type':'OTP','otp_type':'COPY_CODE'}
]",
"example": "*1234* is your verification code.",
"enableSample": true,
"allowTemplateCategoryChange": true
}
Example body of a request to create a category template IMAGE:#
{
"elementName": "ticket_confirmation_notification",
"languageCode": "en_US",
"category": "MARKETING",
"templateType": "IMAGE",
"vertical": "Ticket confirmation notification",
"content": "Your ticket has been confirmed for {{1}} persons on date {{2}}. Thank you for using our service!",
"example": "Your ticket has been confirmed for 4 persons on date 2025-05-04. Thank you for using our service!",
"enableSample": true,
"allowTemplateCategoryChange": true,
"mediaUrl": "https://my.site.com/img/image_for_ticket_template.jpeg"
}
Example body of a request to create a VIDEO category template:#
{
"elementName": "ticket_confirmation_notification",
"languageCode": "en_US",
"category": "MARKETING",
"templateType": "VIDEO",
"vertical": "Ticket confirmation notification with video",
"content": "Your ticket has been confirmed for {{1}} persons on date {{2}}. Thank you for using our service!",
"example": "Your ticket has been confirmed for 4 persons on date 2025-05-04. Thank you for using our service!",
"enableSample": true,
"allowTemplateCategoryChange": true,
"mediaUrl": "https://my.site.com/video/video_for_ticket_template.mp4"
}
Example body of a request to create a DOCUMENT category template:#
{
"elementName": "ticket_confirmation_notification",
"languageCode": "en_US",
"category": "MARKETING",
"templateType": "DOCUMENT",
"vertical": "Ticket confirmation notification with document",
"content": "Your ticket has been confirmed for {{1}} persons on date {{2}}. Thank you for using our service!",
"example": "Your ticket has been confirmed for 4 persons on date 2025-05-04. Thank you for using our service!",
"enableSample": true,
"allowTemplateCategoryChange": true,
"mediaUrl": "https://my.site.com/doc/document_for_ticket_template.pdf"
}
Example body of a request to create a CAROUSEL category template:#
Features of creating a CAROUSEL category template
- The only valid value for the 'category' field is 'MARKETING'; other values cannot be used.
- The carousel must contain between 2 and 10 cards.
- No more than two buttons can be added to a single card.
- The maximum number of characters in the 'body' field cannot exceed 160.
Rules for designing cards within a single carousel:
- If at least one card contains text, that text field must appear in all cards in the carousel.
- The number of buttons, their order, and type (
QUICK_REPLY,URL,PHONE_NUMBER) must match in all cards.
{
"elementName": "march_promo_carousel_ru",
"languageCode": "ru",
"category": "MARKETING",
"vertical": "March promo carousel",
"templateType": "CAROUSEL",
"content": "Spring coming, {{1}}! We have prepared a selection of our products for the spring season especially for you.",
"example": " Spring coming, John! We have prepared a selection of our products for the spring season especially for you.",
"enableSample": true,
"cards": "[{
'headerType': 'IMAGE',
'mediaUrl': 'https://example.com/image/image.png',
'body': 'HIT OF THE SEASON: Floral Print Shorts - only {{1}} USD',
'sampleText': 'HIT OF THE SEASON: Floral Print Dress - only $90',
'buttons': [{
'type': 'URL',
'text': 'Buy',
'url': 'https://example.com/shop?product_id={{1}}',
'buttonValue': 'https://example.com/shop?product_id=',
'suffix': '12345',
'example': ['https://example.com/shop?product_id=12345']
},
{'type': 'QUICK_REPLY','text': 'I want to know more'}]},
{
'headerType': 'IMAGE',
'mediaUrl': 'https://example.com/image/image.png',
'body': 'Spring collection',
'sampleText': 'Spring collection',
'buttons': [{
'type': 'URL',
'text': 'Buy',
'url': 'https://example.com/shop?catalog={{1}}',
'buttonValue': 'https://example.com/shop?catalog=',
'suffix': '12345','example': ['https://example.com/shop?catalog=12345']
},
{'type': 'QUICK_REPLY','text': 'I want to know more'}]},
{
'headerType': 'IMAGE',
'mediaUrl': 'https://example.com/image/image.png',
'body': 'Summer collection',
'sampleText': 'Summer collection',
'buttons': [{
'type': 'URL',
'text': 'Купить',
'url': 'https://example.com/shop?catalog={{1}}',
'buttonValue': 'https://example.com/shop?catalog=',
'suffix': '12345',
'example': ['https://example.com/shop?catalog=12345']},
{'type': 'QUICK_REPLY','text': 'I want to know more'}]
}]"
}
Response#
Response parameters#
| Parameter | Type | Description |
|---|---|---|
template | object | Created template object |
Response template parameters#
| Parameter | Type | Description |
|---|---|---|
buttonSupported | string | Types of buttons used in the template. |
category | string | Template category. |
containerMeta | string | A fully formed request sent to Meta for verification. |
createdOn | number | Template creation timestamp (in milliseconds) |
data | string | Data field from the template, text representation of the template. |
elementName | string | The template's name is specified in the body of the CreateTemplate request. |
languageCode | string | The template language is from the body of the CreateTemplate request. |
languagePolicy | string | Service field for defining the language for Meta. |
meta | string | The field containing a sample template. |
modifiedOn | number | Template editing timestamp (in milliseconds). Equal to createdOn when creating the template. |
namespace | string | GREEN-API Account ID. |
priority | number | The template priority given by Meta. |
quality | string | A service field for template evaluation by Meta. |
retry | number | The number of times a template is resubmitted for verification in Meta. |
stage | string | Service field of the Meta request processing stage. |
status | string | Meta verification status for the template. Can have the following values: PENDING (under consideration), APPROVED (the template has been verified and can be sent), REJECTED (the template has not been verified, Meta considers the template suspicious), FAILED (the template has not been verified, there is an error in the request body. The reason is specified in the additional reason field), PAUSED (the template has been suspended). |
templateType | string | Template type |
vertical | string | Brief description of the template for passing Meta verification. |
templateId | string | ID of the created template for interaction with it. |
Response body example#
Status code success: 200 OK.
{
"template": {
"buttonSupported": "URL",
"category": "UTILITY",
"containerMeta": "{\"data\":\"Notice: A signature is required to complete your document. You can sign it in one of the following ways:\",\"buttons\":[{\"type\":\"URL\",\"text\":\"Email\",\"url\":\"https://green-api.com/sign/{{1}}\",\"example\":[\"https://green-api.com/sign/498hge89-43985gfd\"]},{\"type\":\"URL\",\"text\":\"Code\",\"url\":\"https://green-api.com/sign/{{1}}\",\"example\":[\"https://green-api.com/sign/498hge89-43985gfd-fosdiaj3\"]}],\"sampleText\":\"Notice: A signature is required to complete your document. You can sign it in one of the following ways: \",\"enableSample\":true,\"editTemplate\":false,\"allowTemplateCategoryChange\":true,\"addSecurityRecommendation\":false,\"isCPR\":false,\"cpr\":false}",
"createdOn": 1764652442143,
"data": "Notification: A signature is required to complete your document. You can sign it in one of the following ways: | [Email,https://green-api.com/sign/{{1}}] | [Code,https://green-api.com/sign/{{1}}]",
"elementName": "invite_to_sign_document_v3",
"languageCode": "ru",
"languagePolicy": "deterministic",
"meta": "{\"example\":\"Notification: A signature is required to complete your document. You can sign it in one of the following ways:\"}",
"modifiedOn": 1764652442143,
"namespace": "e417d928_4f0d_34c1_b232_0d6fb2b80576",
"priority": 2,
"quality": "UNKNOWN",
"retry": 0,
"stage": "NONE",
"status": "PENDING",
"templateType": "TEXT",
"vertical": "invite_to_sign_document",
"templateId": "3d13e6b0-e567-495e-a8b3-55e28fb4774f"
}
}
Пример тела зпроса создания шаблона категории CAROUSEL:#
Особенности создания шаблона категории CAROUSEL
- В поле
categoryединственное допустимое значениеMARKETING, другие значения использовать нельзя. - Карусель должна содержать от 2 до 10 карточек.
- На одну карточку можно добавить не более двух кнопок.
- Максимальное количество символов в поле
bodyне может привышать 160.
Правила оформления карточек внутри одной карусели: - Если хоть одна карточка содержит текст, то текст должен быть во всех карточках карусели.
- Количество кнопок, порядок их расположения и тип (QUICK_REPLY, URL, PHONE_NUMBER) должен совпадать во всех карточках.
{
"elementName": "march_promo_carousel_ru",
"languageCode": "ru",
"category": "MARKETING",
"vertical": "March promo carousel",
"templateType": "CAROUSEL",
"content": "Весна уже близко, {{1}}! Мы подготовили специально для вас подборку наших товаров для весенней поры",
"example": "Весна уже близко, Иван! Мы подготовили специально для вас подборку наших товаров для весенней поры",
"enableSample": true,
"cards": "[{
'headerType': 'IMAGE',
'mediaUrl': 'https://example.com/image/image.png',
'body': 'ХИТ СЕЗОНА: Платье с цветочным принтом - всего {{1}} рублей',
'sampleText': 'ХИТ СЕЗОНА: Платье с цветочным принтом - всего 4990 рублей',
'buttons': [{
'type': 'URL',
'text': 'Купить',
'url': 'https://example.com/shop?product_id={{1}}',
'buttonValue': 'https://example.com/shop?product_id=',
'suffix': '12345',
'example': ['https://example.com/shop?product_id=12345']
},
{'type': 'QUICK_REPLY','text': 'Хочу узнать подробнее'}]},
{
'headerType': 'IMAGE',
'mediaUrl': 'https://example.com/image/image.png',
'body': 'Весенняя коллекция',
'sampleText': 'Весенняя коллекция',
'buttons': [{
'type': 'URL',
'text': 'Купить',
'url': 'https://example.com/shop?catalog={{1}}',
'buttonValue': 'https://example.com/shop?catalog=',
'suffix': '12345','example': ['https://example.com/shop?catalog=12345']
},
{'type': 'QUICK_REPLY','text': 'Хочу узнать подробнее'}]},
{
'headerType': 'IMAGE',
'mediaUrl': 'https://example.com/image/image.png',
'body': 'Летняя коллекция',
'sampleText': 'Летняя коллекция',
'buttons': [{
'type': 'URL',
'text': 'Купить',
'url': 'https://example.com/shop?catalog={{1}}',
'buttonValue': 'https://example.com/shop?catalog=',
'suffix': '12345',
'example': ['https://example.com/shop?catalog=12345']},
{'type': 'QUICK_REPLY','text': 'Хочу узнать подробнее'}]
}]"
}
CreateTemplate errors#
For a list of errors common to all methods, refer to Common errors section.
Request examples#
curl --location '{{apiUrl}}/waInstance{{idInstance}}/createTemplate/{{apiTokenInstance}}' \
--header 'Content-Type: application/json' \
--data 'elementName=ticket_check_url_4245343' \
--data 'languageCode=en_US' \
--data 'category=MARKETING' \
--data 'templateType=TEXT' \
--data 'vertical=TEXT' \
--data 'content=your ticket has been confirmed for {{1}} persons on date {{2}}.' \
--data 'header=This is the header' \
--data 'exampleHeader=This is the header' \
--data 'footer=This is the footer' \
--data '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'}]"' \
--data 'example=your ticket has been confirmed for 4 persons on date 2020-05-04.' \
--data 'enableSample=true' \
--data 'allowTemplateCategoryChange=true'