POST /v1/templates makes a template and sends it to WhatsApp for review, with the same rules as the app. It starts as pending; you get template.status_changed when WhatsApp approves or rejects it. A Full key is needed.
Name, language and category
name: lowercase letters, numbers and underscores.language: a language code, e.g.enorhi.category:marketing,utilityorauthentication.
Text
body: the message, at most 1,024 characters. It is needed for marketing and utility templates.footer: optional, at most 60 characters, no variables.
Header
header is optional. One of:
- Text:
{"type": "text", "text": "Order {{order}}"}— at most 60 characters and one variable. - A file:
{"type": "image", "url": "https://…"},"video"or"document". The file is the sample WhatsApp reviews: an image JPEG or PNG up to 5 MB, a video MP4 up to 16 MB, a document PDF up to 100 MB. When you send the template you give the file each person gets.
Variables
Write a variable as{{name}}: lowercase letters, numbers and underscores, starting with a letter. A variable can’t be the first or last thing in the body, and two can’t stand side by side.
Give a sample for each variable in examples, by where it is:
"body:name": "Riya"for the body,"header:order": "#4521"for a text header,"button:1:code": "DIWALI20"for a link button’s variable (1 is the button’s place inbuttons, from 0).
Buttons
buttons holds up to 10, in this order of kinds: quick replies together, the others together.
A coupon code itself is given when you send the template (
buttons with type: "copy_code" and its value).
OTP (authentication)
An authentication template has no body of your own: WhatsApp writes the words (“482915 is your verification code.”) and adds a button that copies the code.auth.add_security_recommendation: adds “For your security, do not share this code.”auth.code_expiration_minutes: 1 to 90; adds “This code expires in N minutes.”auth.button_text: the button’s text (optional).
POST /v1/messages/otp — see Sending OTPs.
Edit and delete
PATCH /v1/templates/{name}?language=en: change the body, footer, header, buttons or samples; it goes for review again. The name and language stay, and an approved template’s category stays. WhatsApp allows an approved template to be edited once in 24 hours and 10 times in 30 days (template_edit_limit).DELETE /v1/templates/{name}: moves it to the bin (one language with?language=, or every language of the name).
Not available yet
These can’t be made with the API today — see What is not available yet:- Numbered variables (
{{1}}). A template made elsewhere with numbered variables can still be sent. - Carousel templates.
- Limited-time offer templates.
- Catalog, product, flow and call-permission buttons.