Create a WhatsApp Template with Text

POST Method

Kaleyra.io allows you to create a WhatsApp template using the API. After you create a WhatsApp template, it has to get approved by Meta before you can use the WhatsApp template to send messages.

Template Category

📘

Note:

Marketing, Authentication, and Utility template categories are supported by Kaleyra. For more information, see the WhatsApp Template Category page.

Base URL

<https://api.kaleyra.io/v1/><SID>

To create the WhatsApp template, perform the following:

Signup or Login to Kaleyra.io and create your API key

Refer to the Create an API Key page for steps to create your API key. To view the API Key and the SID, see View API Key and SID.

📘

Note:

After you sign up, your account will be on the trial version. You must complete the KYC to access all the features in Kaleyra.io.

API Request to Create WhatsApp template

To create the WhatsApp template, use the whatsapp/template endpoint with the following request method:

Request format

curl --location --request POST '{{url}}/v1/{{sid}}/whatsapp/template' \
--header 'api-key: {{api-key}}' \
--header 'Content-Type: {{content_type}}' \
--data-raw '{
	"name":"{{template_name}}",
	"language":"{{template_language}}",
	"category":{{template_category}},
	"header":{{header_content_type}},
	"header_content":"{{header_content}}",
	"body": "{{message_body}}",
	"footer_content": "{{footer_content}}",
	"waba_id": {{whatsapp_business_id}}
}'

The following table displays the parameter used to create WhatsApp template API:

ParameterData TypeDescriptionExampleMandatory
sidStringAccount SID (Security Identifier).HXXXXXXX071USYes
content-typeStringThe format in which the data is sent.application/x-www-form-urlencodedYes
api-keyStringAPI key generated from Kaleyra.io account.Axxxxxxxxxxxxxxxxxxxxxxxxxxxx3Yes
nameStringTemplate name.Kaleyra_01Yes
languageStringThe language in which, you want to create the template.en_usYes
categoryStringSelect one of the following:
- Marketing -Authentication
- Utility
MarketingYes
header_content_typeStringSelect one of the following:
Text
Image
Video Document
None
TextYes
header_contentStringHeader textTextYes
bodyStringBody of the message.Hi, this is a WhatsApp test message.Yes
footer_contentStringFooter textTextNo
waba_idStringWhatsApp Business Account IDxxxxxxxxxxxxxx74443Yes

Sample Request Format

The following is the sample request format to create a WhatsApp template:

curl --location --request POST 'https://api.kaleyra.io/v1/HXXXXXXX071US/whatsapp/template' \
--header 'api-key: Axxxxxxxxxxxxxxxxxxxxxxxxxxxx3' \
--header 'Content-Type: application/json' \
--data-raw '{
	"name":"new_template_1",
	"language":"en",
	"category":"marketing",
	"header: {
      type": "none"
   },
	"body": "Hi {{$1}},This is WhatsApp test message.",
	"footer_content": "footer",
	"waba_id": xxxxxxxxxxxxxx74443
}'

Sample Success Response

The following success message appears with status 200:

{
    "status": 200,
    "message": "Template created successfully.",
    "data": [],
    "error": {}
}

Error Codes

For information related to the WhatsApp error code, see WhatsApp Error Codes.