API: list and send WhatsApp templates
Two endpoints let your software use your WhatsApp templates. GET /api/v1/whatsapp/templates lists your approved templates, and POST /api/v1/whatsapp/send-template sends one to a customer from your default number. Both need a key with WhatsApp access.
- Where
- Ask Menuthere support for a key
- Plan
- Needs a connected WhatsApp Business number, which starts on Pro.
- Updated
List your templates
curl 'https://menuthere.com/api/v1/whatsapp/templates' -H 'Authorization: Bearer ck_live_YOUR_KEY'
It returns the approved templates on your default number, so you know the exact name and how many values each one needs.
| Field | Meaning |
|---|---|
| name, language | The template's name and language code. |
| category, status | Category such as MARKETING or UTILITY. Status is APPROVED. |
| body_variables | How many {{n}} values the body needs. |
| has_header, header_format | Whether there is a header, and TEXT, IMAGE, VIDEO or DOCUMENT. |
Send a template
POST /api/v1/whatsapp/send-template with a JSON body. The message goes out from your default sender, set under Several numbers and the primary number. You cannot choose the number in the call.
| Field | Required | What it is |
|---|---|---|
| to | Yes | The customer's number with country code. |
| template_name | Yes | The name from the list call. |
| language | No | Looked up from the approved template if you leave it out. |
| body_params | No | Array of values for {{1}}, {{2}} and so on, in order. |
| header_params | No | Array of values for a text header. |
| header_media_url, header_media_type | No | A link and image, video or document for a media header. |
| button_params | No | Array of values for a dynamic URL button. |
| idempotency_key | No | A reference you choose. id and an Idempotency-Key header work too. |
A successful send returns ok: true, the message_id, the to number and status: "sent". If you send the same idempotency key again, you get the first result back with duplicate: true and nothing is sent twice. A failed send releases the key so you can retry.
Errors and limits
| Status | `error` | Meaning |
|---|---|---|
| 400 | missing_fields, invalid_json, invalid_number, template_error | A required field is missing, the number looks wrong, or the template is wrong for the values you sent. |
| 404 | template_not_found | No approved template with that name on your default number. |
| 409 | recipient_opted_out | The customer replied STOP. No message is sent. |
| 409 | in_progress | A request with the same idempotency key is still running. |
| 412 | no_whatsapp_number | No default WhatsApp number is connected. |
| 429 | daily_limit_reached, rate_limited | Your number's daily WhatsApp limit is used up, or the key is over its rate limit. |
| 502 | send_failed | WhatsApp could not be reached. Try again. |
Questions
Can I send a normal text message through the API?
Will it message someone who opted out?
Related
Can't find it? Email [email protected] or chat with us, 9 AM – 9 PM.Help centerPricingmenuthere.com
