Getting StartedAuthentication & API Keys

Authentication & API Keys

Create, send, store and rotate Air Pixels Data API keys, and fix the 401 and 403 errors that follow a bad key.

How keys work

Send your key in a header on every request. One key works for REST, for MCP and for every dataset your plan includes.

  • Format: ap_live_ followed by 32 letters and digits.
  • Prefix: the first 12 characters identify the key. GET /v1/usage returns them as key_prefix. Quote the prefix to support, never the full key.
  • Read-only: a key can read data and manage its own account, nothing else.
  • Shown once: Air Pixels stores only a SHA-256 hash. A lost key cannot be recovered, only replaced.
  • Account-level limits: plan, quota and billing belong to the account (one per email). An account can hold several keys. Rate limits apply per key; the monthly quota is shared by all of them.

Create a key

Sign in to the Data Console

Open the Data Console at airpixels.com/api/console and enter your account email. You get one email with a sign-in link and a 6-digit code; open the link or type the code. There is no password, and the link and code last 15 minutes and work for one sign-in.

Create the key

Go to Keys and create a key. A new key is shown once, so copy it before you leave the page. An account can hold up to 5 active keys.

Name keys per environment or application, so a leak can be traced and a single key retired without touching the rest.

Send the key with every request

Every request carries your key in the Authorization header.

curl https://api.airpixels.com/v1/usage \
  -H "Authorization: Bearer $AP_KEY"

x-api-key: ap_live_... works too, but prefer Authorization: Bearer: it is the header MCP clients send.

A request with no key, or with a key that cannot be used, comes back with the same error shape.

{
  "error": {
    "code": "missing_key",
    "message": "No API key was sent. Send Authorization: Bearer ap_live_..."
  }
}

The message text varies with the situation, but code is stable: missing_key, invalid_key or key_revoked. Branch on code, not on the message.

Keep keys safe

  • Call the API from your server. CORS is open, so a browser can call the REST API, but a key in public front-end code is a key anyone can use.
  • Store the key outside your code. Keep it in an environment variable or a secrets store, out of source control.

Never commit a key to source control or ship it in a browser or mobile bundle. If a key leaks, rotate it immediately: a leaked key can read data and manage the account until it is revoked.

Rotate a key

POST /v1/keys/rotate returns a new key and revokes the key that made the call, immediately. Rotation is free and takes no request body.

curl -X POST https://api.airpixels.com/v1/keys/rotate \
  -H "Authorization: Bearer $AP_KEY"
{
  "data": {
    "api_key": "ap_live_7Kd2mQ9rT4xL8bNc1Vz6Yw3Ph5Jg0SaB",
    "key_prefix": "ap_live_7Kd2",
    "created_at": "2026-11-06T19:37:16.410Z",
    "revoked_key_prefix": "ap_live_3Rf8"
  },
  "meta": {
    "plan": "builder",
    "calls_used": 10,
    "calls_included": 25000,
    "attribution": "Data: Air Pixels (airpixels.com)"
  }
}

api_key is the new plaintext key and is shown once, so store it before the response leaves your logs. To overlap during a deploy, deploy the new key to your environment variables first, then confirm traffic is using it. Any process still holding the old key gets 401 key_revoked.

Lost a key? Switch it off and create a new one in the Data Console, or email support@airpixels.com from your account email. Support revokes it and issues a new one.

Keys and MCP

The same ap_live_ key authenticates the hosted MCP server, sent as the same Authorization: Bearer header. See MCP server for connection details. A missing or bad key over MCP comes back as a JSON-RPC error rather than the REST error body.

Troubleshooting

StatusError codeWhat to check
401missing_keyNo key sent. Send Authorization: Bearer ap_live_....
401invalid_keyKey malformed or not recognised. Check for copy errors, a truncated key, or a missing ap_live_ prefix. Email support if it is lost.
401key_revokedKey was revoked or rotated. Use your newest key.
403not_in_planThe key is valid but the dataset or feature is not in your plan. error.plan names your plan. Upgrade, or call only what your plan includes.

The complete error list, including the non-authentication codes, is on Plans and limits.

Next