# Responses and errors ## Success envelope ```json { "data": {}, "meta": { "requestId": "req_…", "environment": "test" } } ``` `data` is an object for one resource and an array for a list. `meta.environment` is `test` or `live`, from the key. Every response also carries an `X-Request-Id` header and the three `RateLimit-*` headers ([rate limits](rate-limits.md)). Responses with listing content add `meta.page` (searches), `meta.dataLastUpdatedAt`, the [`compliance`](../reference/compliance.md) block and `warnings`: ```json { "data": [], "meta": { "requestId": "req_…", "page": { "limit": 24, "nextCursor": null, "total": 0, "totalIsCapped": false }, "dataLastUpdatedAt": "2026-11-10T14:59:00.000Z", "environment": "live" }, "compliance": {}, "warnings": [ { "code": "close_date_clamped", "message": "…", "fix": "…" } ] } ``` A warning says the request was answered but not exactly as asked (a clamped date, a filter that doesn't apply to some classes, rooms or open houses left out as stale). Codes: `close_date_clamped`, `filter_not_applicable`, `rooms_stale`, `open_houses_stale`. The sandbox answers with the same warnings as live. A warning describes the request, not the page of results: `filter_not_applicable` comes with a `beds` filter whenever the search could return land or commercial listings, even if this page holds only houses ([search](../reference/endpoints/search-listings.md) says how to avoid it). Responses to key-protected endpoints are `Cache-Control: private, no-store`. ## Error envelope ```json { "error": { "code": "client_token_required", "message": "This endpoint acts for one consumer and needs a client token.", "fix": "Mint a token on your server with POST /v1/client-tokens (sk_ key) and send it as the X-Client-Token header with your pk_ key.", "docs": "https://docs.apidata.one/errors/client_token_required", "requestId": "req_…" } } ``` `validation_failed` adds `fields: [{ path, problem, expected }]`. Messages say what is wrong and `fix` says exactly what to do. Every code has its own page under [errors/](../errors/). | HTTP | Codes | | ---- | -------------------------------------------------------------------------------------------------------- | | 400 | `validation_failed`, `client_id_must_be_opaque`, `pagination_limit_reached`, `shape_invalid`, `shape_too_large`, `webhook_url_invalid`, `webhook_destination_refused`, `webhook_ping_failed` | | 401 | `missing_api_key`, `invalid_api_key`, `key_revoked`, `client_token_required`, `client_token_invalid`, `client_token_expired`, `client_token_account_mismatch` | | 403 | `secret_key_in_browser`, `secret_key_required`, `origin_not_allowed`, `account_suspended`, `account_pending`, `tier_insufficient` | | 404 | `not_found` (an object outside your account or consumer, a place, or an unknown route or method), `listing_not_found` | | 409 | `idempotency_conflict`, `limit_reached`, `shape_in_use` | | 429 | `rate_limited`, `quota_exceeded` (both carry `Retry-After`) | | 500 | `internal_error` (always carries a `requestId`), `data_stale` (listing content more than 12 hours old; carries `Retry-After`), `temporarily_unavailable` (a write kept losing a race, or the service was busy, or its database slow to answer or out of reach; carries `Retry-After`, and repeating the request is safe) | The API itself never answers `502`, `503` or `504`. `data_stale` and `temporarily_unavailable` are sent as `500`, with the JSON body above and their `Retry-After` header: tell them from `internal_error` by `error.code`, never by the status. Retry those two after `Retry-After`. Most HTTP client libraries retry a `503` by themselves but not a `500`, so write that retry yourself. An HTML page with status `502`, `503` or `504` does not come from the API. It is the hosting platform's own answer while it could not reach the API, for example for a moment during a deploy. It has no JSON body and no `requestId`; retry it after a few seconds. Some codes add fields of their own beside `code` and `message`, inside `error`: `limit` (`limit_reached`), `savedSearchIds` (`shape_in_use`), `result` and `statusCode` (`webhook_ping_failed`). Each code's page says which. ## Order of checks A request is checked in this order, and the first failure is the one reported: the key (missing, malformed, unknown, revoked), the browser check (an `sk_` key in a browser), the origin (a `pk_` key from an unlisted domain), the key type (a `pk_` key on an `sk_`-only endpoint), the client token, the client ID, the account status (pending, suspended), and only then the request body. So a missing header or a malformed body never hides a bad key or a secret key in a browser, and once the origin check has passed, a listed site can read every later error through CORS. ## Request bodies Request bodies are JSON only: `Content-Type: application/json` (UTF-8), at most 64 KiB. Anything else, including form bodies, other charsets and malformed JSON, is `400 validation_failed` with `fields[0].path` of `body`. A request with no body is never refused for its `Content-Type`, whatever that header says: a `DELETE` sent with `Content-Type: application/json` and no body works. A route that needs a body refuses an empty one through its field checks (`fields[0].path` of `body.listingKey` or `body.clientId`). Unknown fields are ignored. The body is read in full before the request is processed, so a slow upload never holds a database connection. A request whose path can't be read is `400 validation_failed` with `fields[0].path` of `path`: a broken percent-escape (`problem` is `malformed`), or a part of the path longer than 100 characters where a route takes a value (`too long`). The answer repeats nothing of the request, and it comes before the key is checked. Three answers come from the HTTP server itself, before the API has a request to work on: - `400 Bad Request` for a malformed HTTP request, including an HTTP/1.1 request with no `Host` header. - `408 Request Timeout` for a request whose headers and body haven't all arrived within 30 seconds. The connection then closes. - `431 Request Header Fields Too Large` for oversized headers. They carry no error envelope and no `requestId`. Nothing was done with the request: send it again on a new connection (after a 400 or a 431, with the request itself put right).