API tokens#
bash
curl -H "Authorization: Bearer prn_pat_xxxxxxxxxxxxxxxxxxxx" \
https://principal.example.com/api/v2/identities| Personal | Organization | |
|---|---|---|
Prefix |
prn_pat_ |
prn_oat_ |
Acts as |
Owner |
Organization |
Issued by |
Any member (for self) |
Member with tokens:manage |
Built-in roles |
admin, viewer, user (up to issuer) |
admin, viewer |
Expiry / limit |
1h–366d, 25 active per member |
1h–366d, 100 per org |
Secrets show once on issue or rotation and store as SHA-256 hashes.
Roles and API tokens#
A token freezes its built-in role and optional custom_role_id at issuance. On each request it gets only the permissions of its roles that its bound member still holds (effective_permissions). Issuing or rotating requires every permission of its roles. Organization tokens require at least one permission (viewer, admin, or custom role).
What tokens cannot do#
Tokens serve automation and MCP. Refusals return 403 auth.api_token_not_allowed with details.reason unless noted.
| Area | Requirement and details.reason |
|---|---|
Console-only |
/auth/* and /events (api_token_not_allowed). Sync approval returns 403 authorization.denied. |
Token management ( /api-tokens/*) |
allow_token_management (api_token_management_not_allowed). Child tokens inherit issuer limits and revoke with it. Personal routes need a personal token (api_token_personal_only). Revoking a rotated token returns 409 (secret_replaced) unless revoke_replacement=true. Take over keeps the issuer chain. |
Installation admin |
/admin/health, /admin/maintenance, /admin/audit/events, /admin/upgrade/preflight, /admin/activity/operations, /admin/sign-in-page, /admin/sign-in-methods need allow_installation_admin (personal token of installation admin, max 30 days, api_token_installation_admin_not_allowed). |
Security changes |
Second-factor actions (org policy, MFA, trusted networks, passwords, sign-in bindings, connectors, granting security:manage or all permissions, external-ID linking via /identities/ensure, /policies/ensure, /grants) need allow_security_changes + security:manage (api_token_security_changes_not_allowed). External-ID ensure also requires org admin and all target-user org permissions: use identity IDs instead. |
Credential reads |
Revealing credentials or agent SSH certificates ( POST /ssh/certificates) needs allow_credentials_read (api_token_credentials_read_not_allowed). |
Create org |
Personal tokens only ( api_token_personal_only). Token stays in its original org. |
Token errors#
| Response | Cause |
|---|---|
401 auth.api_token_invalid (invalid) |
Bad format, checksum, or unknown prn_ token. |
401 auth.legacy_auth_disabled |
Bearer lacks prn_ prefix. |
401 auth.api_token_invalid (expired) |
Token expired. |
401 auth.api_token_invalid (revoked) |
Revoked or rotated. |
401 auth.api_token_invalid (inactive) |
Bound member left org or lost access. |
401 auth.api_token_invalid (unused) |
Disabled for inactivity. Issue a new token. |
401 auth.api_token_invalid (network) |
Client IP outside allowed networks. |
403 auth.api_token_not_allowed |
Console-only route or missing right ( details.reason). |
403 authorization.denied |
Missing role or permission. |
403 tenant.org_access_denied |
X-Organization-ID names another org. |
Browser sessions#
bash
curl -X POST https://principal.example.com/api/v2/policies/$POLICY/apply \
-b cookies.txt -H "X-CSRF-Token: $CSRF_TOKEN"| Rule | Detail |
|---|---|
Cookies |
__Host-principal_session (principal_session on HTTP dev), principal_csrf. |
CSRF |
X-CSRF-Token matching principal_csrf on POST/PUT/PATCH/DELETE, GET with refresh=true, and GET /identities/{id}/credentials (else 403 auth.csrf_required or auth.csrf_invalid). Not for API tokens. |
Session info |
|
Org header |
Tokens are org-bound (other orgs return 404). Sessions accept X-Organization-ID: <uuid>. |
Internal auth |
Kubernetes TokenReview client and Dex connector Basic auth (system routes). Full matrix: Permissions. |