Handling the failed status and error codes in webhooks
The failed status carries an errors object with code and details. Learn how to turn each code into an action: reopen the window, wait, fix or escalate.
A good share of the messages that "never reach" the customer were already explained by Meta, in a webhook your system received and ignored. The failed status carries the reason, and treating it as a plain "it errored" throws away the most valuable information in the send cycle. This article shows what comes in the error object and how to map codes to actions instead of blind resend attempts.
What comes in the errors object of a failed status
When a message fails, the failed status arrives with an errors object that carries code (an integer), title and message (identical), error_data with a details field and href (a link to the code's documentation). That object appears only on failure. Meta's documentation asks you to handle the error by code and detail, and warns that the title will be discontinued, so do not write logic on top of it.
The status is the same delivery event that carries sent, delivered and read, in the payload's statuses field. The item id is the wamid of the message you sent, and that is how you join the failure to the record stored at send time. If you did not store the wamid when sending, you lose the ability to know which message failed.
There are also errors that appear before a status exists. An error response from the send call itself means the API refused the request, and in that case no later status will come, because the message was never accepted. Separate the two paths in code: synchronous send error and asynchronous failure by webhook.
A concrete example: a code-to-action map
The practical gain comes from an explicit map between the code and what the system does. The snippet below illustrates the idea with four codes that the site documents with cause and fix. Any code outside the map falls into a default action, log and escalate, instead of a blind retry.
const ACTION = {
131047: 'reopen_window_with_template', // 24 h window closed
131049: 'wait_24h_before_resending', // marketing held by WhatsApp
131026: 'check_number_do_not_resend', // not deliverable to the contact
131000: 'retry_once_then_escalate', // unknown failure
}
function handleFailure(status) {
const error = status.errors?.[0]
const action = ACTION[error?.code] ?? 'log_and_escalate'
return { wamid: status.id, code: error?.code, details: error?.error_data?.details, action }
}| Code | What it means | Suggested action |
|---|---|---|
| 131047 | 24-hour service window closed | Send an approved template; the window reopens when the contact replies |
| 131049 | WhatsApp held a marketing template because of the per-contact limit | Wait at least 24 hours before resending |
| 131026 | Message could not be delivered to the contact | Confirm the number through another channel; resending unchanged gives the same error |
| 131000 | Unknown failure on Meta's side | No reason given; retry once and escalate |
Code 131049 is the one in Meta's official example for the failed status, with the text that the message was not delivered to maintain healthy ecosystem engagement. The documented cause is that the contact reached the limit of marketing templates WhatsApp delivers to them, across all businesses, or that the same message was resent within 24 hours. Resending earlier only produces another error.
Code 131047 calls for a different decision: the error is not about the number or the contact, it is about the window rule. Outside the 24 hours after the customer's last message, only an approved template can be sent. The right action is to change the message format, not repeat the send.
Automatic resend: when it helps and when it harms
Automatic resend only makes sense for failures that can resolve on their own, and it is harmful for the others. A 131000, unknown failure, justifies one more attempt after a wait. A 131047 or a 131049 resent unchanged produces the same error, consumes throughput and, for marketing, can worsen the engagement problem with that contact.
Define a policy per code, with an attempt limit and an interval, and record every decision. If the same code repeats for many contacts in a short time, treat it as an incident and not as an individual error: a sudden rise in failures may point to a problem with the account, quality or template, and the right action becomes investigating, not resending.
- Map the error by code and by error_data.details, never by title.
- Store the wamid at send time to join the failure to the original message.
- Do not resend unchanged on window, marketing or number errors.
- Code outside the map: record the whole errors object and escalate.
- A spike of the same code across many contacts is an incident, not noise.
Monitoring failures as a signal
Failure rate by code is one of the best health signals you can build from webhooks. Track the share of sent messages that end in failed, broken down by code, over a rolling window. A stable low rate of one code, such as an occasional closed window, is normal; a jump in the rate of any code is the signal to look closer. Because each failed status already carries the code, this metric needs no extra calls.
Alert on changes, not on absolute counts. A burst of 131049 right after a marketing send tells you about the campaign and the contacts' limits; a burst of 131047 tells you your bot is replying outside the window, which usually means a flow that waits too long. Pair each alert with the action from your map, so whoever is on call knows the next step without reading documentation at night.
Delivery failures and deduplication
Like every webhook event, the failed status can arrive duplicated by a retry, and your handling must be idempotent. The natural key is the wamid combined with the state. Without it, the same failure triggers the same action twice, such as two notifications to the operator or two template resends.
Be careful with order too. A failed can arrive after a sent, and the state-advance rule must decide what to do if it arrives after a read, in which case the read indicates the message was displayed. The article on out-of-order statuses in this cluster proposes a rule. Anyone using CRPRO Hub receives statuses through the message.status event; the exact fields are on the CRPRO Hub webhooks page, and the first authenticated calls are in the quickstart.
Frequently asked questions
What does the failed status tell me about the reason for the failure?
An errors object with code (integer), title and message (identical), error_data.details and href. Handle the error by code and detail.
Why did my marketing template fail with 131049?
The contact reached the limit of marketing templates WhatsApp delivers to them, across all businesses, or the same message was resent within 24 hours. Wait at least 24 hours.
Should I automatically resend every message that failed?
No. Only failures that can resolve on their own, such as the unknown one. Closed window, marketing limit and invalid number repeat the error if resent unchanged.
How do I join the failure to the message I sent?
By the id of the item in statuses, which is the wamid returned at send time. Store it when sending so you can make that join.
Fontes
Documentação oficial da Meta, conferida em 31 de outubro de 2026.