Evolvier Engineering Team
Engineering
10 min read
In the GCC, India, and much of Africa, WhatsApp is not a marketing channel bolted onto commerce — it is where the buying conversation already happens. Customers ask about stock in the thread, negotiate in the thread, and expect to pay in the thread. The WhatsApp Business API is how you serve that demand programmatically instead of with an agent copy-pasting payment links from a spreadsheet.
It is also one of the most misunderstood APIs we integrate. It is not a free-form messaging socket. It is a regulated pipe with strict windowing rules, a template review process, per-message pricing, and a quality score that can throttle your channel overnight. Teams that treat it like a generic REST API ship something that works in a demo and degrades in production. This guide covers what the API actually gives you, what you have to build around it, and the trade-offs that decide whether conversational commerce earns its keep.
What the API is — and what it is not
WhatsApp has three distinct surfaces, and conflating them is the first mistake:
- The consumer app. Person-to-person messaging. Automating it with unofficial tools violates WhatsApp's terms and gets numbers banned — more on that under failure modes.
- The WhatsApp Business app. Free, manual, built for a sole trader answering chats from a phone. No meaningful automation surface.
- The WhatsApp Business Platform (the API). Programmatic send and receive over HTTPS and webhooks. This is the layer commerce systems are built on.
The API itself comes in one practical flavor now: the Cloud API, hosted by Meta. The legacy on-premises API — the one older tutorials describe as Docker containers you run yourself — has been retired, so any architecture guidance that assumes self-hosted WhatsApp infrastructure is obsolete. You call Meta's Graph API to send; Meta calls your webhook endpoint to deliver inbound messages and status updates.
What the API gives you: text and media messaging, message templates for business-initiated contact, interactive messages (reply buttons and list menus), product catalogs, and WhatsApp Flows for structured in-chat forms. What it pointedly does not give you: an inbox, conversation state, cart logic, payment processing in most countries, retry semantics, or analytics. Everything in that second list is software you build or buy — which is why "we integrated WhatsApp" means very little until you ask what sits behind the webhook.
Choosing your access path: direct Cloud API or a BSP
You can consume the Cloud API directly from Meta or through a Business Solution Provider (BSP) such as Twilio, 360dialog, Vonage, or Infobip. This is the first real architectural decision, and it is a trade-off, not a ranking.
Go direct to the Cloud API when:
- You have an engineering team that will own webhook infrastructure, token rotation, and Graph API version upgrades anyway.
- Message volume is high enough that per-message markups compound into real money.
- You want new platform features — Flows, catalog message types, commerce settings — the day Meta ships them, not after a vendor wraps them.
Go through a BSP when:
- You need one vendor for SMS, voice, and WhatsApp, and consolidated billing matters more than per-message cost.
- Volume is low and the engineering appetite for running ingestion infrastructure is lower.
- You want bundled tooling — hosted inboxes, template managers — and accept the abstraction.
Either way, the commerce logic is yours. No BSP ships your cart state machine, your catalog sync, or your fulfillment loop. The vendor decision moves the transport layer around; it does not remove the integration engineering.
The messaging rules that shape every architecture
The API's constraints are not fine print — they are the load-bearing walls of your design.
The 24-hour window. When a customer messages you, a service window opens. Inside it, you can reply with free-form text, media, and interactive messages. Once it closes, you can only re-initiate contact with a pre-approved template message. Every conversational flow you design must therefore answer one question: what happens when the user goes quiet for a day? Cart recovery, payment reminders, and delivery updates all cross the window boundary and must exist as approved templates.
Template categories and review. Templates are classified as marketing, utility, or authentication. Meta reviews each template before it can be sent, prices each category differently, and can reject or later pause templates that generate negative user feedback. Your template library is a managed production asset with a lifecycle — versioned, monitored, and owned — not a string file.
Opt-in. Business-initiated messaging requires user opt-in. Buying a contact list and blasting it is both a policy violation and a fast way to destroy the next item on this list.
Quality rating and messaging tiers. Each sending phone number carries a quality rating driven by user blocks and reports, and a messaging tier that caps how many unique customers you can initiate conversations with per day. Tiers start in the low thousands and scale up as volume and quality hold; a quality drop can freeze or reduce your tier. Treat quality rating as a production metric with alerting, exactly like error rate — because functionally, that is what it is.
A reference architecture for WhatsApp commerce
Across the chat-commerce systems we have built — including Waco, our WhatsApp commerce engine — the same shape keeps proving itself.
Ingest: verify, acknowledge, enqueue
Your webhook endpoint should do three things and nothing else: verify the payload signature so a spoofed request can never enter your system, return a success response immediately, and push the event onto a queue. All real work happens in workers behind the queue. Meta retries failed webhook deliveries, which means duplicates are guaranteed eventually — so every worker keys off the message ID and checks a dedupe store before acting. Ordering is not guaranteed either: a read status can arrive before its delivered status, and your state handling has to tolerate that without corrupting conversation state.
Conversation state: an explicit machine, not implied context
Model each thread as a state machine — browsing, building a cart, awaiting payment, awaiting fulfillment — persisted with a TTL aligned to the 24-hour window. When a message arrives, the worker loads the thread state, applies the transition, and emits the reply. Implicit state ("we'll infer where they are from the last message") is how chat systems end up offering checkout to someone who asked about returns.
Commerce sync: the thread must never lie
A chat channel quoting yesterday's prices or offering sold-out stock is worse than no channel, because it converts warm intent into distrust. Catalog data, pricing, and availability must sync from your system of record into the conversation layer continuously — idempotent jobs, retries with backoff, verified webhooks on both sides. This is the discipline of API integration and business process automation applied to a messaging surface, and it is most of the real engineering in chat commerce. The Waco case study walks through what that looks like end to end.
Checkout: links out, money on hardened rails
Native in-chat payments exist only in a couple of markets (India and Brazil, via local payment rails). Everywhere else, checkout means generating an encrypted, single-purpose payment link in the thread and completing the transaction on proper payment infrastructure — tokenization, 3D Secure 2.0, card data never touching the conversation layer. The controls we apply are documented on our security page. The chat carries a link and a confirmation; it must never carry payment credentials.
Outbound: rate-aware, template-aware, status-driven
Outbound sends go through a queue that respects your messaging tier and paces marketing volume. The send path checks whether the service window is open and falls back to an approved template when it is not. Status webhooks — sent, delivered, read, failed — feed back into the same state machine, driving retries for transient failures and alerting when delivery rates sag.
Failure modes to design for on day one
Every one of these has bitten a production WhatsApp deployment somewhere. Plan for all of them.
- Duplicate webhook delivery. Guaranteed by retry semantics. Mitigation: idempotency keys on message IDs, dedupe store ahead of every side effect.
- Out-of-order events. Statuses and messages arrive in whatever order the network allows. Mitigation: state transitions that tolerate reordering instead of assuming sequence.
- Template rejection and pausing. A template your cart-recovery flow depends on can be rejected at review or paused later on negative feedback. Mitigation: fallback templates for critical paths, and template health in your monitoring, not in someone's memory.
- Quality rating drops. Too much marketing volume to lukewarm opt-ins, and your tier shrinks. Mitigation: throttle marketing sends well below your ceiling, watch block rates, and keep utility traffic — receipts, tracking updates — clearly separated from promotion.
- Number bans from unofficial automation. Tools that puppet consumer accounts get numbers banned, taking the channel and every chat history with it. There is no mitigation except never doing it: official API only.
- Media expiry. Inbound media is fetched via short-lived URLs. Download and persist to your own storage immediately; a fulfillment worker that fetches lazily will find a dead link.
- Webhook endpoint outages. Meta retries for a limited period, then gives up. Mitigation: a boring, highly available ingest path on properly provisioned cloud infrastructure, plus reconciliation jobs that detect gaps rather than hoping there are none.
- API version deprecations. The Graph API versions on a fixed cadence. Someone has to own upgrades before forced cutover, not after.
What it honestly costs
Pricing details shift — Meta has restructured its model more than once — so verify current rates, but the cost structure is stable:
- Per-message template fees. Business-initiated template messages are billed per message, with rates varying by category and recipient country. Marketing templates cost meaningfully more than utility or authentication. Replies inside an open service window are the cheap path, which conveniently rewards genuinely conversational design.
- BSP markups. If you route through a provider, expect per-message markups or platform fees on top of Meta's rates. At low volume this is noise; at high volume it is a line item worth re-architecting around.
- Build cost. Webhook infrastructure, the conversation state machine, catalog sync, checkout integration, and human-handoff paths are weeks of senior engineering, not a weekend hackathon. Most of the cost is integration middleware, not the WhatsApp-specific surface.
- Ongoing operations. Template lifecycle management, quality monitoring, version upgrades, and content operations for marketing sends continue for the life of the channel.
When WhatsApp commerce is the wrong answer
The honest disqualifiers, before you spend the budget:
- No existing conversational demand. If customers are not already messaging you, the API will not invent that behavior. Fix the demand side first.
- Catalog complexity. Deep configurators and large multi-vendor assortments fight the message format. A full marketplace — the territory of Peyze, our marketplace infrastructure platform — is the better home, with chat as a companion channel at most.
- Markets where WhatsApp is not the default. A US-centric customer base mostly is not living in WhatsApp threads.
- Pure broadcast marketing. If the plan is one-way blasts, email is cheaper and will not torch a quality rating you might want later.
Where to start
Start with the integration map, not the chatbot. Inventory what the thread must read (catalog, stock, pricing) and write (orders, payments, fulfillment events), and design the middleware seams — idempotency, retries, dead-letter queues — before any conversation design. If you intend to put an LLM behind the thread, the same gateway discipline applies twice over: agents need scoped, audited tools, which is the ground covered by our AI development and MCP integration work.
We have built this stack from the webhook up, and we run it ourselves in production. If you want a concrete read on what connecting WhatsApp to your systems would actually involve, the mapping session is the fastest way to find out.
Put this thinking to work on your roadmap.
Our API Integration & Business Automation team ships exactly this kind of work. You will talk to a senior engineer within one business day.
Prefer email? support@evolvier.com