1. guides
prorm
  • prorm documentation
  • Known test gaps
  • Architecture
  • Core concepts
  • Database types & coverage
  • Getting started
  • Going further
  • compliance
    • Compliance
    • The security toolkit: `prorm audit`
    • Checklists by regulation
    • Declaring personal data
    • Evidence bundles
    • Evidence
    • Frameworks: `@Security`
    • Jurisdictions
    • Platform policies
    • Protecting data
    • The regulation dataset
    • Residency and cross-border transfers
    • Retention & integrity
    • Status
    • Subject rights
  • decorators
    • prorm with decorators
    • Models with decorators
    • Querying a decorated model
    • Relations with decorators
  • diagrams
    • Diagram generators
    • Chen diagram
    • Class diagram
    • Dependency diagram
    • ER diagram
    • Flow diagram
    • From your models to a diagram
    • Gantt diagram
    • Index diagram
    • Migration diagram
    • Model diagram
    • Package diagram
    • Crow’s-foot diagram
    • Schema documentation
    • Sequence diagram
    • State diagram
    • Tree diagram
  • dialects
    • SQL dialects
    • AlloyDB Dialect
    • AlloyDB Omni Dialect
    • Amazon Athena Dialect
    • Aurora DSQL Dialect
    • Amazon Aurora MySQL Dialect
    • Amazon Aurora PostgreSQL Dialect
    • Azure Database for MySQL Dialect
    • Azure Database for PostgreSQL Dialect
    • Azure SQL Database Dialect
    • Azure SQL Managed Instance Dialect
    • Google BigQuery Dialect
    • Citus Dialect
    • ClickHouse dialect
    • Cloud Authentication (`cloud-auth`)
    • Cloud SQL for SQL Server Dialect
    • Cloud SQL for MySQL Dialect
    • Cloud SQL for PostgreSQL Dialect
    • CockroachDB Dialect
    • Azure Cosmos DB for PostgreSQL Dialect
    • CrateDB Dialect
    • Cloudflare D1 Dialect
    • Databricks dialect
    • IBM Db2 Dialect
    • Dolt Dialect
    • Apache Doris Dialect
    • Druid Dialect
    • DuckDB Dialect
    • Exasol dialect
    • Microsoft Fabric Data Warehouse Dialect
    • Firebird Dialect
    • Greenplum Dialect
    • SAP HANA Dialect
    • MySQL HeatWave Dialect
    • Azure Data Explorer (Kusto) Dialect — T-SQL
    • MariaDB Dialect
    • Materialize Dialect
    • MonetDB Dialect
    • MotherDuck Dialect
    • Microsoft SQL Server Dialect
    • MySQL Dialect
    • Neon Dialect
    • OceanBase Dialect
    • openGauss Dialect
    • Oracle Dialect
    • Oracle Autonomous Database Dialect
    • ParadeDB Dialect
    • PolarDB Dialect
    • PostgreSQL Dialect
    • Presto Dialect
    • QuestDB Dialect
    • Aurora RDS Data API Dialect (`rdsdata`)
    • Amazon RDS for Db2 Dialect
    • Amazon RDS for MariaDB Dialect
    • Amazon RDS for SQL Server Dialect
    • Amazon RDS for MySQL Dialect
    • Amazon RDS for Oracle Dialect
    • Amazon RDS for PostgreSQL Dialect
    • Amazon Redshift
    • Amazon Redshift Data API Dialect
    • RisingWave Dialect
    • rqlite Dialect
    • SingleStore Dialect
    • Snowflake Dialect
    • Google Cloud Spanner Dialect
    • Spanner (PostgreSQL interface) Dialect
    • SQLite Dialect
    • StarRocks Dialect
    • Supabase Dialect
    • Azure Synapse Analytics (dedicated SQL pool)
    • Teradata Dialect
    • TiDB Dialect
    • TimescaleDB Dialect
    • Trino Dialect
    • Turso / libSQL Dialect
    • Vertica dialect
    • Vitess Dialect
    • Yellowbrick Dialect
    • YugabyteDB Dialect
  • guides
    • Access rules and behaviour profiles
    • ArangoDB (AQL)
    • Associations
    • Audit levels and escalation
    • Audit logging
    • In the browser
    • Bulk operations
    • Caching
    • Capabilities, tiers and team roles
    • CLI
    • Cloudflare
    • Compliance & data protection
    • Connection Pooling & Performance
    • Security in the console
    • Couchbase: structured N1QL queries
    • Data types
    • Decorators
    • Eager loading
    • Enums and constants
    • Error handling & error types
    • Extensions
    • External fields
    • Foreign data wrappers
    • Graph databases
    • Hooks & lifecycle events
    • Indexes & constraints
    • InfluxDB: structured Flux pipelines
    • klock-errors
    • klock — the `.klock` file
    • Local databases (`prorm db up`)
    • Structured log search — Splunk, Graylog, Papertrail, Sumo Logic
    • Logging
    • Grafana Loki: structured LogQL queries
    • MCP server
    • Migrate — the data transfer subsystem
    • Migrations & Schema Sync
    • Models from an existing database
    • Defining models
    • Multiple databases
    • OrientDB, Neptune and TigerGraph
    • Passwords
    • Importing a Prisma schema
    • Structured PromQL and MetricsQL
    • Query firewall
    • QueryInterface
    • Query operators reference
    • Query optimization
    • Composing find options with `pipe()` and `Q`
    • Query safety: the fail-closed WHERE guard
    • Querying
    • Raw Queries & Query Building
    • Read replicas
    • Schema diffing & migration generation
    • Views, triggers & other schema objects
    • Scopes & default scopes
    • Seeders
    • SPARQL / RDF triplestores
    • SQL constants
    • SQL features
    • SQL function builders
    • SQLite advanced features
    • StoreKey — a prod-orm database as the storage
    • Streaming results
    • Terraform
    • Transactions & Isolation Levels
    • Type mapping: legacy and modern
    • TypeScript types
    • Database users, roles & privileges
    • Validation & constraints
    • Virtual & Computed Fields
    • Writing docs
  • javascript
    • prorm in JavaScript
    • Models in JavaScript
    • Querying in JavaScript
    • Relations in JavaScript
  • runbooks
    • Operational runbooks
    • Connection failures
    • Credential rotation
    • Failover
    • Incident checklist
    • Deploying klock v2
    • Migration rollback
  • running-databases
    • Running databases in Docker
    • Running prorm under Bun in Docker
    • Running Cassandra in Docker with prorm
    • Running ClickHouse in Docker with prorm
    • Running CockroachDB in Docker with prorm
    • Running prorm under Deno in Docker
    • Running Elasticsearch in Docker with prorm
    • Running MariaDB in Docker with prorm
    • Running MongoDB in Docker with prorm
  • prorm control plane
    • Introduction
    • Authentication
    • Errors
    • Getting started
      • Service
        • Is it up
        • This description
    • Account
      • Sign-up and verification
        • Create an account
        • Exchange credentials for a token
        • Verify with the emailed code
        • Verify by clicking the emailed link
        • Name the parent or guardian
        • What a consent link is about
        • Give consent for a child's account
        • Ask the parent or guardian again
        • Send a new code and link
      • Family
        • Everyone this account is responsible for
        • One child, in detail
        • Turn a limit on or off
      • Profile
        • Who am I
        • Change the account
        • Every address on the account
        • Add an address
        • Confirm an address with the code mailed to it
        • Mail a fresh code to an unconfirmed address
        • Make an address primary
        • Remove an address
        • What this caller may do
    • Security
      • Sessions
        • Everywhere this account is signed in
        • Sign out everywhere else
        • Sign one out
        • A token for the CLI on a named machine
        • A token for the customer console, from the staff one
        • Park a sign-in for the CLI to collect
        • The CLI collecting its sign-in
        • The team's members' live sessions
        • Sign a member's session out
        • Sign an account out everywhere
        • Everywhere the account is signed in
        • Sign an account's session out
      • Single sign-on
        • Begin a single sign-on
        • The provider's return
        • Link the signed-in account to a team's provider
        • Which team an address signs in to
        • The team's single sign-on, as a member sees it
        • Set the team's OpenID Connect provider up, or change it
        • Remove the provider
        • The team's domain claims and the DNS record each needs
        • Prove a claimed domain
      • MFA and passwords
        • Start enrolling a second factor
        • Prove the app has it
        • Remove the second factor
        • Ask for a reset link
        • Set a new password with the emailed token
      • Klock
        • Open a device-bound klock session
        • Check in, for the next grant
        • Step up the session asking
        • Rotate the device key
        • Freeze a session
        • Unfreeze a session
        • A guest grant
        • The revocation feed
        • The published keyset
        • What this control plane supports
      • Devices
        • Your devices, or a team's
        • Approve a new device's pairing code
        • One device
        • Rename a device
        • Revoke a device
        • Suspend a device
        • Reinstate a suspended device
        • Wipe a device
        • Ask a device to rotate its key
        • The team's members' devices
        • Revoke a member's device
        • An account's devices
        • Revoke an account's device
        • Wipe an account's device
        • The device fleet
      • Access rules and behaviour
        • The access rules that bear on you
        • Add an access rule
        • This request, as the rules see it
        • One access rule
        • Remove an access rule
        • The behaviour profiles that bear on you
        • Add or change a behaviour profile
        • The profile presets
        • Your behaviour findings
        • Acknowledge a finding
        • One behaviour profile
        • Remove a behaviour profile
        • The team's access rules
        • Add a team access rule
        • Remove a team access rule
        • The team's behaviour profiles
        • Add or change a team behaviour profile
        • Remove a team behaviour profile
        • What the team's profiles caught
        • Acknowledge a team finding
      • Recovery and lockdown
        • Ask for a recovery link
        • Recover access with the emailed code
        • Is the account locked down
        • Lock the account down
        • Release a lockdown
        • Lock a member down
        • Release a member's lockdown
      • MCP tokens
        • Make a delegated token for one MCP client
        • The account's delegated tokens
        • Revoke a delegated token
        • What a delegated token may do now
        • Run one MCP tool with a delegated token
        • Run a device-signed MCP tool call relayed by the MCP Worker
      • Kerberos
        • Give the team its own Kerberos realm
        • The team's realm
        • Remove the team's realm
    • Logging and monitoring
      • Audit log
        • What has been done to the account
        • What has happened to this account
        • The account's audit trail
      • Operations
        • Everything that has been asked of this database
        • One, with its steps
        • Stop it
        • Put a failed one back in the queue
        • Every operation, across all accounts
      • Metrics and events
        • Every measurement, for a graph
        • Who did what to it
    • Billing
      • Plans and pricing
        • What the plans allow
        • The rate card
        • What one database would cost
        • What this account is paying for, itemised
      • Subscriptions and invoices
        • What this month's invoice will say
        • What this account is on
        • What it has been charged
        • Start a Stripe Checkout session
        • Open the customer portal
        • Stripe's events
        • Buy more connection pools
      • Team billing
        • The team's billing account
        • What the team has been charged
        • What this month's invoice will say
        • The team's cards
        • Add a card, through a Stripe-hosted setup session
        • Make a card the team's default
        • Remove a card
        • Start the team paying
        • Open the Stripe portal on the team's customer
        • Change the team's plan
        • Who receives the team's bills
        • How the team pays for transfers
    • Support
      • Support chat
        • My conversations
        • Start a conversation
        • Every support conversation, open first
        • A ticket for the socket
        • One conversation, with who is in it and who is connected
        • Rename a group; open or close a support conversation
        • The lines, oldest first
        • Say something
        • Add somebody
        • Mark read
    • Administration
      • Users
        • Every account
        • One account, with everything hanging off it
        • Grant or revoke admin
        • Verify an account by hand
        • Lock or unlock sign-in
        • Allow or hold provisioning
        • Send the verification mail again
        • Set the plan by hand
      • Platform
        • Every database and store, across all accounts
        • The counts worth putting on a dashboard
      • Staff and permissions
        • What kind of admin the caller is, and which scopes they hold
        • The admin presets
        • Every admin, and the scopes each resolves to
        • Make an account an admin of a kind
        • Change an admin's kind, or a custom admin's scopes
        • Revoke admin
      • Team administration
        • Every team, with its owner and size
        • One team in full — members with their accounts, and projects
        • Hand the team to another member
        • Put an account in the team, active at once
        • Change a member's role
        • Remove a member
      • Assumed identities
        • Assume an identity — act as a customer account
        • The identities the caller holds open
        • End an assumed identity
      • Support inbox
        • The platform's addresses
        • Add a platform address
        • One address, with its counts
        • Change an address's label, routing, or whether it accepts mail
        • Remove an address that holds no mail
        • Make, adopt or repair the address's routing rule
        • Every admin's personal address, made where missing
        • File a raw message, as if it had arrived
        • The inbox
        • One message, whole
        • Mark a message
        • Hand a message to an admin, or take it back
        • Leave an internal note
        • Reply, from the address the message came to
        • What is waiting
    • Databases
      • Databases
        • Data stores
          • Every data store on the account
          • Provision a data store
          • Change a data store that is already running
          • One data store
          • Deprovision it
          • Report what it is using
          • How to reach a data store
        • Connections and credentials
          • The api keys on a database
          • Issue a key
          • Revoke a key
          • The engine users we created
          • Create a user inside the database
          • Give a user a new password
          • Drop a user
          • How the database is reached
          • Set how it is reached
          • Revoke every api key on it
          • How to connect to it
          • The ssh keys that open its bastion
          • Add a key, or have one made
          • The private half of a generated key, once
          • Revoke an ssh key
        • Schema and objects
          • The SQL objects we put in it
          • Create one, and apply it
          • What is in the database, as the engine reports it
          • One table
          • What it would run, without running it
          • Redefine an object in place
          • Drop it
          • The extensions installed in it
        • Migrations
          • A plan compiled to statements, recording nothing
          • The migrations recorded for it
          • Record one
          • Apply everything recorded and not yet run
          • Apply everything pending, oldest version first
        • Lifecycle
          • Grow or shrink it
          • Stop it accepting connections
          • Start it again
          • Move it to another region
        • Backups and replicas
          • Take a backup
          • The backups it has
          • Restore one into it
          • What has been restored into it, and from where
          • Its read copies
          • Add one
        • Policies
          • The catalog
          • One policy
          • What this database is held to
          • Switch a policy on, or change its knobs
          • Switch it off
          • Mark the policies reviewed
          • Evaluate the periodic policies now
          • Who is behind a credential
        • Passwordless
          • The database's passwordless sessions
          • Issue a passwordless session (v1)
          • Revoke a passwordless session
          • Bind a session to a device key
          • Issue a v2 session for a host to bind
          • Redeem an enrolment ticket on the host
          • Check a passwordless credential
          • Run one described query under a passwordless credential
        • Database roles
          • The database's roles
          • Define a role
          • One role
          • Change what a role permits
          • Delete a role, and revoke every key granted it
          • Grant a role, which mints a key
          • Who holds a role
          • The api keys bound to a role
        • Pools
          • A database's connection pools, and how busy each is
          • Open another pool
          • Rename a pool or change its size
          • Close a pool
        • Data plane
          • Run a query against a database
          • Several statements, in order, over one connection
          • Is this database answering
          • What the proxy itself is holding
        • Transfers
          • The strategies this account's tier may use
          • Price a transfer without creating it
          • The account's transfer jobs, newest first
          • Create a transfer job
          • One job, and whether its certificate holds
          • Cancel an unfinished job
          • Start a created job, confirming its price
          • Report a job's status (the runner, or the owner's side of a local run)
        • Every database on the account
        • Provision a database
        • Change a database that is already running
        • One database
        • Deprovision it
        • Read or write it
        • Report what it is using
        • The engines this API will provision
        • Where a managed database can be put
    • Teams
      • Teams
        • Members
          • Who is on it
          • Invite somebody
          • Accept an invitation
          • Change somebody's role
          • Remove somebody
        • Projects
          • The projects a team runs
          • Start one
          • Rename a project, or move its environment
          • Delete a project
          • One project, and what is in it
          • Put a database or store in it
          • What is in a project
          • Take one out
        • The teams this account is on
        • Start one
        • The twelve roles, and what each may do
        • Rename a team
        • Close a team
        • One team
        • Hand the team to somebody else
        • Leave a team
    • Schemas
      • Error
      • ValidationErrors
      • Token
      • PolicyCategory
      • PolicySeverity
      • PolicyAction
      • PolicyTrigger
      • PolicyParam
      • Policy
      • PolicyCatalog
      • PolicyAssignment
      • PolicyOutcome
      • PolicyFiring
      • CredentialTrace
      • Relation
      • Restrictions
      • ChildSummary
      • SignupRequest
      • SigninRequest
      • UpdateMeRequest
      • User
      • Address
      • GeoPoint
      • D1Region
      • Usage
      • UsageReport
      • Resource
      • Database
      • DataStore
      • NewDatabase
      • NewDataStore
      • QueryRequest
      • DatabasePrivilege
      • ApiKey
      • DbUser
      • Access
      • AccessRequest
      • DatabaseObject
      • NewDatabaseObject
      • NewMigration
      • SchemaOperation
      • Migration
      • Operation
      • Session
      • AdminPowers
      • Admin
      • AuditEntry
      • TeamRole
      • Conversation
      • ChatMessage
      • TeamSso
      • Team
      • TeamMember
      • SshKey
      • ConnectionInfo
      • InboxAddress
      • InboxMailbox
      • InboxMessageSummary
      • InboxMessage
      • InboxNote
      • Page
      • Quote
      • Plan
      • ApiError
      • CapabilityRefusal
      • KlockErrorCode
      • PageWindow
      • SessionView
      • KlockStepUpRequest
      • KlockOpenRequest
      • KlockOpenedSession
      • UpdateMeResult
      • CapabilitiesView
      • SessionLimits
      • Device
      • DeviceListed
      • DeviceTeamRef
      • DeviceCommand
      • DeviceAuditLine
      • DeviceActionRequest
      • StaffActionRequest
      • ManagedSession
      • SessionRevoked
      • AccessRule
      • AccessRuleRequest
      • BehaviourProfile
      • BehaviourProfileRequest
      • BehaviourProfileSaved
      • BehaviourFinding
      • BehaviourFindingAck
      • StepUpProof
      • Removed
      • MemberLockdownRequest
      • McpClient
      • McpDelegatedView
      • McpToolCall
      • McpForwardRequest
      • PasswordlessScope
      • RoleScope
      • PasswordlessSession
      • PasswordlessTlsMaterial
      • PasswordlessKerberosMaterial
      • ServiceDeviceKeys
      • ServiceSession
      • DatabaseRole
      • TransferEndpoint
      • TransferJobRequest
      • TransferQuote
      • TransferStrategy
      • TransferJob
      • TransferJobAccess
      • Pool
      • PoolAllowance
      • BillingSubscription
      • Invoice
      • BillingContact
      • PaymentMethod
      • UpcomingCharges
      • TeamBilling
      • TeamKerberosRealm
      • TeamSsoDomain
      • TeamSsoResponse
      • StoreConnection
      • BatchFailure
      • ProxyStatus
  1. guides

Capabilities, tiers and team roles

A capability is one named thing a session may do, such as data:read or
resource:delete. Every part of the platform uses the same list: the API
checks capabilities on each request, the CLI uses them to decide which
commands to show, and the MCP servers use them to decide which tools to
list. The list, and the rules that turn an account into a set of
capabilities, live in one pure module, src/capabilities.ts. The module is
published as ts-prorm-orm/capabilities, and the API imports it from the
package.
This page covers the capability ids, the tiers, plan entitlements, team roles,
admin scopes and step-up, how the API enforces capabilities, team-owned
resources, and how the CLI and MCP use the same list. For the session file
and its signed grant, see klock. For the rules that can deny a
request that its capabilities allow (IP, country, device, time), see
access rules and behaviour.
WhereWhat
src/capabilities.tsThe ids, tiers, TEAM_ROLES / ROLE_CAPABILITIES / roleCan, ADMIN_TYPES / ADMIN_SCOPES / ADMIN_PRESETS, session kinds and limits, PLAN_ENTITLEMENTS, API_KEY_CAPS, resolveCapabilities(), resolveResourceCaps(), unlockHint(). Pure: no imports, no I/O.
api/middleware/capabilities.jsrequireCapability, the enforcement modes, and ROUTE_CAPABILITIES, the table of what each route needs.
api/controllers/ownership.tsresolveResource(): how a caller reaches one database, store or transfer job (owner, team or API key).
api/security/controllers/klock.tsThe principals (bearer, klock, API key, guest), step-up, and GET /me/capabilities.
api/admin/controllers/access.tsrequireScope / requireAnyScope, which add admin:<scope> to the admin checks.
src/cli/core/command-needs.ts, src/cli/core/framework.ts, src/cli/core/capability-view.tsWhat each CLI command needs, and the CLI's guard.
src/mcp/registry.tsWhat each MCP account tool needs.
CAPABILITIES_VERSION is 1. /me/capabilities returns it, so a client can
tell which list the server speaks.

The capability ids#

An id has the form domain:verb. expand() resolves the wildcards *
(everything) and ns:* (every id in one domain). Only the team owner role
uses a wildcard. satisfies(needs, held) treats an array of needs as
any-of.
There are 60 ids in six groups. Every table on this page was generated from
src/capabilities.ts (see regenerating these tables).
GroupCountIdsWho holds them
public5docs:read, reference:read, scaffold:use, catalog:read, local:useEveryone, including guests
self15account:read, account:write, session:read, session:manage, device:read, device:manage, access-rule:read, access-rule:write, behaviour:read, behaviour:write, team:create, klock:sync, mcp:clients, files:send, files:receiveAny signed-in account, for itself. files:* depends on the plan.
resource22team:read, team:manage-members, project:read, project:write, resource:read, resource:provision, resource:operate, resource:delete, data:read, data:write, migration:write, migration:apply, key:read, key:write, access:read, access:write, audit:read, billing:read, billing:manage, sso:manage, chat:manage, kerberos:manageThe owner of a resource holds all of them. A team member holds the ones their role grants.
team-admin5device:manage-members, session:manage-members, access-rule:team, behaviour:team, files:teamTeam roles owner, admin and security, and operator for files:team
service2passwordless:use, transfer:reportservice sessions only
admin11admin:dashboard, admin:users, admin:resources, admin:operations, admin:billing, admin:logs, admin:support, admin:email, admin:dev, admin:grant-admin, admin:assumePlatform staff, by admin scope. These are secret.
Every id, with its description
IdGroupDescription
docs:readpublicRead the documentation.
reference:readpublicRead the API and dialect reference.
scaffold:usepublicGenerate and review code from templates.
catalog:readpublicList engines and regions.
local:usepublicRun the ORM against databases on this machine.
account:readselfRead your own account.
account:writeselfChange your own account.
session:readselfList your sessions.
session:manageselfRevoke, rotate and freeze your sessions.
device:readselfList your devices.
device:manageselfRename, revoke, wipe and pair your devices.
access-rule:readselfRead your access rules.
access-rule:writeselfChange your access rules.
behaviour:readselfRead your behaviour profiles and findings.
behaviour:writeselfChange your behaviour profiles.
team:createselfCreate a team.
klock:syncselfSync this device with the klock service.
mcp:clientsselfCreate and revoke delegated MCP client tokens.
files:sendselfSend files to your own devices.
files:receiveselfReceive files on this device.
team:readresourceSee a team and its members.
team:manage-membersresourceInvite, change and remove team members.
project:readresourceSee projects and what they group.
project:writeresourceCreate projects and attach resources to them.
resource:readresourceSee databases and stores, their operations and metrics.
resource:provisionresourceProvision databases and stores (billed to the owner: you, or the team).
resource:operateresourceResize, pause, resume, back up and move resources.
resource:deleteresourceDelete resources.
data:readresourceRead data.
data:writeresourceWrite data.
migration:writeresourceWrite and preview migrations.
migration:applyresourceApply migrations.
key:readresourceList keys and connection details.
key:writeresourceIssue and revoke keys.
access:readresourceRead engine logins, roles, passwordless sessions and access settings.
access:writeresourceChange engine logins, roles, passwordless sessions and access settings.
audit:readresourceRead audit logs and policies.
billing:readresourceRead the owner's billing: your own account's, or the team's.
billing:manageresourceManage the owner's billing account: your own, or the team's.
sso:manageresourceConfigure single sign-on.
chat:manageresourceConfigure team chat.
kerberos:manageresourceManage Kerberos principals and certificates.
device:manage-membersteam-adminRevoke team members' devices used on team resources.
session:manage-membersteam-adminRevoke team members' sessions in the team's context.
access-rule:teamteam-adminSet mandatory team access rules.
behaviour:teamteam-adminSet team behaviour profiles.
files:teamteam-adminSend files to team members' devices.
passwordless:useserviceQuery a database as a bound passwordless session.
transfer:reportserviceReport the status of one transfer job.
admin:dashboardadminSee the admin area.
admin:usersadminRead and act on customer accounts.
admin:resourcesadminSee every database and store on the platform.
admin:operationsadminSee and drive the operations queue.
admin:billingadminInvoices, plans, rates and refunds.
admin:logsadminDatabase event and data logs.
admin:supportadminThe support tools.
admin:emailadminThe email accounts and inboxes.
admin:devadminDatabase health and metrics.
admin:grant-adminadminCreate, change and revoke admins.
admin:assumeadminAct as a customer account.

Tiers#

TIERS is guest, user, team and admin. The tier is a display and
default-limits class
. It is not an authorisation input: the capability set
decides what a session may do.
TierWhenCapabilities (an interactive session on the usage plan)
guestNo accountThe 5 public ids
userSigned in, no team context42: public, self and resource. The account owns its own resources, so its ceiling includes every resource capability.
teamSigned in with a team context (--team, the x-prorm-team header, or the grant's teamId) that is an active membershipThe user's 42, plus the team-admin ids the role grants. An admin in the team gets 47: access-rule:team, behaviour:team, device:manage-members, files:team, session:manage-members. A developer gets no extra ids.
adminAn account with role: 'admin' and at least one admin scope, in an interactive or browser sessionThe user's 42, plus admin:<scope> for each scope. For interactive sessions these are dormant until a step-up.
A plain user's ceiling already contains every resource capability, and a team
role never narrows it. What narrows a request on a team resource is the
resource check, which intersects the ceiling with the role. See
how a request is decided.

Resolution#

resolveCapabilities(principal, session) computes a session's ceiling
(caps), its dormant capabilities, its tier, its team roles and its
limits:
1.
Everyone gets the public set. With no user, that is the whole answer.
2.
A user gets the self and resource sets, then the plan's entitlements
(add and remove). In a team context, the plan is the team's.
3.
Every active membership adds its role's capabilities. A team context
must be an active membership, or resolution throws team_not_active.
A guardian restriction (restricted.noProvisioning) then removes
resource:provision and team:create, so a team role cannot restore them.
4.
The session kind's mask (KIND_MASK) is applied. A service session
gets the service set first.
5.
narrowTo, if set, narrows both the ceiling and the dormant set.
6.
Admin scopes become admin:<scope>, for interactive and browser
sessions only (ADMIN_KINDS). See step-up.
7.
The tier, then the limits: the kind and tier defaults, then the plan,
team (in context only), admin and user layers (mergeLimits).
The same account resolves differently by session kind (generated, usage plan):
Session kindCeilingNotes
interactive, device, browser, cli-legacy, handoff, assumed42Every non-admin capability the account holds. Only interactive and browser can carry admin:*.
delegated (an MCP client token)33Loses access-rule:read, access-rule:write, behaviour:read, behaviour:write, billing:manage, device:manage, mcp:clients, session:manage and team:manage-members, and never holds the team-admin ids or admin:*.
service7data:read, data:write, files:receive, migration:apply, passwordless:use, resource:read, transfer:report
guest5The public set
The delegated mask is stricter than the design's list. It also removes
device:manage-members and session:manage-members, so a delegated token can
never act on other members' devices or sessions.

Session kinds and limits#

SESSION_KINDS is browser, cli-legacy, interactive, device,
service, delegated, guest, handoff and assumed. SESSION_DEFAULTS
gives each kind's default limits (generated; – means no limit):
Kind (tier)Max durationIdle timeoutConcurrent (evict)Check in everyGrant TTLStep-up TTLRotate
interactive (user, team)30d7d10 (lru)1h1d––
interactive (admin)12h30m3 (lru)5m12h15m–
device–90d10 (refuse)1d7d–365d
service–180d100 (refuse)1d7d–90d
delegated30d7d5 (lru)00––
guest1d2h1 (lru), 5 new per IP per hour1d1d––
browser1h––0015m–
cli-legacy30d––00––
handoff1h––00––
assumed8h––00––
A checkInEverySec of 0 means the server checks the session on every
request. A grantTtlSec of 0 means the kind carries no signed grant. These
are the bearer kinds.
HARD_LIMITS are ceilings that no layer can exceed:
LimitValue
Interactive session duration90 days
Any admin-tier session24 hours
Step-up TTL60 minutes
Service check-inat most every 72 hours, and a team cannot tighten it below 1 hour
Devices per account100
Grant TTL7 days
mergeLimits layers overrides over the defaults. A plan or admin layer
may move a value either way, within the hard limits. A team or user layer
may only tighten a value. evict: 'refuse' counts as tighter than
'lru'. For how the session kinds behave, see
klock, sessions.

Plan entitlements#

PLAN_ENTITLEMENTS says what each plan adds, removes and allows. An unknown
plan resolves to free. In a team context the team's plan applies,
because the team is billed. These are the values in src/capabilities.ts
today:
PlanAddsRemovesDevicesFile transfer (per transfer / per day)
free–files:send, files:receive3off
starter–files:send, files:receive3off
usage––102 GB / 10 GB
membership––2510 GB / 100 GB
pro––2510 GB / 100 GB
The device count is a plan layer over SESSION_DEFAULTS.device.concurrent,
so it is capped by the hard limit of 100.

API keys#

An API key (x-api-key) is not a session. Its principal holds
API_KEY_CAPS[privilege] and is locked to the one database it was issued for
(resourceLock):
PrivilegeCapabilities
ownerdata:read, data:write, migration:apply, key:read
admindata:read, data:write, migration:apply
readwritedata:read, data:write
readonlydata:read
An unknown privilege is treated as readonly.

Team roles#

TEAM_ROLES has twelve roles. roleCan(role, cap) answers from
ROLE_CAPABILITIES, and owner holds *. Only active members hold
anything: invited and suspended members get nothing.
Role × capability (generated from roleCan):
Capabilityowneradminbillingsecurityoperatordeveloperdeployeranalystsupportauditorviewerguest
team:readyesyesyesyesyesyesyesyesyesyesyes
team:manage-membersyesyes
project:readyesyesyesyesyesyesyesyesyesyes
project:writeyesyesyes
resource:readyesyesyesyesyesyesyesyesyesyes
resource:provisionyesyesyes
resource:operateyesyesyesyes
resource:deleteyesyes
data:readyesyesyesyesyes
data:writeyesyesyesyes
migration:writeyesyesyesyes
migration:applyyesyesyes
key:readyesyesyesyes
key:writeyesyesyes
access:readyesyesyesyes
access:writeyesyesyes
audit:readyesyesyesyesyes
billing:readyesyesyes
billing:manageyesyes
sso:manageyesyesyes
chat:manageyesyes
kerberos:manageyesyesyes
device:manage-membersyesyesyes
session:manage-membersyesyesyes
access-rule:teamyesyesyes
behaviour:teamyesyesyes
files:teamyesyesyes
Public and self capabilities are not in the table, because a role does not
grant them: every signed-in account holds them for itself. Note that a team
admin cannot manage billing (billing:manage); only the owner and
billing roles can.

Admin scopes and step-up#

Platform staff are accounts with role: 'admin' and a permission set.
ADMIN_TYPES is general, billing, logs, support, email, dev and
other. other is a custom set, defined per account. ADMIN_SCOPES lists
the eleven powers, and adminCap(scope) maps each one to one capability.
There is one capability per existing scope, and no new scope was added.
PresetCapabilitiesCan grant adminWhat it is for
generalall eleven admin:*yesEverything, including granting admin.
billingadmin:dashboard, admin:billingBilling, invoices, plans and rates.
logsadmin:dashboard, admin:logsDatabase event and data logs.
supportadmin:dashboard, admin:users, admin:resources, admin:support, admin:assumeHelp customers with their accounts, including as them.
emailadmin:dashboard, admin:emailThe email accounts and inboxes we run.
devadmin:dashboard, admin:resources, admin:operations, admin:devMonitor our databases: health, not data.
The API can override the presets at run time from object-store documents. The
table shows the compiled defaults.
On the API, requireScope(scope) still runs resolvePermissions first, and
its 403 names the missing scope. It then runs
requireCapability('admin:<scope>', { area: 'admin' }) against the session's
ceiling. requireAnyScope does the same with an any-of list.

Dormant capabilities and step-up#

Admin capabilities are only ever available to interactive and browser
sessions. In an interactive (CLI) session they are dormant: the grant
lists them under dormant, not caps. They become live when the account
has MFA enrolled and has stepped up within the step-up TTL (15 minutes by
default, 60 at most). The resolved adminUntil says until when.
From the CLI: prorm step-up (TOTP). When a command needs a dormant
capability, the guard offers the prompt on a terminal and then runs the
command. Without a terminal, it exits with Run `prorm step-up` first.
On the API: POST /security/klock/sessions/:id/step-up with
{ "totp": "123456" }. A browser session without a second factor may send
{ "password": … } instead. A klock session never can
(password_browser_only), and an account that has TOTP must use it
(totp_required). Failures count against the sign-in lockout
(too_many_attempts) and are audited as session.step-up-failed. A klock
caller gets a new grant back, with adminUntil.
When a request needs step-up: when the capability it needs is dormant;
on routes marked stepUp (today, revealing an SSH key); and for any
admin:* capability on an unsafe method (POST, PUT, PATCH or DELETE) from a
klock session, or, from E3, from a browser session. The answer is
step_up_required. A klock session gets 401 with
WWW-Authenticate: Klock error="step_up_required", and a bearer session
gets 403:
{ "error": "step_up_required", "message": "This needs a fresh step-up: prorm step-up", "needs": "admin:users", "unlock": "step-up" }
A support engineer's day, in the terminal. The five admin:* capabilities of
the support preset are dormant until the step-up, then live for 15 minutes:
$ prorm whoami
sam <sam@example.com>  (admin)
  tier        admin · plan usage
  session     interactive · device-bound · dev_7QK2… · key in the OS keychain
  check in    by 28/09/2026, 10:05:00 (in 5m)
  expires     28/09/2026, 22:00:00
  klock       active · ~/.prorm/klock/default.klock
  dormant     admin:assume, admin:dashboard, admin:resources, admin:support, admin:users — `prorm step-up` makes them live
  42 capabilities (api); --caps lists them
API https://api.prod-orm.io
$ prorm step-up
Authenticator code (step-up): ******
✓ Stepped up; admin capabilities are live until 28/09/2026, 10:15:00.
$ prorm whoami --json | jq '.dormant, .session.adminUntil'
[]
"2026-09-28T09:15:00.000Z"
The same step-up three ways:
$ prorm step-up --totp 123456
✓ Stepped up; admin capabilities are live until 28/09/2026, 10:15:00.
Without --totp on a terminal, it prompts. In a script with no terminal and
no --totp, it exits with A step-up needs an authenticator code: pass --totp <code>.
A browser session on an account with no second factor may send
{ "password": "…" } instead. A klock caller signs the request with its
device key rather than sending a bearer token, and gets a new grant back.
Open Security › Capabilities (#/security?tab=capabilities) and use the
Step up now card. Any page that gets 401 step_up_required also asks for
the code and retries, without signing you out.
[!WARNING]
Failed step-ups count against the sign-in lockout. A script that retries a
stale TOTP code in a loop locks the account (too_many_attempts).
A browser admin's capabilities stay live without a step-up (the legacy rule)
until E3. A cli-legacy token (the old prorm-admin login) carries no
admin:* at all. See enforcement for what that means for
the rollout.

How a request is decided#

The API never trusts the ceiling alone. For a request on a resource, the
effective set is the ceiling intersected with the capabilities the caller
holds on that resource
.
For a klock session, the API re-resolves capabilities from live facts on
each request and intersects them with the grant. A team role that has been
lowered therefore takes effect before the grant is re-issued.

Enforcement#

requireCapability(needs, { resource, stepUp, area, all }) is the check, and
ROUTE_CAPABILITIES is the table of what every covered route needs. Each
route's check comes from that table, via capability(router, route).
capability() throws at import time for a route the table does not map, and
api/tests/capabilities-routes.test.js fails on a route that is missing, an
extra entry, or a route that does not run its entry's check.

Modes and areas#

VariableValuesDefaultEffect
CAPABILITY_ENFORCEMENToff, report, enforce, or an area listoffThe mode. It is read on every call, so it can change without a restart. An unrecognised value with no area list anywhere means off.
CAPABILITY_ENFORCEMENT_AREASa comma list of area or area=mode, for the areas resource, team, adminemptyPer-area modes, for example resource=enforce,team=report. : works as well as =, case is ignored, and unknown areas and modes are dropped. See the precedence.
CAPABILITY_E31 / true / yes / onoffEnforcement stage E3. See below.
off skips the ceiling, resource and step-up checks entirely, so an
existing account sees what it saw before capabilities existed.
report runs the checks. A request that would be refused is served
anyway, and recorded as an access.would-deny audit event (level
notice, category access). Its detail has the area, the needs, the
reason (capability_missing, step_up_required or unauthenticated), the
unlock hint, the route, the principal's source, the session kind and how
the resource was reached.
enforce refuses. A missing capability answers 403:
{ "error": "capability_missing", "message": "This session cannot do that", "needs": "resource:delete", "unlock": "team-role" }
unlock is one of login, upgrade, team-role, step-up and none,
from unlockHint(). Admin capabilities always answer none, so they are
never advertised. With no principal at all, the answer is 401
unauthenticated.
Two checks do not depend on the mode:
The team role. A caller who reaches a resource through a team must hold
the capability in their role, in every mode, including off. Team
access is new, so there is no older behaviour to keep, and without the check
a viewer could delete what they can only see. This answers 403
capability_missing with unlock: 'team-role' and the message
Your role on this team (<role>) cannot do that.
Managing MCP client tokens (mcp:clients), which the route checks
itself.
The planned rollout order is off, then report everywhere, then enforce
area by area: resource, then team, then admin. The
deploy runbook has
the steps.

Which mode an area gets#

enforcementMode(area) in api/middleware/capabilities.js decides each area
(admin, resource, team). The first rule that applies wins:
1.
area=mode in CAPABILITY_ENFORCEMENT_AREAS gives that mode.
2.
A bare area in CAPABILITY_ENFORCEMENT_AREAS gives
CAPABILITY_ENFORCEMENT when that is a mode, and enforce otherwise.
3.
CAPABILITY_ENFORCEMENT may itself be written as an area list. There,
area=mode gives that mode and a bare area gives enforce.
4.
An area listed nowhere:
with neither variable set, off (unchanged);
when CAPABILITY_ENFORCEMENT is a mode, that mode;
otherwise (it is unset, an area list or unrecognised, while some list is
set), report.
The admin area is then still held at report until CAPABILITY_E3=1
(below).
Settingsresourceteamadmin
nothing setoffoffoff
CAPABILITY_ENFORCEMENT=reportreportreportreport
CAPABILITY_ENFORCEMENT_AREAS=resource=enforceenforcereportreport
CAPABILITY_ENFORCEMENT_AREAS=resource=enforce,team=enforceenforceenforcereport
the same plus admin=enforce, and CAPABILITY_E3=1enforceenforceenforce
CAPABILITY_ENFORCEMENT=enforce, CAPABILITY_ENFORCEMENT_AREAS=adminenforceenforceenforce (report before E3)
[!WARNING] Behaviour change
Before wave S2, CAPABILITY_ENFORCEMENT=enforce with
CAPABILITY_ENFORCEMENT_AREAS=admin meant "admin enforced, everything else
off". Unlisted areas now fall back to the base mode, so the last row
enforces every area. To enforce admin alone and report the rest, write
CAPABILITY_ENFORCEMENT_AREAS=admin=enforce (with CAPABILITY_E3=1).

The admin area and E3#

Until E3, the admin area is held at report even when it is set to
enforce (effectiveMode). A prorm-admin CLI login is a cli-legacy
bearer, which by design carries no admin:*. Enforcing the admin area before
admins move to klock v2 sessions would lock every CLI admin out, so until then
those requests are recorded as access.would-deny and still served.
[!CAUTION]
CAPABILITY_ENFORCEMENT=enforce with admin in
CAPABILITY_ENFORCEMENT_AREAS does not refuse admin requests yet. Until
CAPABILITY_E3=1, the admin area only records access.would-deny. Read
those findings before you turn E3 on, or CLI admins on cli-legacy tokens
are locked out.
CAPABILITY_E3=1 turns on:
real enforcement for the admin area when it is set to enforce;
step-up for admin:* capabilities on unsafe methods from browser
sessions, as well as klock ones;
mandatory admin MFA;
no new v1 CLI tokens from the login flow;
scope=all as the default for resource lists.

Mandatory admin MFA#

Every requireAdmin route (all of /admin/*, and /proxy/status) refuses
an admin who has no confirmed TOTP factor. A set-up that was never
confirmed does not count. The answer names the way out:
{
  "error": "mfa_required",
  "message": "Admin accounts need a TOTP second factor. Enrol one (prorm security mfa enable, or the console security page), then try again.",
  "enrol": {
    "setup": { "method": "POST", "url": "https://api.prod-orm.io/security/mfa/setup" },
    "confirm": { "method": "POST", "url": "https://api.prod-orm.io/security/mfa/confirm", "body": { "code": "<six digits from the app>" } }
  }
}
The check runs before the klock step-up check, so an admin on a klock
session with no factor sees mfa_required
(403) rather than a step-up they cannot make.
/security/mfa/* are the account's own routes (requireAuth, never
requireAdmin), so an admin can always enrol: prorm security mfa enable
from a terminal, or the prompt the staff console shows
(Security in the console).
Once enrolled, the admin's step-up is { totp }. A password step-up is
refused for an account with a factor.
Customers are not affected.

No new v1 CLI tokens#

POST /security/sessions/cli, and the v1 sign-in relay
POST /security/cli-logins without v: 2, answer 410
login_v2_required:
{
  "error": "login_v2_required",
  "message": "This API no longer issues legacy CLI tokens at sign-in. …",
  "login": {
    "v": 2,
    "configuration": "https://api.prod-orm.io/.well-known/klock-configuration",
    "open": "https://api.prod-orm.io/security/klock/sessions"
  }
}
The exception is an explicit personal token for CI, --token or
PRORM_TOKEN: POST /security/sessions/cli with purpose: "token" still
issues one, for 30 days at most (days over 30 is a 400). The console's
CLI tokens page sends that. The v2 relay (v: 2) is unchanged, tokens
already issued keep working until they expire, and the enforced admin area
already refuses cli-legacy tokens.

Lists default to scope=all#

GET /provision/databases and GET /provision/stores with no ?scope=
answer as scope=all: your own resources plus the teams', each item with
access: { via, teamUuid?, role? }. Before E3 the no-scope answer is
unchanged (your own only, no access). The transfer jobs list is unchanged.

What each route needs#

A summary of ROUTE_CAPABILITIES. The table in
api/middleware/capabilities.js is authoritative.
Router (mount)Needs
provision (/provision)GET /engines and /regions are public. Listing and reading → resource:read. POST /databases and /stores → resource:provision (in the team, with a team context). PATCH and PUT …/usage → resource:operate. DELETE → resource:delete. GET /stores/:id/connect → key:read. POST /databases/:id/query → data:read for a select, data:write otherwise.
databases (/provision/databases)Keys: GET → key:read, POST/DELETE → key:write. Engine logins, SSH keys and /access: GET → access:read, changes → access:write. Revealing an SSH key → access:write with step-up. GET /:id/connect → key:read.
cloudOperations, backups, restores, migrations, replicas, metrics and events: GET → resource:read. Resize, backup, pause, resume, move, replicas, cancel and retry → resource:operate. restore → resource:operate and data:write. rotate-credentials → access:write. migrations and migrations/preview → migration:write. migrations/apply and migrate → migration:apply.
objectsGET → resource:read. Create, change, preview and delete → migration:write.
poolsGET → resource:read, otherwise resource:operate.
policiesA database's: GET and trace → audit:read, changes, review and check → access:write. The catalogue at /policies is public.
rolesGET → access:read, otherwise (including grant) → access:write.
passwordlessList → access:read, issue and revoke → access:write. exchange and query take a signed grant, not a session.
transfers (/transfer)quote, create, start and delete → resource:operate. Reads → resource:read. events takes the runner token, the owner's session or the job's klock.
teams (/teams)By capability in the team: team:read, team:manage-members, project:read/project:write, sso:manage, kerberos:manage, and billing:manage for transfer-billing. POST /teams → team:create. Closing or transferring a team also needs the owner's password.
teamBilling (/teams)GET …/billing* → billing:read; checkout, portal, cards, plan and contact → billing:manage, in the team. See a team's billing account.
mcpClients (/security/mcp)Managing clients → mcp:clients (checked in the route). /capabilities and /call take a delegated token, and each call is checked against the tool's needs.
mcpForward (/internal/mcp)A klock grant and an RFC 9421 signature over the MCP request, then the tool's needs.
Admin routes are not in the table. They are gated by requireScope, as
described above.

Team-owned resources and billing#

A resource created in a team context (teamId in the body, or the
session's team) belongs to the team: the row has ownerKind: 'team' and the
team's teamId. userId still records the member who created it. This
follows the decision recorded on 2026-09-26: team-provisioned resources are
owned and billed by the team.
resolveResource(kind, id, principal) loads the row without filtering by
user, and answers how the caller reaches it:
viaWhenResource capabilities
ownerA user-owned row, and the caller is its userIdEverything (expand(['*']))
teamThe row's teamId is a team the caller is an active member of. For a user-owned row, its owner must also still be an active member.ROLE_CAPABILITIES[role]
keyAn API key presented for the database it was issued forThe key's API_KEY_CAPS
noneAnything elseThe route answers 404, exactly as for a row that does not exist, so a non-member cannot tell that the resource exists.
The rules this enforces:
The team is a property of the row. Only teamId on databases,
data_stores and transfer_jobs gives team access, never
project_resources. A resource therefore belongs to at most one team by
construction.
Sharing a resource you own. Attaching it to a team project
(POST /teams/:teamId/projects/:projectId/resources) needs ownership and
project:write. Attaching records the team on the row. A resource already
shared with another team answers 409 resource_in_other_team, and
someone else's resource answers 404. When the last attachment is removed,
the share ends.
Pre-existing attachments made before this change confer nothing until
the owner attaches the resource again.
Leaving a team. When a member leaves or is removed, the resources they
own that were shared with the team are detached at once. This is audited
as resource.auto-detached for the member and for the team's owner and
admins. Team-owned resources stay with the team, including the ones the
member created.
Closing a team that still owns databases, stores or transfer jobs
answers 409. Resources that were only shared go back to their owners.
Transfer jobs are shared with a team only when the team owns them. A
user-owned job's teamId only says which team's billing it settles on.
Plan and billing. A create in a team context is checked against the
team's plan and the team's usage, not the member's. Invoices for a team's
Stripe customer are billed for what the team owns
(billableTeamResources), and an account's invoice leaves out team-owned
resources.
Lists. GET /provision/databases and /stores take
?scope=own|team|all. Without scope, they return the caller's own,
user-owned resources until E3, and scope=all from E3
(above). With team or all, each item
carries access: { via, teamUuid?, role? }. Team items are listed only
when the role holds resource:read.
Removed by staff. When prorm staff remove a member
(DELETE /admin/teams/:teamId/members/:userId), the member's shared
resources are detached exactly as when the team removes them
(detachOnLeave), audited as resource.auto-detached with the admin as
actorId. The admin audit line carries detached: <count>.

A team's billing account#

A team has a billing account of its own: its own Stripe customer
(teams.stripeCustomerId, made on the team's first checkout, never a
member's), its own plan (teams.plan, which the team's quota reads) and a
billing contact (teams.billingUserId; the owner when unset). The routes are
in api/team/routes/teamBilling.js, mounted at /teams.
Every route needs an active membership. A non-member, or a team that does not
exist, gets 404 {"error":"Unknown team"} before anything else is read. A
member whose role lacks the capability gets 403 capability_missing with
needs and unlock: "team-role". The owner and billing roles hold
billing:read and billing:manage; admin holds billing:read only.
MethodPathNeedsDoes
GET/teams/:teamId/billingbilling:readThe plan, subscription, customer (a boolean), contact, transfer billing, pools { used, max, remaining }, the monthly estimate, and configured
GET/teams/:teamId/billing/invoicesbilling:readThe team's invoices, newest first
GET/teams/:teamId/billing/upcomingbilling:readThis month's lines for the team's own resources
GET/teams/:teamId/billing/payment-methodsbilling:readThe cards on the team's customer: brand, last4, expiry, isDefault
POST/teams/:teamId/billing/checkout { membership? }billing:manageStripe Checkout on the team's customer, which is created here on first need. 409 when the team already pays, with next: PUT /teams/:id/billing/plan. Honours Idempotency-Key.
POST/teams/:teamId/billing/portalbilling:manageThe Stripe billing portal for the team's customer
POST/teams/:teamId/billing/payment-methodsbilling:manageA Stripe-hosted setup session. When it completes, the webhook makes the card the team's default.
PUT/teams/:teamId/billing/payment-methods/:pmId/defaultbilling:manage404 for a card that is not on the team's customer
DELETE/teams/:teamId/billing/payment-methods/:pmIdbilling:manage204; 404 for another customer's card
PUT/teams/:teamId/billing/plan { plan: free | usage | membership }billing:manage202 { pending }: Stripe makes the change, and teams.plan moves when the webhook confirms it. free cancels at the period end. Before the team has checked out, 409 with next: POST /teams/:id/billing/checkout.
PUT/teams/:teamId/billing/contact { userId | null }billing:manageAn active member whose role has billing:read (422 otherwise; a non-member is 404). null means the owner. Also updates the Stripe customer's email.
PUT/teams/:teamId/transfer-billingbilling:manageWho pays for the team's transfers (on the team router)
The checkout, portal, card and plan routes refuse a child's account, as
/billing/* does, and answer 503 when Stripe is not configured.
The webhook (POST /billing/webhook):
checkout.session.completed and customer.subscription.*: a subscription
whose metadata.teamId names a team, or whose customer is a team's, is
mirrored with teamId and moves teams.plan. It must be on the team's own
customer: a subscription on any other customer never moves a team's plan,
whatever its metadata says.
checkout.session.completed in setup mode makes the new card the
customer's default, for an account's customer or a team's.
invoice.paid and invoice.payment_failed: an invoice on a team's
customer is stored with teamId, and its userId is the billing contact.
A failed payment emails the billing contact and is audited as
team.billing.payment-failed.
invoice.created adds the team's resources to the team's invoice.
GET /billing/invoices and GET /billing/subscription list only the
account's own rows (teamId null). A team's rows appear only under
/teams/:id/billing/*.
What the team pays for:
Transfers. A job created with teamId is the team's. The team's
customer must have a card on file; without one the job is refused with
402 ("A card on the team's billing account is required…"). The charge
goes to the team's Stripe customer with metadata.teamId. The member is
never made a customer.
Connection pools. A team-owned database's pools count against the
team's plan allowance, not its creator's. At the limit the answer is 429
with next: "PUT /teams/:id/billing/plan raises the team's plan".
GET /provision/databases/:id/pools reports allowance.owner as team or
user, and an account's own count no longer includes pools on team
databases it created. A team cannot buy extra pools one at a time; it
raises its plan instead.
In the console this is Team › Billing
(Security in the console).

Devices and sessions#

Device and session management is checked in every enforcement mode,
including off: these routes change credentials, so they never run on the
ceiling alone. The routes answer 503 klock_unconfigured when the API has no
klock service binding.
WhoRoutesNeeds
You, on your own devicesGET /security/devices, GET /security/devices/:iddevice:read
PATCH, DELETE /security/devices/:id, POST …/suspend, …/reinstate, …/wipe, …/rotate-key, POST /security/devices/pairings/approvedevice:manage. Approving a pairing as a device kind, like opening a device session, needs a fresh step-up.
A team administrator, on members' devicesGET /security/devices?team=<t> and the same routes with team; GET /teams/:teamId/devices, DELETE /teams/:teamId/devices/:deviceIddevice:manage-members in that team
A team administrator, on members' sessionsGET /teams/:teamId/sessions, DELETE /teams/:teamId/sessions/:sidsession:manage-members in that team
StaffGET /admin/users/:id/devices, DELETE /admin/users/:id/devices/:deviceId, POST /admin/users/:id/devices/:deviceId/wipe, DELETE /admin/users/:id/sessions/:sid, GET /admin/klock/devicesthe support admin scope (admin:support)
The rules for acting on someone else's device or session:
A team administrator must give a reason (400 reason_required
otherwise). The action is audited on the member's trail at level warning,
with the actor's id, and the member is emailed. Only the team's owner may
act on the owner's own devices and sessions (403 for anyone else).
Staff need a fresh step-up for every change, in every mode (the
session's own, or stepUp in the body), and a reason of 10 to 500
characters. Each action is audited as admin.device-action or
admin.session-action at level alert, and the account holder is emailed.
404 parity. Someone else's device answers 404 device_not_found, the
same as a device that does not exist. On the team routes, a caller who is
not a member gets the same 404 as for a team that does not exist.
Signing out everywhere spares service sessions. A service session is any
kind other than browser, cli-legacy, interactive, device,
delegated, handoff, assumed and guest (isServiceSession in
api/controllers/security.ts, the same rule a lockdown uses): database
hosts, CI runners and agents.
RouteEndsTo end service sessions too
DELETE /security/sessions ("sign out everywhere else")every other person sessionincludeServices: true in the body, or ?includeServices=1. The audit detail records includeServices.
POST /security/password/resetevery person session; revoke reason password-reset (it was user)includeServices: true in the body
POST /admin/users/:id/signout, PUT /admin/users/:id/lock (staff)every person session; reason admin, revokedBy the adminincludeServices: true (default false)
A behaviour policy action that revokes the owner's sessionsevery person sessionnever; it uses the default
POST /security/lockdownevery sessionincludeServices: true
Revoking a delegated MCP token by its session row (DELETE /security/sessions/:id, and every other revoke path) appends its dt_… id
to the revocation feed as { kind: "session", ref: "dt_…" }, as ks_…
sessions already were.
For the device protocol itself (enrolment, pairing, suspension, wipe), see
klock.

GET /me/capabilities#

Any caller can ask what it holds: a bearer, a klock session, an API key, or
nobody. ?team=<uuid|slug|id> resolves the answer in that team's context,
and answers 404 team_not_found for a team the caller is not an active
member of. The response is Cache-Control: private, no-store.
{
  "tier": "team",
  "caps": ["access-rule:read", "…sorted"],
  "dormant": [],                        // admin:* awaiting a step-up
  "teamRole": "developer",              // null without a team context
  "teams": [{ "uuid": "…", "slug": "acme", "name": "Acme", "role": "developer", "caps": ["…"] }],
  "admin": null,                        // { type, scopes } for staff
  "plan": { "name": "usage", "entitlements": { "add": [], "remove": [], "limits": {}, "files": {} } },
  "limits": { "byKind": { "interactive": { "…": "…" } } },
  "session": { "kind": "interactive", "binding": "device", "stepUpAt": null, "checkInBy": 1727343600, "deviceId": "dev_…" },
  "source": "klock",                    // klock | bearer | apikey | guest
  "capabilitiesVersion": 1
}
A guest gets the public set with source: 'guest'. An API key gets its
capabilities and its resourceLock. A signed-in bearer whose capabilities
cannot be resolved gets 503 capabilities_unavailable, rather than a guess.
For a klock session with ?team=, the answer is still limited by the grant.

The same list in code#

ts-prorm-orm/capabilities is pure, so the same checks can run anywhere:
import {
  resolveCapabilities,
  resolveResourceCaps,
  effectiveCaps,
  satisfies,
  unlockHint,
  roleCan,
  type PrincipalFacts,
} from 'ts-prorm-orm/capabilities';

const ada: PrincipalFacts = {
  user: {
    uuid: 'u-ada',
    accountRole: 'basic',
    plan: 'free',
    mfaEnrolled: false,
    teams: [{ uuid: 't-acme', role: 'analyst', state: 'active' }],
  },
};

const now = Math.floor(Date.now() / 1000);
const resolved = resolveCapabilities(ada, { kind: 'interactive', binding: 'device', teamUuid: 't-acme', now });
console.log(resolved.tier); // 'team'

// A database the team owns: Ada reaches it through her role.
const access = resolveResourceCaps({ kind: 'team', teamId: 't-acme' }, ada);
const effective = effectiveCaps(resolved.caps, access?.caps ?? null);

console.log(satisfies('data:read', effective)); // true
console.log(satisfies('data:write', effective)); // false: an analyst reads only
console.log(roleCan('analyst', 'data:write')); // false
console.log(unlockHint('files:send', resolved)); // 'upgrade': the free plan removes it

The CLI#

The CLI shows only what the viewer can use, and says what would unlock the
rest.
[!IMPORTANT]
Nothing in the CLI is a security boundary. Help, completion and the guard
read the grant without verifying it, only to decide what to list. The
API enforces every capability on every request.
What each command needs comes from src/cli/core/command-needs.ts,
which register() applies when a command does not set needs itself.
Local commands (db init, schema …, new, config …, login,
whoami, step-up, mcp) need local:use and are never gated: they run
without reading the config or touching the network.
Visibility. A command is always shown, shown when-permitted, or
secret. A command whose needs name an admin:* capability is secret. To
a non-admin, a secret command looks exactly like an unknown one: it is
missing from help, suggestions and completion, and prorm help admin …
prints the top-level help. A group whose commands are all locked gets one
line in help, such as sign in to unlock (prorm login). Staff groups print
nothing.
The view. For help and completion the CLI uses an offline view: the
session grant is decoded without verification (it only decides what to
list), a legacy token uses the cached /me/capabilities, and nobody
signed in is a guest. Before a platform command runs, it uses the verified
klock session, or /me/capabilities for a legacy token (cached for an
hour), or the guest view.
The guard's verdicts. login exits with EXIT.AUTH and
Sign in to use `prorm <cmd>`: prorm login. step-up prompts on a
terminal and continues. sync runs prorm klock sync and continues.
upgrade and team-role exit with a hint. When the server answers
step_up_required, the CLI offers a step-up and retries once. A
capability_missing answer prints the unlock hint. With --json, the
error is { "error", "needs", "unlock" }.
Seeing your capabilities: prorm whoami --caps (and --limits,
--json).
Completion is dynamic. The shell scripts call prorm __complete, which
prints the permitted next words from the offline view.
A developer on the payments team. The ceiling lists every resource
capability, because Ada owns her own databases. On a database the team owns,
the role decides, so the API refuses the delete, in every enforcement mode:
$ prorm whoami --caps --team payments
ada <ada@example.com>
  tier        team — payments as developer · plan usage
  session     interactive · device-bound · dev_Q4M8… · key in the OS keychain
  check in    by 28/09/2026, 11:00:00 (in 58m)
  expires     29/09/2026, 10:00:00
  klock       active · ~/.prorm/klock/default.klock
  teams       payments (developer)
Capabilities:
  public      catalog:read, docs:read, local:use, reference:read, scaffold:use
  self        access-rule:read, access-rule:write, account:read, account:write, behaviour:read, behaviour:write, device:manage, device:read, files:receive, files:send, klock:sync, mcp:clients, session:manage, session:read, team:create
  resource    access:read, access:write, audit:read, billing:manage, billing:read, chat:manage, data:read, data:write, kerberos:manage, key:read, key:write, migration:apply, migration:write, project:read, project:write, resource:delete, resource:operate, resource:provision, resource:read, sso:manage, team:manage-members, team:read
API https://api.prod-orm.io
$ curl -s -X DELETE "$PRORM_API_URL/provision/databases/118" \
    -H "Authorization: Bearer $TOKEN" -H 'x-prorm-team: payments'
{"error":"capability_missing","message":"Your role on this team (developer) cannot do that","needs":"resource:delete","unlock":"team-role"}
When a CLI command gets that answer, it prints the message and the hint for
the unlock value (here, Ask a team owner or admin for a role that allows it.) and exits with code 3 (EXIT.AUTH). With --json, it prints
{ "error", "needs", "unlock" }.
For the commands themselves, see the CLI guide.

MCP#

Every MCP account tool in src/mcp/registry.ts declares needs (an array is
any-of), and may be marked destructive or stepUp. The catalogue tools need
catalog:read, and prorm_run_query needs ['data:read', 'data:write']. The
API re-checks every call, so needs controls what is listed, never what is
allowed.
Both MCP servers filter tools/list and prompts/list by the verified
caller:
The remote Worker (mcp.prod-orm.io) identifies the caller from the
Authorization header. A klock grant plus its RFC 9421 signature is
verified offline (keyset, device signature, revocation feed), and past
checkInBy only the public set is listed. A delegated token
(Bearer prorm_dt_…) is listed from GET /security/mcp/capabilities. Any
other bearer is listed from GET /me/capabilities. No credential is a
guest: the docs, reference and scaffold tools and every prompt, all of which
need only capabilities in the guest set.
The local server (prorm mcp) uses the CLI's own session the same way:
the verified grant, /me/capabilities for a legacy token (cached an hour),
the delegated token's capabilities, or the guest set. It re-reads the view
every 60 seconds.
The rules both follow:
A tool the caller may not use is treated as a tool that does not exist:
both answer JSON-RPC -32602 "No such tool: <name>".
Staff tools are read-only, need step-up, and are listed only to klock
sessions, never to a bearer or delegated token. Nobody gets mutating
admin tools over MCP.
A stepUp tool with a dormant capability is listed, but answers
Run `prorm step-up`, then retry.
A destructive tool answers first with a confirmation token, and runs only
when called again with it.
prorm mcp --caps a,b [--hours N] runs on a child delegated token minted
from your session. It refuses every capability the delegated kind mask
removes (*, admin:*, session:manage, device:manage, the team
administration capabilities and the rest).
See the MCP guide.

Regenerating these tables#

The tables above were generated from src/capabilities.ts, not typed by hand.
To check them after a change to the module, resolve a few principals and print
the results. For example, with Bun from the repository root:
import * as C from './src/capabilities';

const now = Math.floor(Date.now() / 1000);
const user = { uuid: 'u', accountRole: 'basic' as const, plan: 'usage', mfaEnrolled: true, teams: [] };
for (const kind of ['interactive', 'delegated', 'service', 'guest'] as const) {
  const r = C.resolveCapabilities({ user: kind === 'guest' ? null : user }, { kind, binding: 'device', now });
  console.log(kind, r.tier, r.caps.length, r.caps.join(' '));
}
for (const cap of C.ALL_CAPABILITIES) {
  console.log(cap, C.TEAM_ROLES.filter((role) => C.roleCan(role, cap)).join(','));
}
The API keeps a snapshot of these constants, and
api/tests/capabilities-parity.test.js fails when the library it installs
disagrees. A capability change therefore needs a reviewed snapshot update in
the API.

Related reading#

klock: sessions, grants, step-up and the device key
Access rules and behaviour: denying
requests by where, when and how they arrive
CLI: prorm whoami --caps, prorm step-up and prorm admin
MCP: per-principal tools and delegated tokens
Deploying klock: the enforcement rollout
Modified at 2026-10-04 00:40:16
Previous
Caching
Next
CLI
Built with