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(andheader.variablesfor a text header) are the values you must give.buttonslists the buttons in order, with theirindex. A button withneeds_value: trueneeds 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
Usemessage.type template, the template name and language, the variables by name, and the button values by index:
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: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 incontent.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:
Message::template('login_code', 'en')->code('482913').
Errors
Shortext checks the template before sending it and answerscode 1002 with a message you can act on: