Skip to content

Error Codes

The Mahadata API uses standard HTTP status codes and returns a JSON body on every error response. This page explains each error code, its common causes, and the correct handling strategy.

Most error responses return a flat JSON object with the following structure:

{
"code": 400,
"error": "validation_error",
"message": "Validation error: Exactly one message type must be provided"
}
FieldTypeDescription
codeintegerHTTP status code (e.g. 400, 402, 429).
errorstringError category in lowercase with underscores (e.g. validation_error, payment_required). This value is derived from the error type on the server.
messagestringHuman-readable message explaining the cause of the error.
detailsobjectOptional. Top-level field (not inside error) that only appears on some errors — mainly 409 conflicts. Completely omitted when absent.

The request is invalid due to an incorrect body, parameter, or format.

Example response
{
"code": 400,
"error": "validation_error",
"message": "Validation error: Exactly one message type must be provided"
}

Common causes:

  • A required field is missing (messaging_product, to, type).
  • More than one or no main message type (template, text, image, etc.) is provided in a single request.
  • The phone number does not match E.164 format.
  • The JSON body is malformed or a field has the wrong data type.
  • No routing rule matches the destination — this error also returns 400 with error = no_route_found.

Handling: Fix the request and resend. Do not retry automatically because this error is deterministic — the same request will always fail.

401 — Authentication / Authorization Failed

Section titled “401 — Authentication / Authorization Failed”

Authentication failed, or the API key is not authorized for the requested resource.

Example response
{
"code": 401,
"error": "api_key_unauthorized_for_this_entry_point",
"message": "API Key unauthorized for this entry point"
}

Common causes:

  • The Authorization header is missing or is not in Bearer <token> format.
  • The API key is invalid, has been revoked, or belongs to a deactivated account.
  • The API key is not permitted for the phone_number_id used in the request (API Key unauthorized for this entry point).
  • Attempting to read a resource owned by another account — for example, calling GET /v1/messages/{message_id} for another account’s message (Forbidden).

Handling: Check your API key in app.mahadata.io > Settings > API. Ensure the key is authorized for the phone_number_id being used. Do not retry automatically.

Balance, message quota, or budget plan is exhausted when sending a message. This is one of the most common error responses from POST /v1/{phone_number_id}/messages.

Example response
{
"code": 402,
"error": "payment_required",
"message": "Payment required: Insufficient funds to send message."
}

Returned error messages (message):

  • "Payment required: Insufficient funds to send message." — the billing account balance is exhausted or below the message cost.
  • "Payment required: Message quota exhausted." — the message quota is exhausted.
  • "Payment required: Budget plan exhausted for this category." — the budget plan for this message category is exhausted.

Handling: Top up your balance or update your quota/budget plan, then resend. Do not retry automatically before updating your balance or quota — the same request will continue to fail.

The request is authenticated (the API key is valid) but not authorized for the requested resource.

Example response
{
"code": 403,
"error": "channel_not_owned_by_this_account",
"message": "Channel not owned by this account"
}

Common causes:

  • phone_number_id (channel) is registered on the platform but does not belong to your account.

Handling: Verify that phone_number_id is correct and belongs to your account. Do not retry automatically.

The requested resource was not found.

Example response
{
"code": 404,
"error": "resource_not_found",
"message": "Resource not found: Message not found."
}

Common causes:

  • message_id is invalid or has been deleted.
  • The agent or sender (e.g., RCS/SMS) was not found or does not belong to your account.
  • The endpoint path is incorrect.

Handling: Verify the resource ID and endpoint path. Do not retry automatically.

The request conflicts with existing state.

Example response
{
"code": 409,
"error": "conflict_with_existing_resource.",
"message": "Template with this name already exists.",
"details": {
"name": "welcome_template"
}
}

Common causes:

  • Creating a template with a name that already exists.
  • A concurrent duplicate operation on the same resource.
  • On the Sync API (POST /api/v1/{phone_number_id}/messages), 409 is also returned when a send is rejected by Meta (with the error body of the account’s Sync API profile).

Handling: Use a different name or check whether the resource already exists. Do not retry 409 responses automatically.

429 — capacity_exceeded (Async) & Sync API Throttling

Section titled “429 — capacity_exceeded (Async) & Sync API Throttling”
  • Asynchronous API (POST /v1/{phone_number_id}/messages): Rare; returned when the platform’s global capacity is reached (error = capacity_exceeded). This response has no Retry-After header. Per-number sending is queued (~80 messages/second for standard numbers, ~1,000 messages/second for high-throughput numbers) rather than rejected with per-number 429 responses.
  • Sync API (POST /api/v1/{phone_number_id}/messages): Returns 429 with a Retry-After header (in seconds) when the sender number is above its throughput, or error type overloaded with Retry-After: 2 when the Sync API gateway is at capacity.
Example response (Asynchronous API)
{
"code": 429,
"error": "capacity_exceeded",
"message": "Capacity exceeded: Message rejected due to global capacity limits"
}

Handling: On the asynchronous API, retry after a short delay. On the Sync API, wait for the Retry-After duration before retrying. See Rate Limits and Sync API for details.

500 — an_unexpected_internal_error_occurred.

Section titled “500 — an_unexpected_internal_error_occurred.”

An unexpected internal error occurred on the Mahadata server.

Example response
{
"code": 500,
"error": "an_unexpected_internal_error_occurred.",
"message": "An unexpected internal error occurred."
}

Common causes:

  • An unexpected server-side error (rare).
  • An internal configuration error or temporary dependency disruption.

Handling: Retry with exponential backoff. If it persists after several retries, contact support@mahadata.io.

503 — Service Unavailable (Sync API Reports)

Section titled “503 — Service Unavailable (Sync API Reports)”

The Sync API report endpoint (GET /report-dashboard) returns HTTP 503 with a Retry-After header in the following cases:

  • overloaded — busy (Retry-After: 2 or 10 seconds).
  • report_preparing — the report is being built; retry after the given seconds in Retry-After.
  • report_unavailable — temporary unavailability (Retry-After: 10 seconds).

Handling: Wait for the number of seconds in Retry-After before calling the endpoint again.

HTTPerror / TypeRetryable?Strategy
400validation_error / no_route_foundNoFix the request.
401per message (e.g. api_key_unauthorized_for_this_entry_point)NoCheck the API key and its permissions.
402payment_requiredNoTop up balance, message quota, or budget plan.
403per message (e.g. channel_not_owned_by_this_account)NoVerify ownership of phone_number_id.
404resource_not_foundNoCheck the resource ID.
409conflict_with_existing_resource. (or Meta rejection on Sync API)NoResolve conflict / do not retry.
429capacity_exceeded (async) / overloaded (Sync API)YesRespect Retry-After if present; otherwise retry after a short delay.
500an_unexpected_internal_error_occurred. (varies)YesExponential backoff.
503overloaded / report_preparing / report_unavailable (Sync API)YesRetry after Retry-After.

Only retry 429, 503, and 500 (5xx server error) responses. Other 4xx errors are deterministic and will not succeed without modifying the request.

  • When the response includes a Retry-After header (such as Sync API 429 and 503), wait for the given seconds before retrying.
  • When no Retry-After header is present (such as 429 capacity_exceeded or 500 on the asynchronous API), retry after a short delay with exponential backoff and jitter.
  • Include the same Idempotency-Key header when retrying a WhatsApp send so a retry never sends or bills twice.

The WhatsApp send endpoint (POST /v1/{phone_number_id}/messages) supports the Idempotency-Key header to prevent duplicate sends when retrying.

  • Sending the same Idempotency-Key within 24 hours returns HTTP 202 Accepted with the first message_id (messages[0].id) and the response header Idempotent-Replayed: true.
  • The replayed request is not sent or billed again.
  • A different Idempotency-Key (or a request without the header) is treated as a new message.
  1. Generate a unique key per logical message. Use a deterministic identifier from your system (such as an order_id or a per-attempt UUID) as the Idempotency-Key header value.
  2. Reuse the same Idempotency-Key on retry. If you encounter a network timeout, 429, or 5xx, retry with the exact same Idempotency-Key. If the original request was already accepted, you will receive 202 with Idempotent-Replayed: true and the original messages[0].id.
  3. Store messages[0].id from the 202 response. Use this ID (msg_<uuid>) to correlate final delivery status events from webhooks.
  4. Retry only on transient errors. Do not retry 400, 401, 402, 403, 404, or 409 responses.

In addition to HTTP response errors, a message accepted by the server (202 Accepted) can still fail during delivery to Meta. These failures are delivered via the message.status.failed webhook.

The webhook payload follows the enriched Meta Cloud API envelope format — object / entry / changes / value.statuses[] — and each entry in errors[] carries code, title, and message (without a type field):

POST {your_webhook_url}
{
"object": "whatsapp_business_account",
"entry": [
{
"id": "1234567890",
"changes": [
{
"value": {
"messaging_product": "whatsapp",
"metadata": {
"display_phone_number": "6281234567890",
"phone_number_id": "9876543210"
},
"statuses": [
{
"id": "msg_a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"status": "failed",
"timestamp": "1717200300",
"recipient_id": "6289876543210",
"errors": [
{
"code": 131026,
"title": "Message undeliverable",
"message": "Message failed to send because more than 24 hours have passed since the customer last replied."
}
]
}
]
},
"field": "messages"
}
]
}
]
}

See message.status.failed for the complete field structure and list of Meta error codes.

Meta Error Codes & Automatic Retries Before Webhook Failure

Section titled “Meta Error Codes & Automatic Retries Before Webhook Failure”
Code / CausePlatform Behavior & Description
130429 (Sender number rate limit)When Meta answers “too fast”, the platform waits and retries automatically. After 30 minutes of continuous throttling, the message fails with error code 130429 in the message.status.failed webhook.
131056 (Pair rate limit)Too many messages were sent to the same recipient in a short time. The message fails at once with code 131056 in the message.status.failed webhook; the platform does not resend it. Resend from your system after a pause if it is still needed.
131026 (Message undeliverable)Recipient cannot receive the message (number not on WhatsApp or outdated app).
131047 (Re-engagement message)Free-form message outside the 24-hour window: use a template.
Number not on WhatsApp / blocked businessThe recipient does not have a WhatsApp account or has blocked the sender number.
Template not approvedThe message template still has status PENDING or REJECTED.

See WhatsApp Error Codes for the meaning of each WhatsApp error code.

If you encounter an error that cannot be resolved using the guide above:

  1. Check the API Reference to ensure the request matches the schema.
  2. Check the webhook logs for message.status.failed events.
  3. Contact support@mahadata.io including:
    • message_id (if available)
    • Request timestamp (UTC)
    • Full request body and response
    • API key ID (first 4 characters only, do not send the full key)