API DOCUMENTATION / ERRORS AND RESPONSE HEADERS

Errors and response headers

Interpret structured errors, status mappings, usage headers, and conditional rate-limit metadata.

Structured errors

{
  "error": {
    "code": "query_too_broad",
    "message": "The search was stopped before it finished (searches are limited to 90 seconds). Do not retry the same call: it would be stopped again. The query is too broad: broad q= text searches are the slowest. For job titles use title= (or title_advanced=) instead of q=, add filters such as state, city, company or source, or use a smaller limit.",
    "request_id": "<uuid>",
    "alias": "service_unavailable",
    "retryable": false
  }
}

Every error body has code, message and request_id. Branch on code, not on the message. New codes may also include alias (the previous code string, so older clients can still key off it), limit_scope on a 429, and retryable when waiting and repeating the same call will not help.

Common status codes

HTTPMeaning
400A parameter, body, identifier or cursor is wrong. Fix the request or restart from the first page; do not retry it unchanged.
401The bearer key is missing, in the wrong header, malformed, unknown, revoked or expired. See the specific code (below). Not counted against your allowance.
402A payment method is required before paid usage can continue (card_required).
403The key or sign-in is valid but is missing a permission (insufficient_scope). This is not an overage or spend-cap error; those are 429.
404A requested job, company, export, file, usage key or route was not found.
405This route does not accept that HTTP method. The Allow header lists the methods it does accept.
410The job or company ID was withdrawn or merged. A merged company may also include a successor id.
308A merged job or company ID redirects to a canonical ID; job and company response bodies differ.
422A usage report exceeds source-row or group limits. Narrow the period.
429A request window, concurrency cap, or data allowance was reached. Wait Retry-After seconds. The body's limit_scope says which limit you hit.
503The catalog is unavailable, the service is temporarily down or busy, HTML descriptions are not published, or a search was stopped at the 90-second cap (query_too_broad: do not retry the same call). Follow Retry-After when it is present; its absence on query_too_broad means do not replay the search.
504The query could not start, or did not finish within the request budget. A couldn't-start error is retryable; wait Retry-After seconds. A search stopped at the 90-second cap is 503 query_too_broad, not 504.

Usage response headers

After usage admission, responses can include X-Request-Id, X-Data-API-Usage-Mode, X-Data-Records-Used, and X-Data-Records-Reset. Enforced request windows add RateLimit-*; a configured returned-record cap can add X-Data-Records-Limit and X-Data-Records-Remaining. Daily request counters use X-Data-Requests-* with X-Data-Requests-Window: day when a 24-hour window is in the policy. Headers depend on policy and usage-snapshot availability; they are not guaranteed on every response. Retryable 429, 503 and 504 answers set Retry-After in seconds.

Recover deliberately

Read the structured error.code, and limit_scope or retryable when present, before retrying. Correct a 400 request rather than retrying it unchanged. Follow Retry-After on a 429 and on a busy or generic 503. Do not retry a query_too_broad (or a 503 whose message says the search was stopped) with the same filters: narrow it, for job titles with title= or title_advanced= instead of q=. Quote the request_id when you contact support.

Error codes

CodeHTTPWhat to do
invalid_request400A parameter, body or cursor is wrong, or a cursor belongs to an older catalog snapshot. Fix the request or restart from the first page; do not retry it unchanged.
invalid_api_key401Kept as alias on the more specific 401 codes below, and used when a key becomes invalid mid-request. Send Authorization: Bearer <key> with a key from https://headcountlabs.com/data/keys.
missing_api_key401No API key was sent. Send the header Authorization: Bearer <key> with a key from the keys page. Alias: invalid_api_key.
wrong_auth_header401The key was sent in a header such as X-API-Key. This API reads only Authorization. Alias: invalid_api_key.
malformed_authorization401The Authorization header is missing Bearer , uses a different scheme, is empty, holds a placeholder such as ${HEADCOUNTLABS_API_KEY}, or the value is not a Headcount Labs key (those start with jc_live_ or ar_live_). Alias: invalid_api_key.
invalid_or_expired_api_key401The key was well formed but was not accepted: it is unknown, revoked or expired. WWW-Authenticate includes error="invalid_token". A 401 is not counted against your allowance. Alias: invalid_api_key.
insufficient_scope403The key or MCP sign-in is valid but is missing a required permission (for example jobs:read or companies:read). Reconnect and approve that permission. This is not an overage or spend-cap error.
card_required402A payment method is required before paid usage can continue. Add a card on the Billing page (/data/billing).
not_found404There is no such API route.
job_not_found404No job has this ID.
company_not_found404No company has this ID.
export_not_found404The requested export or export file was not found or is no longer available. Older clients may still see alias job_not_found. Alias: job_not_found.
file_not_found404An MCP download link is invalid or has expired. Call read_file for a new link. The body includes request_id.
api_key_not_found404A usage report named an api_key_id that is not one of your keys.
method_not_allowed405This route does not accept that method. Use one of the methods in the Allow header.
job_withdrawn410The job was withdrawn.
company_withdrawn410The company ID was merged or is no longer in the current public release. The body may include a successor company id.
report_too_large422A usage report covers more than 100,000 events or 1,000 groups. Narrow the period.
rate_limited429A request window (per minute, UTC day or month), a per-key concurrency cap, a search already in progress, or too many unrecognised keys from this address was reached. Wait Retry-After seconds. See limit_scope for which limit you hit.
data_limit_exceeded429This response would go past your records allowance, daily data allowance, spend cap, free records or overage limit, so no data was sent. Wait Retry-After seconds, or raise the cap on the Billing page. See limit_scope.
query_timeout504The query could not start within a few seconds, or did not finish within the request budget. A couldn't-start error is retryable: wait Retry-After seconds (a few seconds) and try again, or narrow the filters. This is not the 90-second stopped-search cap; that is query_too_broad.
query_too_broad503The search was stopped at the 90-second cap and no records were charged. There is no Retry-After header. Do not retry the same call: it would be stopped again. For job titles use title= (or title_advanced=) instead of q=, add filters such as state, city, company or source, or use a smaller limit. Older clients can still key off alias service_unavailable. On MCP, retryable is false and the message also names filters.title. Alias: service_unavailable.
catalog_unavailable503The versioned jobs catalog is being published or is not available yet. Retry after Retry-After seconds (typically 30).
service_unavailable503A temporary failure, or the catalog changed during the request: retry after Retry-After seconds. When the message says the search service is busy (long-running queries already running), Retry-After is 60 seconds, matching “retry in a minute.” A search stopped at the 90-second cap is query_too_broad, not this code.
html_unavailable503description_format=html was requested; confirmed source HTML is not published yet. Use description_format=text. On list and export, alias is invalid_request (the previous list code). Alias: invalid_request.

The `limit_scope` field

Every 429 body includes limit_scope, so you can tell which limit you hit:

limit_scopeMeaning
minuteThe short request window (for example 60 requests per 60 seconds) is full.
dayThe UTC-day request window or the daily records allowance is full.
monthThe monthly request allowance or monthly records allowance is full.
concurrencyThis API key already has the maximum number of requests running at once (10). Wait for one to finish.
search_in_progressThis API key already has a search running. Wait for it to finish, then retry.
bad_keyToo many unrecognised API keys came from this address. Wait and try again.
overageThe monthly overage limit has been reached. Raise it with the set_overage tool or with PUT /v1/account/overage.
spend_capThe monthly spend cap has been reached. See the Billing page (/data/billing).
free_recordsThis month's free records are used up. Turn on paid usage on the Billing page to continue.

MCP errors

MCP tool errors use the same code, message and request_id in the tool result's error object, plus http_status and often retryable. JSON-RPC authorization failures use the same key-error codes (missing_api_key, wrong_auth_header, malformed_authorization, invalid_or_expired_api_key). Keys from an MCP sign-in (OAuth) expire after one hour; the client should refresh or sign in again. Further MCP tool codes are on the MCP tools page.

Handling errors in code

The code samples check the status, read the error.code and print the request_id in Python, Node.js, Ruby, PHP and curl. Quote the request_id when you contact support. The rate limits page says when to retry a 429.

Continue in the reference

Check related request behavior before you build.

View route status and methods Discuss API requirements
All API documentation