Send your first template message
WhatsApp lets a business start a conversation only with a message it has approved in advance, called a template. This guide sends one, then checks that it arrived. You need an API key (make one) and one approved template.
First, why a template? #
WhatsApp has one rule that shapes everything: you may write freely to a customer for 24 hours after their last message to you. Outside that window, only an approved template gets through. So an order update, a reminder or a first hello is a template; a reply to a question is ordinary text.
Templates are written in Chatilo under Templates and sent to WhatsApp for approval, which usually takes minutes. A template has a name, a language and numbered placeholders such as {{1}} that you fill in when sending.
"sandbox": true in the list of numbers), messages sent from it are only pretended: nothing reaches a real phone, and each one is marked delivered a moment later. It is a safe place to follow this guide.-
Check which number you are sending from #
List the workspace’s WhatsApp numbers. With one number you can skip this; with several, note the
idof the one to send from.curl "https://chatilo.me/api/v1/numbers" \ -H "Authorization: Bearer YOUR_API_KEY" -
Find an approved template #
List the templates that can be sent, and look at what each needs filled in:
curl "https://chatilo.me/api/v1/templates?status=APPROVED" \ -H "Authorization: Bearer YOUR_API_KEY"{ "ok": true, "templates": [ { "name": "order_update", "language": "en", "category": "UTILITY", "status": "APPROVED", "variables": { "header": "none", "header_vars": 0, "body_vars": 2 }, "id": 12, "number_id": 1 } ] }body_vars: 2means the body has{{1}}and{{2}}, so you will send two values. To read the template’s text, ask for the template by id. -
Send it #
Give the phone number with its country code, the template’s name and language, and the values for the body in order. The
Idempotency-Keymakes it safe to retry if the connection drops: the same key never sends twice.curl -X POST "https://chatilo.me/api/v1/messages" \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Idempotency-Key: order-1042-shipped" \ -H "Content-Type: application/json" \ -d '{ "to": "+919876543210", "type": "template", "template": { "name": "order_update", "language": "en", "body": [ "Grace", "#1042" ] } }'{ "ok": true, "message": { "id": 3001, "status": "sent", "conversation_id": 2001, "contact_id": 1001 } }If that number wasn’t a contact yet, it is now.
sentmeans WhatsApp accepted the message, not that it has reached the phone. -
See whether it arrived #
Ask for the message a few seconds later. Its status moves from
senttodeliveredand thenread, or tofailedwith the reason inerror.curl "https://chatilo.me/api/v1/messages/3001" \ -H "Authorization: Bearer YOUR_API_KEY"
Fill in the customer’s own details #
A value can be a placeholder that Chatilo fills from the contact: {{name}}, {{first_name}}, {{phone}}, {{email}}, or any of the contact’s custom attributes such as {{city}}. So "body": ["{{first_name}}", "#1042"] greets each person by name without you looking it up.
If the template has a text header with a variable, send it as "header": "…". If it has an image, video or document header, header is a public https link to the file.
When they reply #
The customer’s reply opens the 24-hour window. Now you can answer with ordinary text, in the conversation the template started:
curl -X POST "https://chatilo.me/api/v1/conversations/2001/messages" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"type": "text",
"text": "It’s out for delivery and should reach you today."
}'To hear about replies the moment they come in, subscribe to the message.received event: see webhooks.
If it doesn’t work #
| You get | It means | Do this |
|---|---|---|
template_not_found | No approved template with that name and language on the sending number. | Check the spelling and the language code, and that its status is APPROVED. |
opted_out | The customer replied STOP. | Don’t message them. They can reply START to opt back in. |
invalid_phone | The number has no country code or the wrong length. | Send it as +919876543210. |
window_closed | You sent text, not a template, and the customer hasn’t written in 24 hours. | Send a template. |
send_failed | WhatsApp refused the message. | The message text carries WhatsApp’s reason. |