Template-based messages are the standard way to start a conversation with a customer on WhatsApp, especially when you contact a user outside the 24-hour conversation window.
This guide covers how the template-sending endpoint works and how to structure your data.
To send a template, make an HTTP POST request to the following address:
URL: https://api.getkanal.com/api/v1/templates
As with all requests to the Kanal API, include the following headers so our servers accept your call:
Content-Type: application/json
Authorization: Bearer <YOUR_API_KEY>
The body of your request must be sent in JSON format and contain the following information:
This is the unique identifier of the template you want to send.
Where do you find the template ID?
Go to your Kanal interface, in the "WhatsApp Templates" section. Click the template you want to use. The ID is the number shown at the end of the URL in your browser (for example: .../templates/123, the ID is 123).
The recipient's phone number.
Important: The number must be provided in international E.164 format. It must include the country code, without the "+" sign or the leading "00". (Example for France: 33612345678).
This is the name you want to temporarily assign to the contact in your Kanal database.
Technical note: This name is used in your Kanal interface until the customer replies. As soon as the customer sends a message back, Kanal automatically updates this field with the actual name set by the user on their WhatsApp profile.
If your template contains personalization variables (e.g. {{1}}, {{2}}), you must provide the replacement values in an array. The order of the items in the array must exactly match the order of the variables in the template approved by Meta.
Here is a concrete example of what to send in the body of your request for an order confirmation template with two variables (the first name and the order number):
{
"template_id": 123,
"phone_number": "33612345678",
"name": "John Smith",
"variables": ["John", "FR-98765"]
}
To quickly test your integration from a terminal, you can use the following command:
curl -X POST "[https://api.getkanal.com/api/v1/templates](https://api.getkanal.com/api/v1/templates)" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"template_id": 123,
"phone_number": "33612345678",
"name": "John Smith",
"variables": ["John", "FR-98765"]
}'
Template approval: Make sure the template is marked "Approved" in your Kanal interface before attempting to send it via the API. A template pending review or rejected by Meta will cause an error.
Number format: Most failed sends come from a badly formatted number. Always check that the country code is valid before sending.
Variable handling: If your template was approved with 3 variables, you must send an array containing exactly 3 values. A mismatch between the template and the number of variables sent will cause the request to be rejected.