Home / API errors and retries

API errors and retries

Handle HTTP statuses and error.code values returned by Labrika. Learn when to retry a request and which details to save for diagnosis.

On this page

The Public API uses standard HTTP statuses and a consistent JSON error format. For programmatic handling, check error.code, not the message text.

Validation error · 400 Bad Request

{
  "error": {
    "request_id": "req_example",
    "code": "validation_error",
    "message": "Request validation failed.",
    "details": [
      {
        "field": "collected_at",
        "code": "invalid_datetime",
        "message": "Invalid RFC3339 datetime."
      }
    ]
  }
}

Error fields

request_id Request identifier used for logs and support requests.

code Stable machine-readable error reason.

message Brief diagnostic message in English.

details Optional list of individual field errors or additional constraints.

HTTP statuses

HTTP Meaning Client action
400 The request failed validation. Correct the parameters according to error.code and details.
401 The API key is missing or invalid. Check the Authorization header and key status.
403 The key is recognized, but access is denied. Check the mode, scopes, IP allowlist, and Public API access.
404 The resource was not found or is not accessible to the key. Retrieve the identifiers from the API again and verify the selected object.
429 The rate limit was exceeded. Wait for the number of seconds specified by Retry-After.
500 Internal API error. Retry GET requests after a delay. Before retrying a write or run operation, check its outcome; if the error persists, send the request ID to support.
409 A state, estimate or retry conflict occurred. Read error.code. After an uncertain launch result, do not change Idempotency-Key until you have checked the previous operation. If an estimate explicitly expired or mismatched, obtain a fresh one following the method rules. error.code
413 The request body exceeds the allowed size. Reduce it to the limit of this method. error.code
422 The request cannot be completed under the current conditions. Check the error code, such as insufficient credits or an unrecognized product. Retrying without fixing the cause will not help. error.code

Error codes

The following table lists general codes as well as authentication and keyword rankings endpoint errors.

HTTP Code Reason
400 validation_error One or more path/query parameters do not match the contract.
400 invalid_request_id The client-supplied X-Request-ID has an invalid format.
401 invalid_api_key The key is missing, has an invalid format, or is not recognized.
401 invalid_api_key_location The key was not passed in the Authorization: Bearer header.
401 api_key_revoked The key has been revoked.
401 api_key_expired The key has expired.
401 api_key_disabled The key is disabled.
403 wrong_key_mode A live key was used with the test API or a test key was used with the live API.
403 ip_not_allowed The client IP address is not in the key's allowlist.
403 insufficient_scope The key does not have the scope required by the endpoint.
403 serp_subscription_required The API key owner has no active Business or Agency subscription. Activate one of these subscriptions to retrieve keyword rankings through the live API.
403 public_api_user_blocked, public_api_disabled User access is restricted or the Public API is temporarily disabled.
404 not_found The site, search engine, rank check, or another resource was not found.
429 rate_limit_exceeded The request limit for the current window has been exhausted.
500 internal_error Internal service error; the operation outcome may need verification.

Retries

400–404 Do not retry the request unchanged: correct the parameters, key, or permissions first.

429 Retry after the delay specified by Retry-After.

500 For idempotent GET requests, use exponential backoff with a limited number of attempts.

network A GET request can be safely retried after a timeout or dropped connection.

Request ID and rate-limit headers

Every response contains X-Request-ID. The same value is available in an error as error.request_id. Store it together with the endpoint, request time, and HTTP status before contacting support.

Header Meaning
X-Request-ID Unique request identifier for diagnostics.
X-RateLimit-Limit Maximum number of requests in the current window.
X-RateLimit-Remaining Number of requests remaining.
X-RateLimit-Reset Unix timestamp when the current window ends.
Retry-After Number of seconds until a retry is allowed after a 429 response.

For a missing or invalid key, rate-limit headers describe failed attempts per IP. After authentication, they describe the applicable key or account limit. Headers may be absent for blocks before rate-limit checks or if the counter is unavailable.

The shared API/MCP usage budget is exhausted. For HTTP 429, inspect error.code: usage_budget_exceeded differs from the rate_limit_exceeded frequency limit. Respect Retry-After; do not retry continuously without a delay.

HTTP 202 means the request was accepted, not that processing finished. Save the returned identifier and check the state with the specified GET method. HTTP 200 when reading a state is not proof that the task succeeded: inspect status and error fields. Respect retry_after_seconds when returned.