Skip to main content

Authentication

TPC resolves callers in a fixed order: API key, bearer token, then session cookie. If you send more than one credential, x-api-key wins.

Choose your credential

Session cookies are for The Prompting Company dashboard. The browser sends the better-auth.session_token cookie automatically.
Use session cookies only for first-party browser flows.

OAuth bearer

The CLI authenticates with browser-based device flow:
After login, the CLI stores a local token and sends it as a bearer credential:
Bearer callers must include the scopes required by the route.

API key

API keys are the recommended credential for integrations. Create an organization API key from:
Then send it with x-api-key:

Precedence

resolveCaller checks credentials in this order:
  1. x-api-key
  2. Authorization: Bearer <token>
  3. Session cookie
That precedence makes server integrations deterministic. If a background job accidentally includes a browser cookie, the API key still identifies the integration.

Rotation and revocation

Rotate API keys when a teammate leaves, a secret may have leaked, or an integration boundary changes.
  1. Create a new key with the same or narrower scopes.
  2. Deploy the new secret to your integration.
  3. Confirm requests are succeeding with the new key.
  4. Revoke the old key from the API key settings page.
Revoked keys fail with: