Skip to content

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.
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, character limit 1028.
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.
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.
allowTemplateCategoryChange boolean No Boolean value. If TRUE, WhatsApp will automatically update the template category according to the template content. The default value is FALSE. If the category is updated, you can view the old category via the GetTemplates method.
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

Request body example#

{
    "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": false
}

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 WABA 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": {
    "appId": "****f7-***33-4**d-8f***-c***d*****",
    "category": "MARKETING",
    "createdOn": 1652768999707,
    "data": "Hi, you Welcome to Header.\nHi, {{1}}. This is the template for header testing.\nHi, Welcome to Footer. | [call,917676767676] | [ur,https://www.fb.com]",
    "elementName": "test_template12332",
    "id": "f****a-f****-4**2-8***4-dc****ea",
    "languageCode": "en",
    "languagePolicy": "deterministic",
    "master": true,
    "meta": "{\"example\":\"Hi, [john]. This is the template for header testing.\"}",
    "modifiedOn": 1652768999707,
    "namespace": "e***3_e5**_**de_***3_20****1b",
    "status": "PENDING",
    "templateType": "TEXT",
    "vertical": "Header",
    "allowTemplateCategoryChange": "false"
  }
}

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://greenwaba.io/{{1}}','example':['https://greenwaba.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=false'