Passkin

API keys for your users

Status: built (2026-10-05). Tests: apps/auth-broker/tests/project-api-keys.test.ts, packages/server/tests/api-keys.test.ts, packages/react/tests/components.test.tsx.

Your customers sometimes need a program to call your API as them: a script, a CI job, an integration. This is the product Clerk sells as "API keys". A person — or an organization they administer — makes keys in your product; your server asks Passkin whether a key is good and who owns it. (Not to be confused with workspace API keys, which let you call Passkin's Management API: PLATFORM-API.md; or with OAuth, where a program asks a person for access and gets a token: OAUTH.md. Keys are simpler: long-lived, made by the owner, revocable.)

Off until you turn it on: dashboard → OAuth & MCP → API keys for your users, or PATCH /v1/manage/projects/:pid with api_keys:

{ "api_keys": { "user_keys": true, "organization_keys": true, "allowed_scopes": ["read:orders", "write:orders"], "max_per_owner": 10, "max_expiry_days": 365 } }

What a key is

ak_live_… (production projects) or ak_test_…: 36 random characters, shown once, when it is made; Passkin stores only a SHA-256 hash and a 16-character prefix to recognise it in a list. A key has an owner (a user or an organization), a name ("what will use it"), scopes (only ones you listed in allowed_scopes; with none listed, keys carry no scopes), and an optional expiry (mandatory, and bounded, if you set max_expiry_days). One owner may hold max_per_owner active keys (default 10).

Your customers make them

  • People: <ApiKeys /> from @passkin/react (English, Arabic, Spanish and French), or GET/POST /v1/me/api-keys, DELETE /v1/me/api-keys/:id with the person's access token (ACCOUNT.md).
  • Organizations: the same with organization=<id or slug>: <ApiKeys organizationId="org_…" />. Requires the organization permission org:api_keys:manage (admins have it; members do not and learn nothing: an organization they are not in reads as not found). A person's own list never shows an organization's keys.
  • You, for someone: POST /v1/api-keys with { "owner": { "type": "user", "id": "user_…" }, "name": "…", "scopes": […] } (secret key); list with GET /v1/api-keys?owner_type=&owner_id=; revoke with POST /v1/api-keys/:id/revoke. The dashboard shows and revokes every key.

Your server checks them

import { createPasskinServer } from "@passkin/server"; // PASSKIN_SECRET_KEY must be set: it is your server asking
const passkin = createPasskinServer();

export async function GET(request: Request) {
  const check = await passkin.verifyApiKey(request, { scopes: ["read:orders"] });
  if (!check.ok) return check.response;                       // 401, 403 or 503, already shaped
  const { owner } = check.key;                                // { type: "user", id, email } or { type: "organization", id, slug, name }
  return Response.json(await ordersOf(owner));
}

The key may arrive as Authorization: Bearer ak_… or X-API-Key: ak_…. Without the SDK: POST /v1/api-keys/verify with Authorization: Bearer sk_… and { "key": "ak_…" } → { "valid": true, "id", "name", "owner", "scopes", "expires_at", "created_by" } or { "valid": false } (always 200 for an unknown key, so it is not an oracle). The SDK remembers answers for 30 seconds (cacheSeconds: 0 asks every time): a key revoked a moment ago may pass for that long. If Passkin cannot answer, the SDK returns 503 — nobody's key is refused for our outage.

Rate limits

You decide how fast a key may be used — never the person who made it. A default for every key (dashboard: OAuth & MCP → API keys for your users → Rate limit per key, or api_keys.rate_limit on the project):

{ "api_keys": { "rate_limit": { "requests": 1000, "per": "minute" } } }      // per: minute, hour or day; null: no limit

and, for one key, its own — set by your server with the secret key, higher or lower than the default, and cleared with null:

POST  /v1/api-keys              { "owner": {…}, "name": "partner", "rate_limit": { "requests": 60, "per": "hour" } }
PATCH /v1/api-keys/:id          { "rate_limit": { "requests": 10000, "per": "day" } }          // or null: the default applies again

A person making a key who sends rate_limit is refused ("set by the product"); they see the limit their key is held to (effective_rate_limit, and in <ApiKeys />). The key list shows both: rate_limit (its own) and effective_rate_limit.

How it is counted. Each verification of a key that has a limit counts as one request in a fixed window (the clock's minute, hour or day — every instance agrees on where it ends). The answer says where the key stands:

{ "valid": true, "…": "…", "rate_limit": { "limit": 1000, "remaining": 412, "reset_at": "2026-10-05T12:01:00.000Z", "reset_in": 23, "exceeded": false } }

verifyApiKey turns that into the standard answer: over the limit it returns 429 with Retry-After and RateLimit-Limit, RateLimit-Remaining, RateLimit-Reset; within it, check.headers holds the same RateLimit-* headers to put on your own response, and check.key.rateLimit the numbers. A key with a limit is never remembered by the SDK's 30-second cache — every request asks Passkin, because asking is how it is counted; a key without one is remembered as before. Counting is for the keys you limit, so the cost of asking is only paid where you wanted a limit. A key that is not good counts for nothing.

Not counted: calls that never reach Passkin. A request your server refuses before verifying (no key, a malformed one) is not a request of any key. Changes to a key's limit are in the audit log (api_key.updated).

Usage

Every verification of a good key is counted for the day (UTC), and the ones over its rate limit are counted apart — a number, nothing more: no address, no path, no content. It is shown where the key is: verifications_30d on every key in GET /v1/api-keys (Backend API), in the dashboard's key list, and to the person in their own list (GET /v1/me/api-keys, and the key components: "1,204 uses in the last 30 days", in the four languages).

GET /v1/api-keys/:kid/usage?days=30      →  { key_id, days, total, rate_limited, data: [{ day: "2026-10-05", verifications, rate_limited }, …] }

One row for each of the last days days (1–90, default 30), zeros included, oldest first, so a chart needs no filling in. Counts older than 90 days are deleted by the scheduled maintenance, and a key's go with it. Tests: apps/auth-broker/tests/project-api-keys.test.ts.

What is counted is verifications — questions put to Passkin, not requests to your API: an SDK that remembers a good answer for a few seconds asks once for all the requests in them, and a key held to a rate limit is never remembered, so its count is exact. Counting is one write per verification (an upsert on (key, day)); at high volume it should be buffered, which is not built.

When a key stops

At once: it is revoked (by its owner, an organization admin or you), it expires, its person is banned or deleted, or its organization is deleted (verification checks the owner each time). A key belongs to its organization, not to the member who made it: that member leaving does not end it; the admins' revoking does. Keys revoked or expired for three months, and keys of owners that no longer exist, are removed by the scheduled maintenance.

Making and revoking a key are in the audit log (api_key.created, api_key.revoked) and are webhook events — never the key.

Not built yet

Usage broken down by endpoint, by hour or by caller, buffered counting for high volume; IP allow-lists per key; a sliding window or burst allowance for the limit (it is a fixed window); a limit per owner rather than per key; key rotation with an overlap window; a hosted "API keys" page (the component is the UI); machine-to-machine access for a customer's service account (use OAuth machine clients for your own services); Vue and Svelte versions of the component.

Ready to try it?

Create a project — the dashboard fills these snippets in with your own keys.

Open the dashboard