Skip to Content
BuddyGeoDocs

Authentication

Send your key in the X-API-Key header. Create one key per environment, rotate with an overlap and revoke what you no longer use.

Every API request is authenticated with an API key that belongs to a workspace.

Send the key

Put the key in the X-API-Key request header:

curl "https://api.buddygeo.com/v1/reverse?lat=43.6426&lon=-79.3871" \
  -H "X-API-Key: YOUR_API_KEY"

Keep keys out of query strings and out of code that ships to browsers or mobile apps: anyone who can read the key can spend your credits. Call BuddyGeo from your server and store the key in your secret manager or environment.

# 200: authenticated lookup with an active key
curl "https://api.buddygeo.com/v1/reverse?lat=43.6426&lon=-79.3871" \
  -H "X-API-Key: YOUR_API_KEY"

# 401 missing_api_key: no header
curl -i "https://api.buddygeo.com/v1/reverse?lat=43.6426&lon=-79.3871"

# 401 invalid_api_key: not a recognized BuddyGeo key
curl -i "https://api.buddygeo.com/v1/reverse?lat=43.6426&lon=-79.3871" \
  -H "X-API-Key: not-a-key"

Manage keys

Keys live under API keys in the dashboard.

  • Create a key with a label and an environment tag such as production or development. The secret is revealed once; after that only the masked form (bg_live_7f3a…c91d) is shown.
  • One allowance, many keys. All keys of a workspace share the same monthly credits and the same requests-per-second limit. Separate keys buy you separate labels in Usage and Request logs, and the ability to replace one without touching the others.
  • Owners and admins can create, rotate, rename and revoke keys. Members can see the list and which key made a request, but cannot change keys.

Key states

StateMeaningRequests with this key
activeNormal working keyAccepted
expiringRotated, still inside its overlap periodAccepted until the overlap ends
rotatedRotated and the overlap has ended401 revoked_api_key
revokedRevoked by an owner or admin401 revoked_api_key

Rotate without downtime

Rotating a key issues a replacement and keeps the old key working for an overlap you choose, from 0 to 168 hours (7 days).

  1. Open API keys, choose Rotate key on the key and pick the overlap.
  2. Copy the new secret. It is shown once.
  3. Deploy the new secret. During the overlap both keys are accepted, and the old one is marked expiring.
  4. When the overlap ends, the old key becomes rotated and its requests fail with 401.

To cut a key off immediately, for example after a leak, revoke it instead. The next request with a revoked key fails with 401:

{
  "request_id": "req_kjsvrb9pvtvv",
  "status": 401,
  "error": {
    "code": "revoked_api_key",
    "message": "This API key was revoked and can no longer be used.",
    "next_step": "Switch to an active key, or create a replacement under API keys in the dashboard."
  }
}

To verify revocation immediately, revoke a test key under API keys and send a lookup with it: the gateway refuses the request with 401 and records it in Request logs.

Authentication errors

All three are 401 responses with the error body shown above. They are never charged, and requests made with a known but unusable key are recorded in the request log with the outcome unauthorized. Passing API keys in URL query strings (such as ?api_key=...) is always rejected with 401.

error.codeCauseFix
missing_api_keyNo X-API-Key header was sentAdd the header
invalid_api_keyThe key is not recognizedCheck for missing characters or stray whitespace
revoked_api_keyThe key was revoked, or rotated and past its overlapSwitch to the active or replacement key

Open in the app

On this page