# Errors (/docs/errors)

When an error occurs, the API returns an appropriate HTTP status code with the request fields of a successful response (`tool`, `query`, `requestId`, `timestamp`, `elapsed`, `cached`) and no results. `results` is `null`, or left out on the Site Report, Email Security and Redirect Check APIs. `errors` holds the reason. The HTTP status is in the status line only. Errors from the Batch Runs API (`/v1/runs`) are only `{ "errors": [...] }`.

## HTTP Status Codes

| Status | Name | Meaning |
| --- | --- | --- |
| **200** | OK | Request was successful. The response contains the requested data in the results field. |
| **400** | Bad Request | Invalid query or parameters, including a parameter the tool does not take: an unknown or misspelled parameter is refused, never ignored, and the message names it and lists the allowed ones. Check the URL structure and parameter values. |
| **401** | Unauthorized | Invalid, missing, or expired API key. Verify your API key is correct and your account is active. |
| **402** | Payment Required | Out of credits, or calls are blocked by a debt after a refund or dispute. A batch or a reverse DNS range also gets a `402` when what it reserves, one credit per item or address, does not fit your balance. Buy credits as you go, or subscribe for discounted credits, to continue — see [Credits & Billing](/docs/credits). Not billed. |
| **404** | Not Found | No endpoint by that name (`unknown_tool`), or no such path or method on it (`unknown_endpoint`). Check the name against the [Available APIs](/docs#available-apis). Also `not_found` when the thing asked about does not exist: the domain on `/v1/email`, the host on `/v1/site`, or the run on `/v1/runs/{id}`. Not billed. |
| **422** | Unprocessable | The request is well-formed, but the tool cannot answer it, and retrying will not help: on `/v1/dns`, no server can be found to ask; on `/v1/domain`, no WHOIS or RDAP server is known for the TLD. Not billed. |
| **429** | Too Many Requests | Too many requests too quickly. Wait, then retry with incremental backoff. See [Rate Limits](#rate-limits). |
| **500** | Internal Server Error | An unexpected error occurred while processing your request. Please try again later or contact support with the `requestId`. You can reach us at [support@dns.tools](mailto:support@dns.tools). |
| **503** | Service Unavailable | A server the lookup depends on (a registry, WHOIS or RDAP server, or resolver) timed out, refused the connection or is throttling requests. Retry after the number of seconds in the `Retry-After` header. Not billed. |

> Check the HTTP status code, then branch on `errors[0].code`. Implement retry logic with incremental backoff for transient errors (`5xx` status codes).

```json title="Error Response Example"
{
  "tool": "dns",
  "query": "example..com",
  "requestId": "d4b81f3f-b684-429c-9ff3-aeac635ecf58",
  "timestamp": "2026-12-01T18:27:56.569Z",
  "elapsed": 1287,
  "cached": false,
  "errors": [
    {
      "code": "invalid_query",
      "message": "Invalid query 'example..com' for query type: SOA",
      "retryable": false
    }
  ],
  "results": null
}
```

A name that is valid but does not exist is not an error. It is a `200` with a negative answer, and it is billed.

**Error Fields**

- `errors` (array): 
  Every tool. Empty for a clean answer. On a `200` from `/v1/dns`, the questions of the lookup that failed; on any other status, why the request failed. Each entry has a `code`, a `message`, `retryable`, and when they apply `name` and `type`, `source`, `retryAfter` and, with `verbose`, `detail`.
   Examples: `[]`, `[{ "code": "upstream_timeout", ... }]`.

## Rate Limits

We protect the API at the edge. If you send too many requests too quickly, the API returns a `429` status code. Wait, then retry with incremental backoff, and spread requests over time.