# Error codes reference

> Every Wayline API error code with its HTTP status, what it means, whether to retry and how to fix it. Linked from each error's docs_url.

Source: https://www.wayline.cloud/docs/errors

All errors share one envelope with a stable `code`. The `docs_url` in each error links straight to the matching section below. Errors are **never billed**. For retry strategy, see [Errors & retries](/docs/concepts/errors-and-retries).

```json
{
  "error": {
    "code": "RATE_LIMITED",
    "message": "Rate limit exceeded.",
    "request_id": "req_01JD8Q4ZK7V3",
    "docs_url": "https://www.wayline.cloud/docs/errors#rate-limited"
  }
}
```

## 402 Payment Required: `SPEND_LIMIT_REACHED`

You set a monthly spend limit on the billing page and this calendar month (UTC) has reached it. The request is refused before any work is done and is **not billed**. Raise or remove the limit and retry; there is nothing else to change.

```http
HTTP/1.1 402 Payment Required
Content-Type: application/json
X-Request-Id: req_4f1c9a2b7d3e4f50a1b2c3d4e5f60718

{
  "error": {
    "code": "SPEND_LIMIT_REACHED",
    "message": "Monthly spend limit reached.",
    "request_id": "req_4f1c9a2b7d3e4f50a1b2c3d4e5f60718",
    "docs_url": "https://www.wayline.cloud/docs/errors#spend-limit-reached"
  }
}
```

Other 402 codes use the same body: `PAYMENT_REQUIRED` (no card on file, or the account is suspended after unpaid invoices) and `FREE_QUOTA_EXHAUSTED`. Do not retry a 402 automatically.

## 429 Too Many Requests and `Retry-After`

`RATE_LIMITED` means your key sent more requests per second or per minute than its plan allows. Every response carries `X-RateLimit-Limit`, `X-RateLimit-Remaining` and `X-RateLimit-Reset`; a 429 adds `Retry-After` with the whole number of seconds to wait.

```http
HTTP/1.1 429 Too Many Requests
Content-Type: application/json
Retry-After: 1
X-RateLimit-Limit: 50
X-RateLimit-Remaining: 0
X-RateLimit-Reset: 1
X-Request-Id: req_7e6d5c4b3a2918076f5e4d3c2b1a0918

{
  "error": {
    "code": "RATE_LIMITED",
    "message": "Rate limit exceeded.",
    "request_id": "req_7e6d5c4b3a2918076f5e4d3c2b1a0918",
    "docs_url": "https://www.wayline.cloud/docs/errors#rate-limited"
  }
}
```

Wait at least `Retry-After` seconds, then retry with exponential backoff and jitter. `TEST_KEY_LIMIT_REACHED` (429) is a test key's daily cap; it resets at midnight UTC, so `Retry-After` can be hours.

## All error codes

## Google-compatible endpoint errors

`/maps/api/distancematrix/json` returns Google-style statuses (`INVALID_REQUEST`, `MAX_ELEMENTS_EXCEEDED`, `OVER_QUERY_LIMIT`, `REQUEST_DENIED`, `UNKNOWN_ERROR`) in the `status` field with an `error_message`, so existing Distance Matrix error handling keeps working. See the [migration guide](/docs/guides/migrate-from-google-distance-matrix).
