Personal access tokens

How a user's own agent (Claude Code over MCP, a script) calls the API as that user, without a browser session.


What a token is

A personal access token is an opaque bearer credential (ppat_…) a signed-in user creates for themselves. It resolves to that same user, in the organization it was created in, while they are still a member of it. Permissions are not stored on the token: on every request the deployment host binds them from the deployment access policy and the user's verified identity, exactly as for a browser session. A token therefore does exactly what its owner may do now, and a role removed from the owner is gone from the token at once.

A token never impersonates (the backend ignores the impersonation headers for it and the middleware refuses them with 403) and cannot list, create or revoke tokens. Every write it makes is recorded under the owner's name, like any other write.

SendAuthorization: Bearer ppat_…; X-Process-Platform-Organization is optional and must match
LifetimeChosen at creation, 1 to 365 days (default 90)
StoredSHA-256 hash, name, owner, organization, created, last used, expiry; never the secret
RevokeDELETE /api/access-tokens/{id} from the owner's browser session; immediate

Tokens are kept per deployment owner: Mongo collections access-tokens-v1-…, oauth-clients-v1-… and oauth-codes-v1-… under the Mongo driver, one JSON file in the data directory under the file driver, memory under the memory driver.


Scope

A token's access is chosen when it is made (scope on POST /api/access-tokens) and cannot change:

scopeWhat it may do
full (default, and every older token)Everything its owner may do, in every application.
stepsOnly in the application it was made from (the frontend proxy's stamp), with the owner's permissions narrowed to an allowlist: read items, save and complete steps, notes and follow-ups. Never starts, shares, abandons, reopens or deletes.
readBound the same way; its allowlist may name only processes:read, processes:read_all, processes:audit and templates:read (anything else is refused at creation, 400 invalid_scope). Every write is refused (403 token-scope), including any write added later: the deployment host lets such a token through only a fixed list of reads.

GET /api/me reports a scoped token's accessTokenScope. Using a token from a script: drive runs over the JSON API.


Signing in an MCP client

An MCP client signs in with OAuth 2.1 instead of a pasted token. The frontend hosting the MCP server is the authorization server: it publishes RFC 9728 protected-resource and RFC 8414 authorization-server metadata, accepts RFC 7591 dynamic registration of public clients, shows a consent page that requires the user's normal app sign-in, and exchanges a single-use code (with a PKCE S256 verifier) for an access token that is one of the user's personal access tokens (1 hour) and a refresh token (30 days) that rotates on every use. Replaying a used refresh token revokes the grant. Clients, codes and grants live in the backend (/api/oauth/*), hashed; the connection appears in the user's token list under the client's name.

The Auth0 tenant is not involved: users sign in to the app as usual, and the app issues the client's token. Spell review is the first frontend to host this; see applications/spell-review/docs/mcp.md.


Known gaps

  • A full token is not narrowed to one application: it reaches whatever its owner's browser session reaches through the API. Its application is recorded for display only.
  • lastUsedAt is written at most once a minute per token.
  • Client registration is rate-limited per address by the frontend and per deployment by the backend, in memory; registrations are not yet garbage-collected.