Skip to main content
HTTP errors use a stable envelope:
Authentication errors (401 and 403 with missing_api_key, invalid_api_key, or missing_api_key_scope) carry "status": "failure" instead of "failed". Branch on the HTTP status and error.code, not on status.

HTTP Policy

Common authentication codes are missing_api_key, invalid_api_key, and missing_api_key_scope. Validation codes begin with developer_v3_search_ or developer_v3_enrich_ and identify the affected contract. Not every error body is JSON. Read the body as text and parse it only when the Content-Type is application/json.

Async Failures

An accepted request can later finish with a failed result. These failures appear inside the resource rather than as an HTTP error:
For Search, completed_with_errors is a terminal aggregate with usable results. Keep every ready result and handle failed items individually. Treat failed as a terminal search with no ready results. For Enrich, stop polling on completed or failed. The request_id in the response is the status handle for accepted work.

Safe Retry Pattern

  1. Choose how retries stay idempotent. If you send nothing, Orbit generates a request ID, and a retried POST after a lost response can start duplicate work. To make retries safe, create an ID before the first POST and send it as request_id in the body or as the Idempotency-Key header. If you send both, Orbit uses request_id.
  2. Persist that ID, and the returned search_id or Enrich request_id, before you poll.
  3. Retry lost responses, 429, and 5xx errors with the same ID and the exact same body. A lost response is a timeout, a refused or reset connection, or a connection that closes before the response arrives; Orbit may have accepted the request. Do not retry other 4xx errors unchanged.
  4. On 429, wait at least Retry-After seconds. Without the header, wait 1 second. On repeated failures, wait the larger of Retry-After and an exponential backoff with jitter, for example 1, 2, 4, then 8 seconds, each varied by up to 20%.
  5. Cap retries, for example at 5 attempts, then surface the error with its error.code.
  6. Stop polling on every terminal status.
  7. Keep each request_id or Idempotency-Key unique across your whole application. It belongs to the API key that sent it, so when one key serves many users, add a per-user prefix.
Reuse a request_id or Idempotency-Key only with the exact same request. Using one for different work returns 409.

Python Example

This standard-library client retries 429, 5xx errors, and lost responses with the same Idempotency-Key, and never logs the key. You own the key: create it and save it before the first call, so a later call with the same key can resume the request if every attempt fails.
Catch OSError and http.client.HTTPException, not only URLError and TimeoutError. A connection that closes before the response arrives raises http.client.RemoteDisconnected or ConnectionResetError, and on Python 3.9 a read timeout raises socket.timeout. None of these is a URLError.