Observability for WhatsApp integrations
What to measure and alert on in a WhatsApp integration: send outcomes, webhook health, latency from accepted to delivered, error codes and per-tenant views.
A WhatsApp integration fails in quiet ways. The send call returns success, the webhook never arrives, a template is paused and nobody notices until a customer complains. Observability for this kind of system is mostly about the gaps between steps: accepted but not delivered, delivered but not read, event sent but not received. This article lists the signals worth collecting, the alerts worth waking someone for and the per-tenant views that make a multi-customer platform debuggable.
What is the lifecycle you need to observe?
A message passes through at least four observable stages: accepted by the API, sent to WhatsApp, delivered to the device and optionally read, with failed as an exit at any point. Each transition arrives as a separate event, and each gap between them is a metric.
Meta states that the response to a send request confirms only that the request was accepted, not that the message was delivered, and tells developers to subscribe to messages webhooks for delivery status. If a delivered status does not arrive before the message time-to-live expires, the message should be assumed dropped. CRPRO Hub follows the same pattern: the send endpoint answers 202 for accepted and queued, and the final state arrives through webhooks and the channel history.
| Stage | Source | Metric to keep |
|---|---|---|
| Request accepted | Send API response (202) | Count and latency of send calls, by tenant and channel |
| Sent / delivered / read | Status webhooks | Time from accepted to each status; ratio of delivered to accepted |
| Failed | Status webhook with error code | Count by error code, tenant and template |
| Inbound received | Message webhook | Count; lag from event time to processing time |
Which metrics matter most?
Five metrics cover most incidents: send success rate, accepted-to-delivered latency distribution, failure counts by error code, webhook processing lag and queue age. Keep them labelled by tenant, channel and template, but watch label cardinality so the metrics store stays affordable.
- Send success rate: share of send calls that return acceptance, separate from the share of messages later delivered.
- Accepted-to-delivered latency: percentiles, not averages, because a few stuck messages hide inside a mean.
- Failures by error code: 130429 means throughput exceeded, 131047 means the 24-hour window closed, 132015 means a paused template, 368 and 131031 mean a restricted account.
- Webhook lag: the difference between the event timestamp and the time your handler stored it.
- Queue age: how old the oldest unsent job is, the earliest sign of a stuck worker.
Do not alert on delivered ratio alone. Delivery to a device depends on the recipient's phone being reachable, so a drop can be a network event or a list-quality problem. Alert on changes against the tenant's own baseline.
How do you monitor webhook health?
Monitor both sides of the pipe: whether the provider can deliver to you, and whether you process what arrives. The provider's delivery list tells you the first; your own lag metric tells you the second.
The Hub lists the 50 most recent deliveries per endpoint with status (pending, processing, retry, succeeded, dead or canceled), attempt count and the last HTTP status your receiver returned. It retries failed deliveries up to nine more times and pauses an endpoint after 20 consecutive failed attempts. Polling the delivery list for retry and dead entries gives an early warning well before the pause, as described in the webhooks reference.
# poll for deliveries stuck in retry or dead, per endpoint
curl "https://crprohub.com/api/v1/webhooks/WEBHOOK_UUID/deliveries" \
-H "Authorization: Bearer $HUB_API_KEY" \
| jq '[.data[] | select(.status == "retry" or .status == "dead")] | length'
# alert when the number stays above zero for several minutesAlso run a synthetic check: a periodic message to an internal number whose status webhooks you expect within a known interval. A missing status from a known-good message is the most direct test that the whole loop works.
How do you trace one message end to end?
Carry one correlation identifier from your own request through the send call, the idempotency key, the provider message id and every status event. When a customer asks about one message, a single lookup should reconstruct its whole history.
{
"ts": "2026-10-31T14:02:11Z",
"level": "info",
"event": "send_accepted",
"tenant_id": "t_123",
"channel_id": "ch_456",
"correlation_id": "c0a8-...",
"idempotency_key": "order-9981-confirm",
"provider_message_id": "wamid.XXXX",
"latency_ms": 212
}The example uses placeholder values. Notice what is absent: no message body, no full phone number, no credentials. Structured logs with a stable event name make it possible to count and alert on events, and leaving personal data out keeps the observability stack outside the scope of every deletion request.
Which alerts deserve a page?
Page on conditions that stop messages or put the account at risk, and send everything else to a ticket queue. Alert fatigue is how real incidents get ignored.
- Page: an endpoint paused or approaching the consecutive-failure limit, webhook lag growing steadily, queue age beyond the tenant's agreed delivery time, or any account-restriction error code.
- Ticket: a template paused for quality, rising opt-out errors on a campaign, or a tenant approaching its messaging tier.
- Dashboard only: delivered ratio movement, read ratio, individual 131056 rate-limit responses for a single recipient.
Put the tenant name in the alert title. When a platform serves many customers, the first question during an incident is always who is affected, and the answer should not require a query.
What should a per-tenant view show?
A per-tenant view shows connection state, recent volume, outcomes by status and error code, webhook delivery health and template status. It should be usable by support without database access, and a simplified version can be exposed to customers.
Use the provider's diagnostics where available. The Hub offers a channel diagnostics call that checks the token, the number and the webhook subscription against Meta without exposing secrets, and a usage call that returns current quota usage under the billing:read scope. Combine them with your own metrics so a support engineer sees one page instead of five tools. The quickstart covers authenticating those calls.
Frequently asked questions
Does a 202 response mean the message was delivered?
No. It means the request was accepted and queued. Delivery is confirmed by the delivered status webhook, and Meta advises assuming a message was dropped if no delivered status arrives before its time-to-live expires.
What is the earliest warning that webhooks are failing?
Growing counts of deliveries in retry or dead state, and rising webhook lag on your side. Both appear well before an endpoint is paused after 20 consecutive failures.
Should I log message bodies for debugging?
Avoid it in general-purpose logs. Log identifiers, status and error codes, and keep content in a separate store with its own access rules and expiry.
Fontes
Documentação oficial da Meta, conferida em 31 de outubro de 2026.