Everything the dashboard does goes through the Management API
(/v1/manage/…, see MANAGEMENT-API.md). Until now only a
person signed in to the dashboard could call it. This page is about the other
way in: a workspace API key, for scripts, CI, Terraform-style tools and the
command line.
Covered by apps/auth-broker/tests/api-keys.test.ts, openapi.test.ts and
packages/cli/tests/cli.test.ts.
Workspace API keys
A key looks like pak_… (36 random characters after the prefix). It belongs to
one workspace and opens that workspace and nothing else.
| Roles | admin (read and write, the default) or read (look, never change) |
| Expiry | Optional, 1 to 730 days. Without it the key lives until revoked |
| Limit | 25 active keys per workspace |
| Who can make, list and revoke them | A person who is an owner or admin of the workspace. Never another key |
| Shown | Once, when made. Passkin keeps only a SHA-256 hash and a 12-character prefix to recognise it in a list |
| Rate limit | 600 requests per minute per key |
In the dashboard: API keys in the sidebar, for an owner or admin of the workspace. Or through the API:
# Make one (as a signed-in owner or admin; the key is in the response, once)
curl -X POST https://auth.passk.in/v1/manage/workspaces/$WORKSPACE/api-keys \
-H "Authorization: Bearer $DASHBOARD_TOKEN" -H "Content-Type: application/json" \
-d '{"name":"ci","role":"read","expires_in_days":90}'
# Use it
curl https://auth.passk.in/v1/manage/me -H "Authorization: Bearer pak_…"
Routes: GET /v1/manage/workspaces/:id/api-keys, POST …/api-keys,
DELETE …/api-keys/:keyId (revokes at once).
What a key can and cannot do
- It manages its own workspace's projects, applications, users, sign-in
methods, webhooks, organizations, SSO connections, directories, audit log and
the rest, exactly as an admin of that workspace would. A
readkey can look at all of it and change none of it. - It cannot create workspaces, cannot make or revoke API keys, cannot use the operator routes, and gets "not found" for any other workspace.
- Its writes are in the audit log attributed to the key (
actor_type: "api_key", with the key's name), so you can tell what a program did. - It stops working the moment it is revoked or expires, and when the person who made it leaves Passkin (a key is never an orphan with powers).
- Its use is recorded (
last_used_at, at most once a minute) so a key nobody uses can be found and removed.
A workspace key is powerful: it can read every user of every project in the
workspace. Treat it like the secret keys (sk_…): environment variable or
secret store, never source control. Prefer a read key where reading is all a
tool needs, and an expiry for anything temporary.
The OpenAPI document
GET /openapi.json returns an OpenAPI 3.1 description of the Backend API
(secret key), the Management API (dashboard session or workspace API key) and
the end-user /v1/me API. No key is needed to read it; it is cacheable and
served with CORS *. Management operations that exist for a single project are
described both under /v1/… for the Backend API and under
/v1/manage/projects/{projectId}/… for the Management API.
Use it to generate a client in any language, to import into Postman or Insomnia, or to feed an agent. Two tests keep it honest: one checks that every route the broker answers is described (and every described route exists), the other validates the document against the OpenAPI specification.
passkin openapi --out passkin.openapi.json
The passkin command line
packages/cli (package @passkin/cli, the passkin binary). Node 20 or newer.
The packages are not published to npm yet, so npx @passkin/cli … works only
once they are; until then build it in the repository (pnpm --filter @passkin/cli build) and run node packages/cli/dist/cli.js …. The examples below write
passkin for either.
passkin login --key pak_… # saved in ~/.config/passkin/config.json (readable by you only)
passkin whoami # which workspace, and whether the key can write
passkin projects # list
passkin projects create "Shop" --redirect https://shop.example.com/api/auth/callback
The key can also be given for one command with --key, or from the
environment as PASSKIN_API_KEY (best for CI). --url or PASSKIN_URL points
at another Passkin (default https://auth.passk.in). --json prints
machine-readable output.
passkin init
In a Next.js (App Router) project:
passkin init
It asks Passkin for a project (named after your package, or the one in
.passkin.json / --project), registers http://localhost:3000/api/auth/callback
as a redirect address (--port to change it), and then writes:
| File | What it is |
|---|---|
lib/passkin.ts |
createPasskin(…) configured from the environment |
app/api/auth/[...passkin]/route.ts |
export const { GET, POST, PATCH, DELETE } = handlers; |
middleware.ts |
passkinMiddleware |
.env.local |
PASSKIN_PUBLISHABLE_KEY, PASSKIN_SECRET_KEY, PASSKIN_COOKIE_SECRET (random), PASSKIN_URL |
.passkin.json |
which project this folder is (no secrets) |
then installs @passkin/nextjs with the package manager your lockfile shows
(pnpm, yarn, bun, otherwise npm), and prints the one snippet left for you:
wrapping your layout in <PasskinProvider>.
It is safe to run twice: files that exist are kept, never overwritten
(--force replaces them), an existing .env.local keeps its values and gains
only the missing ones, and the same project is reused instead of making a
second. With src/ it writes into src/. --no-install skips the install.
It refuses, with an explanation, on anything that is not an App Router Next.js
app, and on a read key (it needs to make a project).
passkin users export / import
passkin users export --project prj_… --format csv --out users.csv
passkin users import auth0-export.ndjson --project prj_… --source auth0
passkin users import users.csv --project prj_…
The same importers and exporter as MIGRATION.md (Auth0,
Clerk, Supabase, Firebase, Cognito, CSV, Passkin's own shape) with the same
rules: old password hashes are used once to prove a mailbox and never kept, and
exports never contain hashes. .passkin.json remembers the project, so
--project is only needed the first time. import exits with 2 if any record
failed (and lists them), so a pipeline can notice.
passkin config: a project as a file you keep in Git
passkin config pull --project prj_… # writes passkin.config.json: what the project is, with no secret in it
passkin config diff # what applying the file would change (add --exit-code to fail a CI job on drift: exit 3)
passkin config apply --dry-run # the same plan, from apply
passkin config apply # make the project match the file
passkin config apply --prune # …and remove what the file no longer lists
The file has project (name, sign-in methods, lifetimes, retention…), access, organizations, api_keys, shield, branding (with the support address replies go to), email (sender name, one-click link, password sign-up: EMAIL.md), claims, and the lists applications, permissions, roles, webhooks,
and oauth (settings, resources, clients). It is partial on purpose: a section that is absent is left alone, and an item missing from a list is left alone too unless you pass --prune. Things are matched by what
names them — applications and OAuth clients by name, webhooks by URL, hooks by event, the vault's switch and scopes (connections), roles and permissions by key, resources by identifier — so a rename is a new item (and, with --prune, the old one's removal).
- Checked first. A typo (an unknown section or field, a duplicate name, the wrong shape) is an error before anything is asked of Passkin; a change that cannot be made (an application's type) is marked
xand nothing is applied. - Secrets are never in the file. The signing secret of a webhook, or the secret of a client, that apply creates is printed once at the end.
- Idempotent. Values are compared as the server keeps them (address lists lower-cased without a leading
@, country codes upper-cased, lists as sets): a secondapplysays "No changes". - Safe on failure. Changes are made in a fixed order (settings, permissions, roles, applications, webhooks, OAuth); the first one Passkin refuses stops the run with what was already done, and running it again carries on.
- Never removes the project's main website, and deletes nothing without
--prune. Areadkey candiffbut notapply. Every change is an ordinary Management API call, audited as the key's.
passkin mcp: manage a workspace from an AI assistant
{ "mcpServers": { "passkin": { "command": "passkin", "args": ["mcp"], "env": { "PASSKIN_API_KEY": "pak_…" } } } }
An MCP server on standard input and output (JSON-RPC, no dependencies) for Claude Desktop, Cursor, Claude Code and any client that speaks the Model Context Protocol. It uses the same workspace API key, and is narrower than the key on purpose:
- Reading:
whoami,list_projects,get_project,list_users,get_user,list_organizations,list_audit_log,list_webhooks,shield_summary,list_oauth_resources. - Careful changes:
create_project,set_sign_in_methods,invite_users,ban_user/unban_user,create_organization,set_shield_mode. - No deletion of anything, no key or secret rotation, and no secret is ever returned (a new project's secret key is withheld; rotate one in the dashboard).
- With a
readkey, orpasskin mcp --read-only, only the reading tools exist. - What it returns about people is data, and the server tells the assistant so; every call is an ordinary Management API call, so the audit log shows it was made by the key.
The documentation is also for assistants: /llms.txt (an index) and /llms-full.txt (all of it as one file) on the docs site, and the API as OpenAPI at /openapi.json.
Exit codes
0 success · 1 the command could not be done (message on stderr) · 2
finished but some records failed.
What this is not (yet)
- No keys for a single project or an organization, and no
client_credentialsgrant for machine-to-machine access to your own API (both are on the roadmap). - No Terraform provider yet (the OpenAPI document is its starting point);
passkin configis the file-based way until then. passkin initknows Next.js only. Other frameworks are in the roadmap; until then use INTEGRATION.md.passkin listen --forward-to <url>forwards a project's events to your local server, signed like a real webhook (see WEBHOOKS.md); it has no retries and no way to fire an arbitrary event yet.- The MCP server is stdio only (a hosted, OAuth-protected one for Passkin itself is not built).