Templates#
Templates are managed on the WhatsApp Business Account (WABA), not on the phone number. kenari forwards the message_templates edge of any WABA connected to your account.
| Action | Request |
|---|---|
| List templates | GET /{version}/{waba_id}/message_templates |
| Create a template | POST /{version}/{waba_id}/message_templates |
| Delete a template | DELETE /{version}/{waba_id}/message_templates |
| Send a template | POST /{version}/{phone_number_id}/messages (see below) |
The query string and body go to Meta exactly as you send them, so you can use Meta's filters, paging cursors and delete parameters as documented. The only exceptions are access_token and appsecret_proof, which kenari removes and replaces.
List#
curl "https://api.kenari.dev/v21.0/$WABA_ID/message_templates?limit=20" \ -H "Authorization: Bearer $KENARI_API_KEY"Create#
curl -X POST "https://api.kenari.dev/v21.0/$WABA_ID/message_templates" \ -H "Authorization: Bearer $KENARI_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "name": "order_shipped", "language": "en", "category": "UTILITY", "components": [ { "type": "BODY", "text": "Your order {{1}} has shipped." } ] }'Meta reviews new templates. Their status changes arrive as message_template_status_update webhook events. See Webhooks.
Delete#
curl -X DELETE "https://api.kenari.dev/v21.0/$WABA_ID/message_templates?name=order_shipped" \ -H "Authorization: Bearer $KENARI_API_KEY"Send a template#
Sending goes through the phone number's messages edge, like any other message:
curl -X POST "https://api.kenari.dev/v21.0/$PHONE_NUMBER_ID/messages" \ -H "Authorization: Bearer $KENARI_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "messaging_product": "whatsapp", "to": "6281234567890", "type": "template", "template": { "name": "order_shipped", "language": { "code": "en" }, "components": [ { "type": "body", "parameters": [{ "type": "text", "text": "#1042" }] } ] } }'What's not forwarded#
Only the message_templates edge of a WABA is on the allow-list. Other template calls return 404 KenariRoutingException, including reading or editing a single template by its template id (/{version}/{template_id}).
Things to know#
- Rate limit. All template calls (list, create and delete) share the WABA's 5,000 requests/hour bucket. Template sends count against the number's per-second bucket instead. See Rate limits.
- The WABA and its numbers must be healthy. Template calls return
422KenariNotConnectedExceptionif the WABA's token is revoked or the WABA is disconnected. They also return it if any number still connected on that WABA is restricted, flagged or not registered. The message names the problem. - Test keys. A
kn_test_…key can call a WABA's templates only if every connected number on that WABA is aSANDBOXnumber. Otherwise the call returns401.