The WhatsApp Business API lets developers build automated messaging systems on top of WhatsApp. Businesses use it to send order confirmations, payment receipts, appointment reminders, and customer support replies at scale. Unlike the free WhatsApp Business App, the API supports programmatic access, webhooks, and integration with backend systems. It is conversation-based pricing, meaning you pay per 24-hour conversation window, not per message.
You probably use WhatsApp every day. You open the green app, type a message, send it. Simple. The WhatsApp Business API lets software do the same thing, but programmatically. Instead of a person typing messages, your code sends and receives them through an API.
This matters because it enables automation. A human can handle maybe 20 customer conversations simultaneously. A well-built WhatsApp integration can handle thousands. When a customer makes an M-Pesa payment, your system automatically sends them a WhatsApp receipt. When a delivery driver marks an order as dispatched, the customer gets a WhatsApp update with a tracking link. No human involved.
There are three WhatsApp products for businesses, and confusing them causes problems:
When someone says "build a WhatsApp bot" or "integrate WhatsApp into our system," they mean the Business API. The Business App is just a mobile application with some extra features. The API is the tool that lets you write code.
The single most important concept in the WhatsApp Business API is the 24-hour conversation window. If you do not understand this rule, you will build something that violates WhatsApp's policies and gets your number restricted.
Here is how it works:
When a user messages you first. A 24-hour window opens. During this window, you can reply with any type of message: text, images, documents, interactive buttons, lists. No restrictions on content. This is called a "service conversation" and it is free. You are responding to the user's inquiry, so WhatsApp considers it customer service.
When you want to message a user first. Outside the 24-hour window (or if the user has never messaged you), you cannot send a free-form message. You must use a pre-approved message template. Templates are structured messages that Meta reviews and approves before you can use them. They have a specific format with variable placeholders for dynamic content.
This rule exists because Meta does not want WhatsApp to become a spam channel. They want businesses to use it for relevant, expected communication, not bulk marketing blasts. If you violate the rules, your quality rating drops, your sending limits get restricted, and in extreme cases your account gets suspended.
What this means for your architecture: design your system around two flows. The reactive flow handles incoming user messages (customer asks a question, your bot or support agent responds). The proactive flow sends outbound messages using templates (payment confirmations, delivery updates, appointment reminders). Both flows use the same API but follow different rules.
Get weekly developer tips
Join 25,000+ developers. Practical guides, job tips, and new content — straight to your inbox.
No spam. Unsubscribe anytime.
Templates are the gatekeepers of outbound messaging. You define a template, submit it to Meta for review, and once approved, you can use it to start conversations with users. The review process usually takes minutes to hours, but can take days for complex templates.
A template looks like this:
Hi {{1}}, your order #{{2}} has been dispatched.
Estimated delivery: {{3}}.
Track your order: {{4}}
The {{1}}, {{2}}, etc. are variables that you fill in when sending the message. Meta approves the template structure, and you provide the dynamic values at send time.
Templates that get approved quickly:
Templates that get rejected:
Four template categories, each with different pricing:
Meta offers two ways to access the WhatsApp Business API. The Cloud API (hosted by Meta) and on-premise API (you host the infrastructure). For any developer starting out, the Cloud API is the clear choice. It is free to use (you only pay per conversation), Meta handles the servers, and setup takes under an hour.
Here is the quick path to sending your first message:
1. Create a Meta Developer account at developers.facebook.com. You need a regular Facebook account to log in (yes, this is annoying if you do not use Facebook, but there is no way around it).
2. Create a new app and add the WhatsApp product. Meta gives you a test phone number and a temporary access token. The test number is not a real WhatsApp number. It is a sandbox for development.
3. Add test recipients. During development, you can only send messages to phone numbers you have explicitly added as test recipients in the Meta Developer dashboard. This prevents accidental spam.
4. Send a test message using a curl command or your preferred HTTP client. The endpoint is a standard REST API. Send a POST request with your access token, the recipient's phone number, and the message content. If everything is set up correctly, the recipient gets a WhatsApp message within seconds.
5. Set up webhooks to receive incoming messages. Meta sends a POST request to your server whenever a user messages your number, reads your message, or interacts with a button. You need a publicly accessible URL for this (ngrok works during development).
The alternative to the Cloud API is a BSP (Business Solution Provider) like Africa's Talking, 360dialog, or Twilio. BSPs add features like analytics dashboards, team inboxes, and dedicated support, but they charge a monthly fee on top of Meta's pricing. For learning and small projects, the Cloud API is enough. Consider a BSP when your business needs justify the cost.
Pricing is per conversation, not per message. Once a conversation opens (either user-initiated or business-initiated), you can exchange as many messages as needed within that 24-hour window without additional charges.
For Kenya (rates as of mid-2026, check Meta's pricing page for current numbers):
How this compares to SMS: An SMS through Safaricom or an aggregator costs roughly KES 1 to KES 2 per message. A WhatsApp utility conversation costs roughly KES 0.65 to KES 1 and lets you send multiple messages (including images and documents) within the window. For transactional messaging, WhatsApp is cheaper than SMS per interaction and offers a richer experience.
Hidden costs to budget for: A dedicated phone number (KES 200 for a Safaricom SIM), server hosting for your webhook endpoint (KES 500 to KES 2,000/month for a basic VPS), and developer time. If using a BSP, add their monthly platform fee (typically $50 to $200/month). The Meta Cloud API itself has no monthly fee.
For a small Kenyan business sending 500 transactional messages per month, total WhatsApp API costs are under KES 1,000 monthly. That is less than most businesses spend on airtime for customer calls.
The API supports text messages, images, documents (PDFs, spreadsheets), location sharing, contact cards, and interactive elements (buttons, lists, quick replies). This gives you a lot of design space for building useful products.
Customer support bot. Automated responses to common questions. A user messages "what are your hours?" and gets an instant reply. More complex queries get routed to a human agent. This is the most common WhatsApp API use case in Kenya.
Order management. Customer places an order through an interactive WhatsApp menu (list of products, quantity selection, delivery address). System triggers an M-Pesa STK Push for payment. Customer receives order confirmation, preparation updates, and delivery notification, all through WhatsApp.
Appointment booking. Clinics, salons, and service businesses let customers book through WhatsApp. "Pick a date" shows a list of available slots. Customer selects one. System confirms the booking and sends a reminder the day before.
Payment notifications. After an M-Pesa payment is processed, your system sends a WhatsApp receipt with the transaction details, amount, reference number, and a thank-you message. Richer than an SMS receipt and more likely to be read.
Delivery tracking. E-commerce and logistics companies send real-time updates: order confirmed, picked up, in transit, out for delivery, delivered. Each update is a message in the same WhatsApp conversation, creating a timeline the customer can scroll through.
If these use cases interest you, our Full-Stack Software and AI Engineering course (KES 120,000) covers WhatsApp API integration as part of the African Stack module. You build working integrations with M-Pesa and WhatsApp together.
Learning from other people's mistakes is cheaper than making your own. Here are the ones we see most often.
Using a personal number for the API. You cannot register a number that is already on regular WhatsApp or the WhatsApp Business App. You need a dedicated number. Buy a new SIM specifically for the API. If you try to use your personal number, you will lose access to your personal WhatsApp account during the migration process.
Ignoring business verification. You can build and test without Meta business verification, but you cannot go live. The verification process takes 2 to 7 business days and requires official documents (business registration certificate, KRA PIN certificate). Start this process on day one, not when your code is ready.
Sending marketing without opt-in. Meta monitors your message quality. If users report or block your messages, your quality rating drops and your sending limits get restricted. Only send marketing messages to users who have explicitly opted in. Transactional messages (order updates, receipts) are fine because the user initiated the relationship.
Building complex flows as one long conversation. WhatsApp is a chat interface, not a form. If your flow requires 10 inputs from the user, it will feel tedious as a back-and-forth chat. Keep interactions short. Three to five exchanges is the sweet spot. For complex data collection, send a link to a web form instead of collecting everything through chat.
Not handling webhook failures. Meta sends webhooks for incoming messages, read receipts, and status updates. If your server is down or responds slowly, Meta retries with exponential backoff and eventually stops trying. Build your webhook handler to be reliable, fast, and idempotent (able to handle duplicate deliveries without side effects).
KES 9,999
Master Daraja API, STK Push, C2B, B2C, and callback handling. Build a real payment flow from scratch. 10 modules, 57 lessons.
Enrol in M-Pesa Integration