# Errors

> The problem+json error shape, what each status means, and which errors to retry.

URL: https://renzo-digital.com/docs/concepts/errors

Every error from `/api/v1` is an RFC 7807 problem document with `Content-Type: application/problem+json`. Each one has a stable `code`. Branch on `code`, never on `title` or `detail`: the text can change, the code does not.

## The shape

```json
{
  "type": "https://errors.renzo.app/watchlist_limit_reached",
  "title": "Watchlist Limit Reached",
  "status": 409,
  "code": "watchlist_limit_reached",
  "detail": "This product allows 3 watchlists.",
  "instance": "/api/v1/watchlists",
  "correlation_id": "0b6f3c1e8f4a4d2b9a573e2c1d0f9a11",
  "limit": 3,
  "held": 3,
  "product_code": "free"
}
```

| Field | Meaning |
| --- | --- |
| `type` | A URI made from the code. Treat it as an ID; it is not a web page. |
| `title` | A short summary of the error kind. |
| `status` | The HTTP status, the same as the response status. |
| `code` | The stable, machine-readable error code. See [Error codes](https://renzo-digital.com/docs/error-codes). |
| `detail` | A sentence about this occurrence. For people, not for code. |
| `instance` | The path that failed. |
| `correlation_id` | The request ID, also in the `X-Request-ID` header. Quote it to support. |

Some errors add fields, such as `limit`, `held` and `product_code` above, `retry_after_seconds` on a `429`, or `slug` and `access_level` on [`article_sign_in_required`](https://renzo-digital.com/docs/error-codes#article_sign_in_required). The [API reference](https://renzo-digital.com/docs/api) shows the possible codes of each operation, with an example body.

## Validation errors

A body or parameter that fails validation answers `422` [`validation_failed`](https://renzo-digital.com/docs/error-codes#validation_failed) with an `errors` list:

```json
{
  "type": "https://errors.renzo.app/validation_failed",
  "title": "Validation Failed",
  "status": 422,
  "code": "validation_failed",
  "detail": "The request body or parameters did not pass validation.",
  "instance": "/api/v1/watchlists",
  "correlation_id": "0b6f3c1e8f4a4d2b9a573e2c1d0f9a11",
  "errors": [
    { "location": ["body", "name"], "message": "Field required", "type": "missing" }
  ]
}
```

`location` names the part of the request: `body`, `query` or `path`, then the field. A few checks made by the endpoint itself, such as a `limit` over 100, answer the same code with only a `detail` and no `errors` list.

## Status codes

| Status | Meaning | Typical codes |
| --- | --- | --- |
| 400 | The request is malformed. | [`bad_request`](https://renzo-digital.com/docs/error-codes#bad_request), [`invalid_cursor`](https://renzo-digital.com/docs/error-codes#invalid_cursor) |
| 401 | No valid credential. | [`missing_credentials`](https://renzo-digital.com/docs/error-codes#missing_credentials), [`token_expired`](https://renzo-digital.com/docs/error-codes#token_expired), [`session_revoked`](https://renzo-digital.com/docs/error-codes#session_revoked) |
| 402 | A payment failed. | [`billing_payment_declined`](https://renzo-digital.com/docs/error-codes#billing_payment_declined) |
| 403 | The credential is fine, but the action is not allowed. | [`article_access_required`](https://renzo-digital.com/docs/error-codes#article_access_required), [`customer_account_deactivated`](https://renzo-digital.com/docs/error-codes#customer_account_deactivated) |
| 404 | Nothing there, or not yours. | [`not_found`](https://renzo-digital.com/docs/error-codes#not_found), [`watchlist_not_found`](https://renzo-digital.com/docs/error-codes#watchlist_not_found) |
| 405 | The path does not take this method. | [`method_not_allowed`](https://renzo-digital.com/docs/error-codes#method_not_allowed) |
| 409 | The request conflicts with the current state. | [`profile_incomplete`](https://renzo-digital.com/docs/error-codes#profile_incomplete), [`watchlist_limit_reached`](https://renzo-digital.com/docs/error-codes#watchlist_limit_reached), [`idempotency_key_reused`](https://renzo-digital.com/docs/error-codes#idempotency_key_reused) |
| 410 | The resource is gone for good. | [`article_archived`](https://renzo-digital.com/docs/error-codes#article_archived) |
| 413 | The body is too large. | [`payload_too_large`](https://renzo-digital.com/docs/error-codes#payload_too_large) |
| 415 | The body is not JSON. | [`unsupported_media_type`](https://renzo-digital.com/docs/error-codes#unsupported_media_type) |
| 422 | The body or parameters are invalid. | [`validation_failed`](https://renzo-digital.com/docs/error-codes#validation_failed), [`username_invalid`](https://renzo-digital.com/docs/error-codes#username_invalid) |
| 429 | Too many requests. | [`rate_limited`](https://renzo-digital.com/docs/error-codes#rate_limited) |
| 500 | A bug on our side. | [`internal_error`](https://renzo-digital.com/docs/error-codes#internal_error) |
| 502 | The payment provider failed. | [`billing_provider_failed`](https://renzo-digital.com/docs/error-codes#billing_provider_failed) |
| 503 | A dependency is down for a moment. | [`service_unavailable`](https://renzo-digital.com/docs/error-codes#service_unavailable), [`dependency_unavailable`](https://renzo-digital.com/docs/error-codes#dependency_unavailable), [`auth_temporarily_unavailable`](https://renzo-digital.com/docs/error-codes#auth_temporarily_unavailable) |

> **Note:** A resource that belongs to someone else answers `404`, not `403`, so IDs do not leak.

## How to handle errors

1. **Read `code`.** Handle the codes your feature expects, such as a plan limit. Show `detail` only as a fallback.
2. **On `401` [`token_expired`](https://renzo-digital.com/docs/error-codes#token_expired)**, refresh the token pair once, then repeat the call. On any other `401`, sign in again. See [Authentication](https://renzo-digital.com/docs/authentication).
3. **On `429` and `503`**, wait for the `Retry-After` header (seconds), then retry. See [Rate limits](https://renzo-digital.com/docs/concepts/rate-limits).
4. **On `500` and `502`**, retry a few times with backoff. For writes, send an `Idempotency-Key` so a retry cannot act twice. See [Idempotency](https://renzo-digital.com/docs/concepts/idempotency).
5. **Do not retry** other `4xx` errors unchanged. Fix the request first.
6. **Log `correlation_id`** with every error.

## Errors that are not HTTP errors

A few codes never come as an HTTP status:

- MCP tool calls report errors inside the tool result, such as [`mcp_daily_limit_reached`](https://renzo-digital.com/docs/error-codes#mcp_daily_limit_reached). See [MCP](https://renzo-digital.com/docs/mcp).
- A market quote can carry an `error` object when a symbol's data is stale or missing, such as [`market_data_stale_cache`](https://renzo-digital.com/docs/error-codes#market_data_stale_cache). The call itself answers `200`.

The [error code catalog](https://renzo-digital.com/docs/error-codes) marks these with the status "none".
