Service accounts (Cloud)
Cloud. A service account is a non-human identity of one organization, for CI pipelines or a provisioning service. It is not a member of the organization. Its role and permissions come only from the account itself.
Create an account and a token
Section titled “Create an account and a token”Org admins manage accounts from a dashboard session (a token can never manage accounts or tokens):
POST /v1/organizations/{org}/service-accounts{ "name": "ci-prod", "role": "developer", "scopes": ["projects:read", "db:migrate"], "projects": ["shop"], "ip_allow": ["203.0.113.0/24"] }
POST /v1/organizations/{org}/service-accounts/{id}/tokens{ "expires_in_days": 30 }The token (pb_sa_…) is returned once. Only its hash and its prefix are stored, and logs and the audit log only show the prefix. Every token expires, after at most 90 days. An account can hold two active tokens at a time: create the new one, switch your pipeline over, then revoke the old one with DELETE …/tokens/{token}.
What an account may do
Section titled “What an account may do”| Scope | Allows |
|---|---|
projects:read |
list and read the projects of its organization |
projects:create |
create projects in its organization, with an optional bootstrap |
projects:delete |
delete a project; the request must also pass ?confirm=<ref> and is audited at high severity |
config:write |
set and rotate trusted third-party issuers (JWKS) |
db:migrate |
apply migrations through the API |
db:schemas |
install / detach / purge app schemas |
db:roles |
create and delete app roles |
database:read |
read database metadata |
Every route has to allow service accounts explicitly; anything else is refused with 403, reads included, whatever the scopes. That includes:
- members, invitations and roles of the organization;
- personal access tokens;
- other service accounts;
- API keys;
- the SQL editor.
projects restricts an account to the listed projects; [] means every project of the organization. A restricted account cannot create projects. Its role (developer or admin) applies in its own organization only. An admin account may also use the owner-level routes that provisioning needs:
- app schemas;
- app roles;
- third-party auth.
An account never gets owner rights, and it can never loosen the guardrails that apply to it. These are for people only (a dashboard session or a personal access token), whatever the account’s scopes:
- the migrations policy gate (
PATCH …/config/migrations; accounts may read it); - network access to the database (
config/db); - rate limits (
config/rate-limits); - end-user auth settings (
config/auth); - Data API settings (
PATCH …/config/data-api). An account exposes a schema through app schemas, or sets the initial values in a bootstrap.
Create a project with bootstrap
Section titled “Create a project with bootstrap”An account with projects:create, or a person, can set up a new project in one request (Cloud). It creates the app roles and app schemas, trusts third-party issuers and sets the Data API, as soon as the project database is ready:
POST /v1/projectsIdempotency-Key: tenant-acme-1{ "organization_id": "<org uuid>", "name": "Acme", "ref": "acme", "bootstrap": { "app_roles": ["app_crm"], "app_schemas": [{ "name": "app_shop", "expose": true }], "third_party_auth": [{ "id": "clerk", "name": "Clerk", "issuer": "https://clerk.acme.example", "jwks_url": "https://clerk.acme.example/.well-known/jwks.json", "audience": ["acme"], "role_claim": "org_role", "role_map": { "member": "app_crm" } }], "data_api": { "db_max_rows": 500 } }}-
Same permissions as the routes. Each kind of step needs what its own route needs, or the request is refused with
403and nothing is created:Step Service account Personal access token Role app_rolesdb:rolesdatabase:writeowner (an account: admin)app_schemasdb:schemasdatabase:writeowner (an account: admin)third_party_authconfig:writeprojects:writeowner (an account: admin)data_apidb:schemasprojects:writedeveloper (an account: admin) -
Checked before anything is created. The request is refused with nothing created when the bootstrap is invalid:
- a malformed field;
- a
jwks_urlthat is not https or points to a non-public address; - a
role_mapthat names an app role the bootstrap does not create (422 unknown_app_role); - invalid Data API settings.
-
Idempotency-Keyis required with a bootstrap (400 idempotency_key_required). Sending the same key and body again within 24 hours returns the same project, with the headeridempotent-replayed: true. Another body with the same key is refused with422 idempotency_key_reused. -
Order: the steps run in this order, each once: app roles, app schemas, third-party issuers, Data API. An explicit
data_api.db_schemaskeeps the app schemas the bootstrap exposes. Each step uses the same checks as its own route. -
Wait for
active. The project is not served (Data API, auth, storage, realtime) until every step is done.GET /v1/projects/{ref}and the project list readprovisioninguntil then. Thebootstrapfield showssteps,steps_done,failed_stepanderror. Steps start as soon as the database exists, so a new project usually becomesactivewithin a few seconds (Cloud). A bootstrap with no steps is done at once. Poll every 250–500 ms rather than every few seconds. -
Failure and retry. When a step fails, the project reads
bootstrap_failedandbootstrap.failed_stepnames it, for exampleapp_schemas:app_shop. The project is still not served. Fix the cause, then send the same request with the sameIdempotency-Keyagain. Your permissions are checked again, then the bootstrap resumes from the failed step. Steps already done are skipped, unless their result is gone (for example a dropped schema), in which case they run again. -
Audit: the outcome is recorded as
project.bootstrappedorproject.bootstrap_failedat high severity, under the account (sa:<id>) or person that created the project.
Security
Section titled “Security”- IP allowlist:
ip_allowlimits where a token may be used;[]means any address. IPv4 clients also match IPv4-mapped IPv6 entries. The client address only honoursX-Forwarded-Forfrom proxies configured as trusted (BASE_TRUST_PROXY), and a warning is logged when such headers arrive without that setting. - Disable and delete take effect at once: disabling an account (
PATCH … { "disabled": true }) or deleting it refuses all of its tokens immediately. - Rate limit: 600 requests per minute per account, counted across all servers.
- Audit: every request of an account, reads included, is in the audit log as
sa:<id>, with its IP and token prefix. Refused attempts are audited asauth.service_account_denied, at most once per minute and reason: wrong address, rate limited, or a revoked, expired or wrong token of a known account. The last use of each token (time and IP) is shown in the token list. - Migrations: migrations sent by a service account run with the policy gate at
errorby default: a migration that opens data is rolled back. Only the project owner can change the gate. A service account cannot acknowledge findings:policy_ackin the body or a-- policy-ack:line in the SQL is refused with403 policy_ack_not_allowed. A person applies acknowledged migrations. - Third-party issuers:
jwks_urlmust use https, including after redirects. Private, loopback, link-local and cloud metadata addresses are refused at every hop, after DNS resolution. Setting or removing an issuer is audited at high severity.