> ## Documentation Index
> Fetch the complete documentation index at: https://docs.newlead.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Errors

> What each error means and when to retry the request.

## Error object

Every error has the same shape:

```json theme={null}
{
  "error": {
    "type": "invalid_request_error",
    "code": "parameter_invalid",
    "message": "limit must be <= 100.",
    "param": "limit",
    "request_id": "req_m3k2a9_4f1c2b7e",
    "doc_url": "https://docs.newlead.ai/errors#parameter_invalid"
  }
}
```

| Field | Description |
| - | - |
| `type` | The error family. Each HTTP status has one. |
| `code` | The specific cause. It is stable: base your logic on it. |
| `message` | An explanation for people. It can change: never match on it. |
| `param` | The field that caused the error, dot-separated (`variables.city`), or `null`. |
| `request_id` | The request ID, also in the `X-Request-ID` header. Include it when you contact support. |
| `doc_url` | The link to this code in the [error codes](#error-codes) table. |
| `details` | Extra data. Present only on the codes below. |

| Code | `details` field | Content |
| - | - | - |
| `agent_not_ready` | `blockers` | An array that names what is missing, such as `channel` or `calendar`. |
| `send_outcome_unknown` on `POST /v1/calls` | `call_id` | The call to check, when it is known. |

## HTTP status codes

| Status | `type` | Meaning |
| - | - | - |
| `400` | `invalid_request_error` | The request is malformed or a parameter is not valid. |
| `401` | `authentication_error` | The API key is missing or not valid. |
| `402` | `billing_error` | The wallet has no balance, or the subscription or subaccount is not active. |
| `403` | `permission_error` | The key cannot use this operation, or the feature is not enabled. |
| `404` | `not_found_error` | The resource or route does not exist in your subaccount. |
| `409` | `conflict_error` | The request conflicts with the current state of the resource. |
| `429` | `rate_limit_error` | Too many requests. See [Rate limits](https://docs.newlead.ai/rate-limits.md). |
| `500` | `api_error` | Something failed on our side. |
| `502` | `provider_error` | A provider did not respond or did not confirm the operation. |

## Retrying

| Response | What to do |
| - | - |
| `400`, `401`, `403`, `404` | Fix the request and send it with a new `Idempotency-Key`. |
| `402` | Top up the wallet or reactivate the subscription, then retry with the same key. |
| `409 idempotency_key_reused` | Send the request with a new key. |
| `409 idempotency_key_in_use` | Wait for `Retry-After`, then retry with the same key. |
| Any other `409` | Fix the cause, then retry with the same key. |
| `429` | Wait for `Retry-After`, then retry. |
| `500`, or `502` other than `send_outcome_unknown` | Retry with the same key, waiting longer each time. |
| `502 send_outcome_unknown` | **Do not retry with a new key.** Check what happened first. |

> [!WARNING]
>
> `send_outcome_unknown` means the message or call may have gone out. Retrying with a new key can send it twice. Follow the steps in [Idempotency](https://docs.newlead.ai/idempotency.md#send_outcome_unknown).

## Error codes

| Code | Status | Meaning |
| - | - | - |
| `parameter_missing` | 400 | A required parameter is missing. `param` names it. |
| `parameter_invalid` | 400 | A parameter has an invalid type, format or value. `param` names it. |
| `parameter_unknown` | 400 | The request includes a field the operation does not accept, likely a typo. `param` names it. |
| `body_invalid_json` | 400 | The request body is not valid JSON. |
| `recipient_invalid` | 400 | The recipient cannot receive the message: the number is invalid, has no WhatsApp or has blocked you. |
| `api_key_missing` | 401 | No API key was sent. |
| `api_key_invalid` | 401 | The API key does not exist, is revoked or its subaccount no longer exists. |
| `insufficient_balance` | 402 | The wallet has no balance for this operation. Top up and retry. |
| `subscription_inactive` | 402 | The subscription or subaccount is not active: read-only. |
| `api_key_forbidden` | 403 | This key cannot use this operation. An organization key does not work on /v1. |
| `feature_disabled` | 403 | The feature is not enabled on this account. |
| `resource_not_found` | 404 | The resource does not exist or does not belong to your subaccount. `param` names the id. |
| `route_not_found` | 404 | The route does not exist in /v1. |
| `agent_not_ready` | 409 | The agent cannot send yet. `details.blockers` lists what is missing. |
| `lead_do_not_contact` | 409 | The lead asked not to be contacted. Clear `do_not_contact` before messaging or calling. |
| `lead_ai_paused` | 409 | The AI is paused for this lead: it cannot be paused again, and the lead cannot be called while a person handles it. |
| `lead_ai_not_paused` | 409 | The AI is not paused for this lead. |
| `messaging_window_closed` | 409 | More than 24 hours have passed since the lead's last message and there is no template to reopen the conversation. |
| `template_not_approved` | 409 | The template is not approved by WhatsApp. Only `approved` templates can be sent. |
| `outside_initiation_hours` | 409 | Outside the hours when the agent can start conversations. |
| `voice_number_missing` | 409 | The voice agent has no number to call from. |
| `webhook_endpoint_limit_reached` | 409 | The agent already has 3 active webhook endpoints. Pause or delete one before creating or reactivating another. |
| `webhook_endpoint_disabled` | 409 | The endpoint is paused and receives no deliveries, including test ones. Reactivate it with `active: true`. |
| `idempotency_key_reused` | 409 | This `Idempotency-Key` was already used with a different request. |
| `idempotency_key_in_use` | 409 | The request with this `Idempotency-Key` is still processing. Retry after `Retry-After`. |
| `rate_limit_exceeded` | 429 | You exceeded 120 requests per minute with this key, or 5 outbound calls. Retry after `Retry-After`. |
| `internal_error` | 500 | Something failed on our side. Retry the request, with the same `Idempotency-Key` if it carried one. |
| `provider_unavailable` | 502 | An upstream provider is not responding. Retry the request, with the same `Idempotency-Key` if it carried one. |
| `send_outcome_unknown` | 502 | The provider did not confirm the send or the call, and it may have gone through. Check the lead's messages or calls before retrying with a different `Idempotency-Key`. |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.