API reference

Error responses

Every failed request tells you what went wrong in code and how to trace it in requestId.

{
  "success": false,
  "error": "Unknown query type: summary. Did you mean 'summary_metrics'?",
  "code": "VALIDATION_ERROR",
  "requestId": "req_abc123def456",
  "details": [
    { "field": "parameters[0]", "message": "Unknown query type: summary", "suggestion": "Did you mean 'summary_metrics'?" }
  ]
}

Branch on code, not on error, which is written for people. Every response also carries the request ID in the X-Request-ID header.

Look up a code

These are the codes /v1/query and its subroutes return.

CodeStatusMeaningWhat to do
AUTH_REQUIRED401No valid API keySend a key, or replace a revoked one
ACCESS_DENIED403The key can't reach this website or actionCheck the key's scopes and website access
MISSING_PROJECT_ID400No website_id, link_id, schedule_id or organization_idAdd the ID the query type needs
VALIDATION_ERROR400A field, date, filter or query type is wrongFix the fields listed in details
COMPILATION_ERROR400The query can't be builtChange the query definition
FEATURE_UNAVAILABLE402Your plan doesn't include this query typeUpgrade, or drop that query type
RATE_LIMITED429Too many requestsWait Retry-After seconds
INTERNAL_SERVER_ERROR500Something broke on our sideRetry with backoff; contact support with the request ID
SERVICE_UNAVAILABLE503Keys can't be checked for a momentWait Retry-After seconds (5)

Other endpoints can add their own codes, so keep a fallback for codes you don't know. SQL and event tracking list theirs.

Catch partial failures

A query with several parameters can succeed overall while one parameter fails.

{
  "success": true,
  "data": [
    { "parameter": "summary_metrics", "success": true, "data": [] },
    { "parameter": "top_pages", "success": false, "error": "Query execution failed", "data": [] }
  ]
}

Check success on each item in data, not only at the top. An empty data on a failed item means no answer, not zero.

Retry the right errors

StatusRetry?
400, 401, 402, 403No. Fix the request first.
429Yes, after Retry-After seconds. Add jitter when many workers share a key.
5xxYes, with bounded exponential backoff

How is this guide?