Sending a template is the only way to contact a customer first on WhatsApp, that is, outside the 24-hour conversation window. The template must be approved by Meta before any send.
The complete and always up-to-date reference for this endpoint is available on developers.getkanal.com.
POST https://api.getkanal.com/api/v1/templatesThis endpoint requires an active subscription. It is limited to 60 requests per minute per API key: it is the only API endpoint subject to this limit.
Authorization: Bearer <YOUR_API_KEY>
Content-Type: application/json
Idempotency-Key (optional): replaying a request with the same key does not send the message a second time. Use a unique value, for example a UUID: a key already known to Kanal is treated as a duplicate and the message is not sent.
Idempotency-Key answers that the message was already sent, although nothing went out. Use a new key for each new attempt after an error.Field | Type | Description |
|---|---|---|
| integer, required | The identifier of the template to send. |
| string, required | The recipient's number, including the country code. Non-numeric characters are ignored. |
| object, conditional | Required if the template contains variables. Flat object: each key is the name of a template variable, each value is a string. |
| string, optional | With the value "FR", removes the leading 0 and adds the 33 country code if it is missing. |
| string, optional | Name given to the contact when it is created. Defaults to "Unknown". |
| string, optional | Email given to the contact when it is created. |
The variables field is an object whose keys are the names of the variables declared in the template, not an ordered array. Kanal then builds the WhatsApp payload server-side.
{
"first_name": "Jane",
"order_id": "10456"
}"10456", not 10456. A numeric value is rejected by Meta (error 100, "expected [string, null]") and the message is not sent.Dynamic URL button: its variable uses the button text as its key, as it appears in the template. The button takes its URL from this variable. Static URL buttons and quick reply buttons need no variable.
{
"first_name": "Jane",
"Track my order": "https://example.com/orders/10456"
}Call GET /api/v1/get_templates to list your approved templates and their identifiers.
Or click your team name, then Settings > WhatsApp Templates, and open the template: the identifier is at the end of the URL.
Every approved template of your number can be sent through the API, including those created in an automation or a campaign. You can also create a template dedicated to the API in Settings > WhatsApp Templates, but this is not required.
curl -X POST https://api.getkanal.com/api/v1/templates \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: 6f1c2a9e-0b4d-4c1e-9a7f-3d2b1e0c5a88" \
-d '{
"template_id": 1234,
"phone_number": "+33612345678",
"name": "Jane Doe",
"variables": { "first_name": "Jane", "order_id": "10456" }
}'Success response (200):
{
"success": true,
"message": "Template message sent successfully",
"message_id": 987654,
"contact_id": 54321,
"phone_number": "33612345678"
}If the same Idempotency-Key is replayed, the API returns a 201 with the message Message already sent with this idempotency key, without sending the message again. This also happens if the first send had failed: after an error, use a new key.
Code | Cause |
|---|---|
| Missing or invalid API key. |
| The team has no active subscription. |
| Template not found for this number. |
| More than 60 requests per minute with the same key. The response contains |
| Missing parameter, invalid number, opted-out contact, missing template variable ( |