Authentication
Two kinds of key, two environments
Every request to a key-protected endpoint sends Authorization: Bearer <key>.
| Prefix | Where it lives | Environment | What it can do |
|---|---|---|---|
pk_test_ |
your website (browser) | sandbox (made-up data) | public reads; consumer features with a client token; CORS from your domains and localhost |
pk_live_ |
your website (browser) | live | same, from your authorized domains only |
sk_test_ |
your server only | sandbox | everything in the account, including minting client tokens |
sk_live_ |
your server only | live | everything in the account |
The environment comes from the key, never from the URL. Going live means swapping the key.
You make and revoke keys in the portal: test keys from the moment
you sign up, live keys once your account is approved to go live. A
key is shown once, when it is made, and is stored only as a salted hash, so nobody can show it
to you again. If you lose a key, revoke it and make another. A key can be revoked at any
time; the next request with it gets 401 key_revoked.
Never put a secret key in a browser
A request that carries an sk_ key together with a browser Origin header, or any
Sec-Fetch-Site header (browsers add it to every request they make), is refused with
403 secret_key_in_browser, and the key is flagged as possibly exposed. GET /v1/account (with
an sk_ key) lists flagged keys so you can rotate them, the portal's keys page shows the
warning, and the account's Owners get one email about each flagged key. The key keeps working
from your server until you revoke it. Use the pk_ key plus a client token in
the browser instead. A server that proxies browser requests must not forward the browser's
Origin and Sec-Fetch-* headers, or it looks like the browser. Calls from Node's own fetch
and other server clients are unaffected.
Acting for one consumer: client tokens
Favorites (and later saved searches, shapes and alerts) belong to one consumer of your site. The API never trusts a consumer identity sent from the browser. Instead:
- Your server authenticates the consumer however it likes and chooses an opaque client ID
for them: 1–64 characters of
A-Z a-z 0-9 _ -. Never an email address (anything with@) or a phone number (10 to 15 digits once dashes and underscores are removed); those are refused with400 client_id_must_be_opaque. A UUID is fine. The same ID under two accounts is two different people. - Your server calls
POST /v1/client-tokenswith itssk_key and thatclientId, and gets a short-lived JWT (default 15 minutes, at most 60). - The browser sends
Authorization: Bearer pk_…plusX-Client-Token: <jwt>. - The API checks the token's signature, expiry, environment and that it was minted by the same
account as the
pk_key. A token from another account is401 client_token_account_mismatch.
Your server can also act for a consumer directly: sk_ key plus X-Client-Id: <clientId>.
A clientId in a query string or body is ignored for authorization. A pk_ request to a
consumer endpoint without a token gets 401 client_token_required.
Browsers and domains
pk_ keys work from the account's authorized domains, matched exactly on scheme, host and
port (https://example.com does not cover http://example.com, www.example.com or
https://example.com:8443). pk_test_ keys also work from localhost on any port. A request
from any other origin is 403 origin_not_allowed with no CORS headers.
The browser's OPTIONS preflight carries no key, so it gets the same permissive answer for every
site and reveals nothing; the domain list is enforced on the real request.
Domain locking stops other websites from embedding your key; it is not anti-scraping, because a
non-browser client can forge Origin. Rate limits apply regardless.
Account status
| Status | Effect |
|---|---|
pending |
a live account awaiting approval to go live (a sandbox account is active from the start, so test keys work); a live key gets 403 account_pending everywhere except GET /v1/account with the sk_ key, so your server can see the status |
active |
normal |
suspended |
data writes and listing data get 403 account_suspended; GET /v1/account, reading and deleting consumer data, and minting tokens keep working so you can export or delete |
closed |
every key is revoked at once; the account is deleted within 30 days |