In India, WhatsApp is where customers actually read messages. An order confirmation, delivery update or appointment reminder on WhatsApp gets far more attention than an email, and often more than an SMS.
Businesses can send these messages officially through the WhatsApp Business Platform, using Meta’s Cloud API. This guide explains how it works, walks through a tested Python example, and covers the rules and pricing that trip people up.
The options
- WhatsApp Business app: the free app for small businesses. Manual messaging only; no API for automation.
- WhatsApp Business Platform (API): for sending messages from your own software. You can use Meta’s Cloud API directly, or go through a Business Solution Provider (BSP) such as Gupshup, Interakt, WATI, AiSensy, Twilio and many others, which add dashboards, support and extra features.
Using unofficial tools that automate WhatsApp Web or the consumer app breaks WhatsApp’s terms and risks your number being banned. Stick to the official platform.
Key concepts before you code
Templates
To start a conversation, or to message someone who hasn’t messaged you in the last 24 hours, you must use a pre-approved message template. Templates have placeholders like:
Hi {{1}}, your order #{{2}} has been shipped and should arrive by {{3}}. Track it here: ...
You submit templates in WhatsApp Manager, and Meta reviews them. Each template belongs to a category:
- Utility: updates about something the customer did or asked for: order confirmations, shipping updates, payment receipts, appointment reminders
- Authentication: one-time passcodes
- Marketing: promotions, offers, newsletters and anything else
Categorise honestly. Meta can re-categorise templates, and marketing messages are priced and restricted differently.
The customer service window
When a customer messages you, a 24-hour customer service window opens. During that window you can reply with free-form messages (text, images, documents) as well as templates. Once it closes, you can only send templates.
Opt-in
You need the customer’s permission to message them on WhatsApp, for example a checkbox at checkout saying “Send me order updates on WhatsApp”, with a clear explanation. Record the opt-in. Sending unwanted messages leads to blocks and reports, which lower your quality rating and messaging limits.
Setting up the Cloud API
- Create a Meta Business account (Business Manager) and verify your business.
- In the Meta for Developers portal, create an app and add the WhatsApp product.
- Add a phone number for WhatsApp Business. It can’t currently be registered on the regular WhatsApp app at the same time.
- Note the Phone Number ID and WhatsApp Business Account ID.
- Create a system user in Business Manager and generate a permanent access token with WhatsApp permissions. The temporary token shown in the developer portal expires quickly and is only for testing.
- Create and submit your message templates for approval.
Meta’s documentation changes regularly, so follow the current getting-started guide for the exact screens.
Sending a message from Python
"""Send WhatsApp template messages through the WhatsApp Business Cloud API."""
import os
import requests
GRAPH_VERSION = os.environ.get("WA_GRAPH_VERSION", "v23.0") # use the version in Meta's docs
PHONE_NUMBER_ID = os.environ["WA_PHONE_NUMBER_ID"] # from WhatsApp Manager
ACCESS_TOKEN = os.environ["WA_ACCESS_TOKEN"] # system user token, never hard-code
URL = f"https://graph.facebook.com/{GRAPH_VERSION}/{PHONE_NUMBER_ID}/messages"
def send_template(to: str, template: str, params: list[str], language: str = "en"):
"""Send an approved template. `to` is the number with country code, e.g. 919876543210."""
payload = {
"messaging_product": "whatsapp",
"to": to,
"type": "template",
"template": {
"name": template,
"language": {"code": language},
"components": [{
"type": "body",
"parameters": [{"type": "text", "text": p} for p in params],
}],
},
}
resp = requests.post(
URL,
json=payload,
headers={"Authorization": f"Bearer {ACCESS_TOKEN}"},
timeout=15,
)
data = resp.json()
if resp.status_code != 200:
err = data.get("error", {})
raise RuntimeError(f"WhatsApp API error {err.get('code')}: {err.get('message')}")
return data["messages"][0]["id"] # keep this to match delivery webhooks later
def send_text(to: str, body: str):
"""Free-form text: only allowed within 24 hours of the customer's last message."""
payload = {"messaging_product": "whatsapp", "to": to,
"type": "text", "text": {"body": body}}
resp = requests.post(URL, json=payload,
headers={"Authorization": f"Bearer {ACCESS_TOKEN}"}, timeout=15)
resp.raise_for_status()
return resp.json()["messages"][0]["id"]
if __name__ == "__main__":
msg_id = send_template(
to="919876543210",
template="order_shipped", # must be approved in WhatsApp Manager
params=["Asha", "1042", "15 Jan"], # fills {{1}}, {{2}}, {{3}}
)
print("Sent, message id:", msg_id)
export WA_PHONE_NUMBER_ID="your-phone-number-id"
export WA_ACCESS_TOKEN="your-system-user-token"
python whatsapp_send.py
What the code does
- Sends a POST request to
https://graph.facebook.com/<version>/<phone-number-id>/messages. - The
tonumber includes the country code without+or leading zeros, for example919876543210for an Indian mobile number. - The template
nameandlanguagemust match an approved template exactly. parametersfill the{{1}},{{2}},{{3}}placeholders in order.- On success, the API returns a message ID (starting with
wamid.). Save it, because delivery updates refer to it. - On failure, we raise an error containing Meta’s error code and message, so problems are visible in your logs.
We tested the request building and error handling with mocked responses: the payload was formed correctly, the success path returned the message ID, and an error response (such as an unknown template name) raised a clear exception.
The API version is configurable through WA_GRAPH_VERSION, because Meta releases new Graph API versions regularly and older ones are retired. Check the current version in Meta’s docs.
Delivery status with webhooks
Sending successfully doesn’t mean the message was delivered or read. WhatsApp reports status changes by calling your webhook:
sent: accepted by WhatsAppdelivered: reached the customer’s phoneread: opened (if the customer has read receipts enabled)failed: with an error code explaining why
Incoming customer replies arrive through the same webhook.
A minimal webhook needs to:
- Verify the subscription: when you register the webhook, Meta sends a GET request with
hub.mode,hub.verify_tokenandhub.challenge. Check the token matches yours and return the challenge. - Receive events: handle POST requests with JSON payloads, respond quickly with HTTP 200, and process events in the background.
- Validate signatures: check the
X-Hub-Signature-256header using your app secret, so you only accept genuine requests from Meta. - Be idempotent: the same event can arrive more than once.
Store each message’s status against your order or notification record. That lets you fall back to SMS or email when WhatsApp delivery fails.
Pricing in brief
Since 1 July 2025, the WhatsApp Business Platform charges per message rather than per 24-hour conversation:
- Marketing and authentication templates are charged per delivered message.
- Utility templates are charged per delivered message outside the customer service window, and are free inside it.
- Free-form (non-template) replies within the customer service window are free.
Rates vary by country and category, and Meta updates them periodically, including volume-based discounts for utility and authentication messages. BSPs may add their own fees. Check the current rate card for India before estimating costs.
A practical cost tip: design flows so customers message you first where it’s natural, for example “Reply HI to get your invoice”. That opens a service window in which replies and utility templates are free.
Messaging limits and quality
New numbers start with a limit on how many unique customers they can message in 24 hours. As you send good-quality messages, the limit increases. If many customers block or report you, your quality rating drops, and Meta may restrict your number or pause templates.
To stay in good standing:
- message only people who opted in
- keep messages relevant, timely and short
- make opting out easy, and honour it immediately
- don’t send marketing disguised as utility
Good use cases
- order confirmation with invoice PDF
- shipping and delivery updates
- payment receipts and payment reminders
- appointment and booking reminders
- OTPs for login (using authentication templates)
- service request status updates
- two-way customer support, connected to a helpdesk or chatbot
Common errors
- Template not found or not approved: check the exact name, language code and approval status.
- Parameter count mismatch: the number of parameters must match the template’s placeholders.
- Recipient not a WhatsApp user, or invalid number format: validate numbers and use the full international format.
- Re-engagement error: you tried to send a free-form message outside the 24-hour window. Use a template.
- Token expired: you’re using a temporary token. Switch to a system user token.
Conclusion
The WhatsApp Business Cloud API lets your application send the updates customers actually read. Get the foundations right, which means a verified business, approved templates, proper opt-in, webhook tracking and secure token storage, and the code itself is just a simple POST request.
Start with one high-value utility message, such as order shipped or appointment reminder, measure delivery and response, then expand.
Leave a Comment