API DOCUMENTATION / AUTHENTICATION
Authentication
Create an API key, send it as a bearer token, keep it safe and read the 401 error.
Bearer API key
Every request to the API carries your key in the Authorization header:
Authorization: Bearer <API_KEY>New keys look like jc_live_<UUID>.<43-character secret>. Keys issued before October 2026 start with ar_live_ and still work, so keep using an older key if you have one. Send the whole key, including the part after the dot.
Create a key
Sign in at api.headcountlabs.com/data/login and create keys at api.headcountlabs.com/data/keys. Every key includes the free monthly allowance described on the pricing page. All keys on an account share one set of limits, so a second key does not give you more room.
Headcount Labs stores a digest of each key, not the key itself. The full key is shown once when you create it, so copy it then. If you lose it, create a new key.
Make your first authenticated call
Count some jobs. A count returns one number, so it is a cheap way to check that your key works.
export HEADCOUNTLABS_API_KEY="..." # paste your key here, in your own shell
curl --fail-with-body -sS \
"https://api.headcountlabs.com/v1/jobs/count?country=US&work_arrangement=remote" \
-H "Authorization: Bearer $HEADCOUNTLABS_API_KEY"A good key returns {"count": ..., "snapshot_watermark": "..."}. The code samples show the same call in Python, Node.js, Ruby and PHP.
Keep the key safe
- Store it in a secret manager or a protected environment variable on your server.
- Never put it in browser code, mobile app bundles, URLs, source control, client-side logs or analytics events.
- Never send it, or your password, by email. Support will not ask for either.
- If a key may have leaked, open the keys page and press Rotate to give that key a new secret, or Revoke to switch it off. The old secret stops working at once and a revoked key returns
401. The new secret is shown once. - Give each system its own key, so you can replace one without touching the others.
Authentication errors
A missing, malformed, unknown or disabled key returns 401 with WWW-Authenticate: Bearer (and error="invalid_token" when the key was well formed but not accepted). A typical body looks like this:
{
"error": {
"code": "missing_api_key",
"message": "No API key was sent. Send the header \"Authorization: Bearer <key>\" with a key from https://headcountlabs.com/data/keys.",
"request_id": "<uuid>",
"alias": "invalid_api_key"
}
}A request refused with 401 is not counted against your allowance or your request limit. Check the key for a missing character, a stray space or newline, and the header name. The code is specific: missing_api_key, wrong_auth_header, malformed_authorization, or invalid_or_expired_api_key. Each of these also has alias invalid_api_key so older clients can still branch on that. A 403 insufficient_scope means the key or sign-in is valid but is missing a permission such as jobs:read or companies:read; reconnect and approve it. Overage, spend caps and used-up allowances return 429 (data_limit_exceeded or rate_limited), not 403. A 402 card_required means a payment method is needed before paid usage can continue.
MCP uses sign-in, not a key
The MCP server at https://api.headcountlabs.com/mcp signs you in with OAuth in your browser, so there is no key to copy into your AI client. Each connection appears on your keys page as a key labeled MCP: <client name>; delete it to disconnect. The sign-in asks for scopes: jobs:read (the default), companies:read, usage:read and overage:write. The API key is for direct REST calls. The MCP tools page lists the scope each tool needs. Keys from an MCP sign-in (OAuth) expire after one hour; the client should refresh the token or sign in again. See the MCP page for setup.