Skip to main content
Templates are the only messages WhatsApp accepts outside the 24-hour window. They must be approved by Meta first: create them in the dashboard, through the API or with a hosted link, see Create WhatsApp templates.
In the dashboard, the Use action of a template (Communication > WhatsApp templates) gives the ready-to-copy code that sends it, filled with its examples: API v2.0, PHP SDK and API v1.0.

1. Find the template

GET /templates?channel_id={whatsapp channel id}&status=APPROVED lists the templates a number can send (key with Send messages):
  • body.variables (and header.variables for a text header) are the values you must give.
  • buttons lists the buttons in order, with their index. A button with needs_value: true needs a value when you send the template: the end of a dynamic link, the coupon of a copy-code button, or the code of an authentication template.

2. Send it

Use message.type template, the template name and language, the variables by name, and the button values by index:
To send a template in an existing conversation, post the same message to POST /conversations/{id}/messages.

Buttons

content.buttons gives the value of each button by its index (from 0):
Static links and call buttons take no value.

Media header

For a template with an image, video or document header, give its URL:
Without url, the media stored with the template is used. A document also takes a filename.

Authentication templates

An authentication template carries a one-time code. Send it in content.code: Shortext puts it in the body and in the code button.

Billing category

You are billed for the category Meta approved for the template (UTILITY, MARKETING or AUTHENTICATION), whatever you send.

With the PHP SDK

The PHP SDK (composer require nycorp/shortext-php, version 2.1 or later) builds the same message:
For an authentication template: Message::template('login_code', 'en')->code('482913').

Errors

Shortext checks the template before sending it and answers code 1002 with a message you can act on: