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:
Parameter | Data Type | Description | Example | Mandatory |
---|---|---|---|---|
sid | String | Account SID (Security Identifier). | HXXXXXXX071US | Yes |
content-type | String | The format in which the data is sent. | application/x-www-form-urlencoded | Yes |
api-key | String | API key generated from Kaleyra.io account. | Axxxxxxxxxxxxxxxxxxxxxxxxxxxx3 | Yes |
name | String | Template name. | Kaleyra_01 | Yes |
language | String | The language in which, you want to create the template. | en_us | Yes |
category | String | Select one of the following: - Marketing -Authentication - Utility | Marketing | Yes |
header_content_type | String | Select one of the following: Text Image Video Document None | Text | Yes |
header_content | String | Header text | Text | Yes |
body | String | Body of the message. | Hi, this is a WhatsApp test message. | Yes |
footer_content | String | Footer text | Text | No |
waba_id | String | WhatsApp Business Account ID | xxxxxxxxxxxxxx74443 | Yes |
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.
Updated 12 months ago