Automation
Unified Messaging APIs: Integrating Email, SMS and WhatsApp Reliably
What a unified messaging API does and does not unify, how email, SMS and WhatsApp differ underneath, and an integration design that keeps delivery status, consent and retries under control.

On this page
A unified messaging API gives an application one way to send and receive messages across several channels: typically email, SMS and WhatsApp, sometimes voice or other chat apps as well. Instead of three integrations with three authentication schemes, three message formats and three webhook styles, the application talks to one interface.
That is genuinely useful. It is also easy to overestimate. A unified API unifies the interface, not the channels. Each channel keeps its own rules about consent, content, cost and delivery, and the application still has to respect them. This article explains what a unified messaging API does and does not take off your hands, and the integration design that keeps a multi-channel system reliable once real traffic arrives. It is written for developers and for technical owners planning an integration or choosing a provider.
What "unified" covers, and what it cannot
A good unified messaging API typically gives you:
- One API and one set of credentials for every channel it supports.
- A common message model: recipient, channel, content or template, metadata.
- Normalised events: delivery updates and inbound messages arrive in one webhook format, whatever the channel.
- One place for logs and billing, and often a dashboard for support staff.
- Sometimes routing features, such as trying a second channel when the first fails.
What it cannot do is remove the rules underneath. WhatsApp still limits when a business may send free-form messages. SMS is still split into billable segments, and sender rules still vary by country. Email still depends on your domain's authentication and on giving recipients a way to unsubscribe. A provider can make these rules easier to work with, but your application still decides who may be contacted, on which channel, with what content. That decision cannot be delegated to the API.
The three channels are different underneath
| SMS | WhatsApp (Business Platform) | ||
|---|---|---|---|
| Address | Email address | Phone number | Phone number with a WhatsApp account |
| Who can start the conversation | Sender, within consent and anti-spam law | Sender, within consent and local rules | The customer, or the business using an approved template |
| Content limits | Practically none; HTML and attachments | Short text, split into segments | Free-form only inside the customer service window; templates outside it |
| Delivery feedback | Accepted, bounced, complained; "opened" is unreliable | Carrier delivery receipts, where the network provides them | Sent, delivered, read, failed |
| What you pay for | Usually volume | Each segment | Each message: templates, and service messages beyond a monthly free allowance |
Delivery depends far more on the sending domain than on the API. Mailbox providers expect messages to be authenticated with SPF, DKIM and DMARC, and Gmail and Yahoo have required all three from bulk senders since 2024, together with a one-click unsubscribe for marketing messages and a spam-complaint rate below 0.3 % (Gmail's sender guidelines, Yahoo's sender requirements). Gmail began enforcing these rules more strictly in November 2025, rejecting mail that does not comply. One-click unsubscribe is a pair of email headers (List-Unsubscribe and List-Unsubscribe-Post) defined in RFC 8058; a unified API may add them for you, but your system has to act on the unsubscribe.
Delivery feedback for email is also weaker than it looks. "Delivered" means the receiving server accepted the message, not that it reached the inbox. Open tracking is unreliable because many mail clients load images automatically or through privacy proxies, so treat opens as a rough signal and never as proof that a person read something.
SMS
A text message is billed in segments. With the standard GSM-7 character set, one message holds 160 characters, and longer messages are split into segments of 153. A single character outside that set, such as an emoji or some accented letters, switches the whole message to UCS-2 encoding: 70 characters for one segment and 67 per segment after that (Twilio's explanation of segments; some routes, such as North American toll-free numbers, use slightly smaller segments). A template that grows by a few characters, or picks up a curly apostrophe from a word processor, can double the cost of a campaign.
Sender IDs, registration requirements and opt-out handling also vary by country and carrier. The provider will usually tell you what applies, but the application has to store opt-outs and honour them across every message it sends.
On the WhatsApp Business Platform, a business can send free-form messages only within a 24-hour customer service window that opens when the customer messages the business. Outside that window, the business must use a pre-approved message template, and the customer must have opted in to receiving messages from the business (Meta: sending messages, Meta: templates, Meta: getting opt-in). Pricing has changed twice recently: since July 2025 Meta charges per message rather than per conversation, and since October 2026 service messages inside the window are also charged once a phone number has used its monthly free allowance (Meta: pricing). Check the current rates before estimating costs, because they change.
For the application, that means "send a WhatsApp message" is really two different operations: reply inside an open window, or send an approved template. The system needs to know which one applies before it sends.
An integration design that holds up
The diagram at the top of this article shows the shape that works for most multi-channel systems: the application owns the message and its history, the provider is a delivery mechanism, and everything that comes back from the provider is checked before it changes anything.
1. Record the message before you send it
Create a row in your own database first, with your own ID, the recipient, the channel, the template or content, and a status of queued. Then send. Store the provider's message ID when the API responds.
This gives you a history that survives a provider outage or a change of provider, and it gives you an idempotency key. If the send is retried after a timeout, the system can check whether this message was already accepted instead of sending it twice. Where the provider supports idempotency keys on its send endpoint, pass yours.
2. Send from a queue, not from the web request
Sending inside the request that triggered it (a form submission, a button press) ties the user's experience to the provider's response time and makes retries awkward. Put the send in a queued job with a sensible timeout, a small number of retries with increasing delays, and a final failure state that someone can see. Respect the provider's rate limits there too: a campaign of ten thousand messages should be released at a controlled pace, not all at once.
3. Treat webhooks as untrusted, repeated and out of order
Status updates and inbound messages arrive at a webhook endpoint you expose. Three things are true of almost every provider's webhooks:
- Anyone can call the URL. Verify the provider's signature on every request before doing anything with it. Meta signs webhooks with an HMAC-SHA256 of the request body, keyed with your app secret, in the
X-Hub-Signature-256header (Meta: webhooks). Twilio signs its requests too, and recommends validating them with the helper in its official SDKs rather than reimplementing the scheme (Twilio: webhook security). - The same event can arrive more than once. Providers retry when your endpoint is slow or returns an error. Meta retries failed WhatsApp webhook deliveries for up to seven days and warns that this can produce duplicates (Meta: WhatsApp webhooks), so processing has to be idempotent.
- Events can arrive out of order. A "delivered" update can arrive after "read". Twilio says plainly that status callbacks are not guaranteed to arrive in the order they were sent (Twilio: tracking message status), and Stripe's webhook documentation gives the same warning for its events (Stripe: webhooks).
A minimal Laravel endpoint that follows those rules looks like this:
final class WhatsAppWebhookController
{
public function __invoke(Request $request): Response
{
// The signature covers the raw body, so check getContent().
$body = $request->getContent();
$secret = config('services.whatsapp.app_secret');
$expected = 'sha256='.hash_hmac('sha256', $body, $secret);
$given = (string) $request->header('X-Hub-Signature-256');
if (! hash_equals($expected, $given)) {
abort(403);
}
// Store each delivery once: a retried delivery matches the unique
// fingerprint and is not processed again.
$event = ProviderEvent::firstOrCreate(
['provider' => 'whatsapp', 'fingerprint' => hash('sha256', $body)],
['payload' => $body],
);
if ($event->wasRecentlyCreated) {
ProcessProviderEvent::dispatch($event);
}
// Acknowledge quickly; the real work happens in the queue.
return response()->noContent();
}
}
Two details matter. The signature is calculated over the raw request body, so it must be checked before the JSON is decoded and re-encoded. And the endpoint only records and acknowledges; the queued job does the processing, so a slow database or a provider API call cannot make the webhook time out and trigger more retries.
4. Model delivery status as a state machine
Providers use different words for similar states. Map them to a small set of your own and only allow status to move forward:
enum DeliveryStatus: int
{
case Queued = 10;
case Sent = 20;
case Delivered = 30;
case Read = 40;
case Failed = 90;
public function canMoveTo(self $next): bool
{
return $this !== self::Failed && $next->value > $this->value;
}
}
With this rule, a late "delivered" event cannot move a message that is already "read" backwards, and a duplicate event changes nothing. Keep the raw provider status as well: support staff will need it when a customer says a message never arrived.
5. Keep consent and suppression in your own system
Opt-outs arrive in different ways: an email unsubscribe link, a "STOP" reply to a text message, a customer blocking a WhatsApp number, a hard bounce. Record each one against the contact and the channel, and check that list before every send, including sends triggered by automations written months later. A provider may block some messages to opted-out numbers on its side, but your records are what you will rely on if you are asked to show that a person's choice was respected.
6. Keep secrets and message content out of logs
Webhook payloads and API responses often contain phone numbers, email addresses and message text. Log IDs and statuses by default, store payloads only where you need them, with a retention period, and keep API keys and app secrets in configuration, never in code or logs.
Fallback between channels needs care
"If WhatsApp fails, send an SMS" sounds simple. In practice:
- The customer must have agreed to be contacted on the second channel as well.
- "Not read yet" is not a failure. Falling back on a missing read receipt sends duplicates to people who simply have not opened their phone.
- Each attempt costs money, and a fallback chain can multiply the cost of a campaign.
Fall back only on a definitive failure state, only to channels the contact has consented to, and record every attempt against the same logical message so the history makes sense.
Questions to ask before choosing a provider
- Which channels and countries are supported, and what sender registration does each require?
- Are webhooks signed, and how are they retried? Does each event carry a unique ID?
- How detailed are the delivery statuses, and how long are they kept?
- Can templates be created and checked through the API, or only in a dashboard?
- Where is message data stored, for how long, and can it be deleted on request?
- What are the rate limits, and what happens when you exceed them?
- Is there a test or sandbox mode that behaves like production?
- How is usage billed for each channel?
- Can you export message history and events if you leave?
The last question is the one most often skipped. If your application keeps its own message records and its own status model, as described above, changing provider later is a contained piece of work rather than a migration of your communication history.
Unified provider, or your own thin layer?
There are two reasonable designs. You can use one provider's unified API for every channel, or integrate each channel's provider directly behind a small interface in your own code (send(Message $message): SendResult), with one adapter per provider.
A unified provider is faster to start with and gives non-developers one dashboard. Your own layer costs more to build, but lets you choose the best provider for each channel and country and keeps you independent. Many systems start with a unified provider and keep the option open by putting it behind their own interface from the first day. That interface is a few dozen lines of code and is the cheapest insurance in the whole integration.
From experience
Digital Solutions' founder worked as full-stack developer on a Laravel portal that coordinated email, SMS and WhatsApp-related workflows, with campaigns, a shared inbox, webhooks and scheduled processing. The case study is published at a general level for confidentiality. Its main lesson matches the design above: integration-heavy systems need explicit failure boundaries, observable state transitions and careful handling of external events.
Inbound messages are also a common place to add AI, for example to classify or summarise what customers write. If you are considering that, adding AI to an existing business application covers how to do it without making the system less reliable. Domain authentication and other email basics are covered in the website maintenance and security checklist.
Getting help with an integration
Digital Solutions builds API and third-party integrations for teams connecting a website or internal application to messaging providers, email services and other platforms, with the state, retries and failure handling made visible. If you are planning a multi-channel integration, or an existing one has become hard to trust, describe what it needs to do.


