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. The full API documentation is available at developers.getkanal.com.
Prerequisite: create the template
A template meant to be sent via the API must be created from Settings then WhatsApp Templates in your Kanal interface, not from an automation or a campaign. This is where you retrieve the identifier required for the call. The template must be approved by Meta before any send.
Endpoint
To send a template, make an HTTP POST request to the following address:
POST https://api.getkanal.com/api/v1/templatesAuthentication and headers
As with all requests to the Kanal API, include the following headers:
Content-Type: application/jsonAuthorization: Bearer <YOUR_API_KEY>
Request parameters
The request body is in JSON format and contains the following fields:
template_id (number)
The unique identifier of the template to send. To find it: go to Settings then WhatsApp Templates, click the template you want. The ID is the number shown at the end of the URL in your browser (for example .../templates/123, the ID is 123).
phone_number (string)
The recipient's number in international E.164 format, with the country code but without the "+" sign or leading "00". Example for France: 33612345678.
name (string)
The name temporarily assigned to the contact in your Kanal database. As soon as the customer replies, Kanal automatically replaces this value with the name set on their WhatsApp profile.
variables (array)
If your template contains variables ({{1}}, {{2}}), provide the replacement values in an array. The order must exactly match the order of the variables in the template approved by Meta.
Example request
Request body for an order confirmation template with two variables (first name and order number):
{
"template_id": 123,
"phone_number": "33612345678",
"name": "John Smith",
"variables": ["John", "FR-98765"]
}Example call via cURL
curl -X POST "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"]
}'Best practices
Template approval: the template must have the "Approved" status before any send. A pending or rejected template causes an error.
Number format: most failures come from a badly formatted number. Check the country code before sending.
Number of variables: the array must contain exactly as many values as the template has variables. Any mismatch causes the request to be rejected.
