Authentication
One header, on every request to a keyed route:
Authorization: Bearer sk_live_8Kx2Qm1F_…Exactly Bearer and one space. The key is read from this header and from nowhere else: akey= or access_token= in the query string is ignored, including on thecompatibility routes that accept those parameters so an existing client does not break. A key in a URL ends up in logs, proxies and browser history; one in a header does not.
/v1/health, /v1/migrate and /v1/openapi.json need no key. Everything else does.
What a key looks like
sk_live_8Kx2Qm1F_x9Tq4LmZr2Vb7NcW1sYh3KpA6DgE0JuF
└──┬──┘ └──┬───┘ └──────────────┬───────────────┘
env prefix secret (32)sk_live_ or sk_test_, an eight-character prefix, and a 32-character secret drawn from a CSPRNG over 62 letters and digits — about 190 bits. The prefix is stored in the clear so you can tell keys apart in the console, in a log line or in a support conversation. The secret is not stored at all: only a SHA-256 of the whole key is, which is why it is shown once, when it is minted, and there is no route that could return it again — not to you, and not to us.
Not argon2 or bcrypt, deliberately. A slow hash defends a low-entropy password against guessing; 190 random bits cannot be guessed at any hash speed, and a millisecond of hashing on a path budgeted in microseconds would only let anyone spend our CPU by sending nonsense keys.
live and test
The prefix is a label for your own bookkeeping. A test key carries the plan it was minted on, at the same rates, against the same data, and is billed the same way — it is how you tell your CI's key from production's in a list, not a sandbox with different answers.
A key is its plan, and nothing narrower
A key grants every product its plan includes. There are no per-key scopes, no IP allowlists and no referrer restrictions. Two consequences:
- Never put a key in a browser or a mobile app. Anyone who opens developer tools has it, and nothing about the key limits where it can be used from. Call the API from your backend and let your own frontend talk to that. The service sends CORS headers only to the handful of origins its operator lists (its own site, for the demo), so a browser on any other origin is refused before it reads an answer, and that is not a gap to close: the address form example shows the proxy.
- Separate keys are for separating blast radius, not permissions: one per service or environment, so revoking one does not take down the others.
Revoking takes about a second
Revoking in the console writes the database and notifies the serving fleet, and every pod also polls for revocations once a second, so correctness does not depend on the notification arriving. From then on the key is refused with 401, the same as a key that never existed — as is a key whose account is suspended, or whose subscription has lapsed.
Rotating without downtime
The console's Rotate mints a new key with the same name and plan and revokes the old one in the same transaction. There is no overlap window: anything still sending the old key is refused within about a second. That is the right button when a key has leaked. For a planned rotation, overlap them yourself:
- Mint a second key on the same plan.
- Deploy it everywhere the old one is used.
- Confirm nothing still sends the old key — search configuration and deploy logs for its prefix.
- Revoke the old key.
A running batch job is paced by the key that submitted it, and fails withthe key running this job was revoked if that key goes. Rotate after a large job finishes, not during it.
401, 403 and 503 are three different conversations
| Status | Meaning | What to do |
|---|---|---|
401 | No key, or one this service does not know: never issued, revoked, or its account suspended. | Check the header. Mint a new key if it was revoked. |
403 | A good key whose plan does not include the product this route belongs to, or a request larger than the plan allows. | The body names the plan that does include it. An upgrade, not a bug. See products. |
503 | The pod has not been able to reach its control plane for fifteen minutes, and will not invent an entitlement. | Retry. It is ours to fix and says nothing about your key. |
What a missing key gets:
curl -G "https://api.oslew.com/v1/geocode" \
--data-urlencode 'q=Museo Soumaya'from oslew import Client
# The key is read from GEO_API_KEY.
client = Client(base_url="https://api.oslew.com")
answer = client.geocode("Museo Soumaya")import { Client } from "@oslew/client";
// The key is read from GEO_API_KEY.
const client = new Client({ baseUrl: "https://api.oslew.com" });
const answer = await client.geocode("Museo Soumaya");HTTP/1.1 401 Unauthorized
content-type: application/json
{
"error": "an API key is required: Authorization: Bearer sk_live_…"
}A real response, captured from the service at commit b8f4bde-dirty. Timing fields such as took_us differ on every call.