# Permissions (/docs/reference/permissions)



Access is a set of **permissions** — `decision.edit`, `decision.publish`, `decision.deploy`,
`deploy.protected`, `review.approve`, `table.publish`, `execution.read`, `delivery.retry`,
`audit.read`, `member.manage`, … — `PROJECT_PERMISSIONS` in `core`.

## The levels at a glance [#the-levels-at-a-glance]

<Diagram node="access-levels" kind="example" />

* **Which levels are there?** Three: **platform** (the installation and its `/admin` area),
  **workspace** (a tenant: its members, SSO, SCIM and logs) and **project** (where decisions,
  tables and executions live). Each has its own list of permissions.
* **How do I get access at a level?** By belonging to it: a platform role, a workspace membership
  or a project membership. An API key carries its own project instead.
* **Does one level include another?** No. A workspace owner who is not in a project cannot open
  it, and a platform administrator sees no tenant content. Levels are checked separately.
* **What is a role?** A named bundle of permissions. The built-in roles are fixed; in a project
  you can also define custom roles.

## Workspace and project roles [#workspace-and-project-roles]

Roles exist at two levels, and they answer different questions. They are **not** the same role at two
granularities, and neither is inherited from the other.

* A **workspace role** (`owner`/`admin`/`member`) shapes the tenant itself: create projects, manage
  who belongs to the workspace and with what role, define the set of custom roles available,
  configure single sign-on and SCIM, and rename, archive or delete the workspace. It is a bundle of
  **workspace permissions** (`WORKSPACE_PERMISSIONS`: `workspace.read`, `workspace.manage`,
  `workspace.member.manage`, `workspace.project.create`, `workspace.role.manage`,
  `workspace.sso.manage`, `workspace.scim.manage`, `workspace.logs.manage`): a `member` holds
  `workspace.read`; `admin` and `owner` hold all of them.
* A **project role** (`owner`/`admin`/`editor`/`viewer`, or a custom role) is what someone may do
  inside one project: decisions, tables, datasets, constants, executions, cases, the audit log,
  project members and invitations. This is the level that carries `PROJECT_PERMISSIONS`.

| Concern                                                    | Level     |
| ---------------------------------------------------------- | --------- |
| Create, rename, archive or delete a workspace              | Workspace |
| Add, change or remove workspace members                    | Workspace |
| Define custom roles (the permission sets)                  | Workspace |
| Single sign-on, SCIM tokens and group mappings             | Workspace |
| Create a project; list the projects you belong to          | Workspace |
| Read, edit, publish, deploy decisions and tables           | Project   |
| Executions, cases, audit log, project members, invitations | Project   |
| Grants and restricted access on a single decision          | Project   |

**A workspace role grants no project access.** Access is membership, nothing else: a workspace admin
who is not a member of a project is turned away exactly like anyone else, and a project owner works
inside their project without any workspace elevation (they still need to be a workspace member to
list projects). Project access is opt-in — a workspace member only sees the projects they belong to.

A few consequences worth knowing:

* Creating a project makes **only its creator** the project owner; no other workspace admin is added.
* An **invitation grants both**: a workspace membership with the fixed role `member` (you cannot
  invite your way into workspace administration) and the project membership with the invited role.
* **Single sign-on and SCIM** provision a workspace membership as `member`; SCIM group mappings also
  grant project roles (and custom roles).
* **Custom roles are defined per workspace** (by a workspace admin) but **assigned per project
  membership**, which is why they live at the workspace level yet take effect in one project.

## Built-in roles [#built-in-roles]

The built-in roles are fixed sets:

| Role       | What it can do                                                                                       |
| ---------- | ---------------------------------------------------------------------------------------------------- |
| **viewer** | Reads the project, its executions and its cases.                                                     |
| **editor** | Builds, publishes, deploys to unprotected environments, approves publish requests and manages cases. |
| **admin**  | Everything in `editor`, plus members, integrations, environments, API keys and governance.           |
| **owner**  | The same permissions as `admin`; a project always keeps at least one owner.                          |

In permission terms (`BUILT_IN_ROLE_PERMISSIONS` in `core`):

* **viewer** — `execution.read`, `case.read`.
* **editor** — everything a viewer has, plus `decision.edit`, `decision.simulate`, `decision.publish`,
  `decision.deploy`, `review.approve`, `table.edit`, `table.publish`, `dataset.edit`, `globals.edit`,
  `assistant.use`, `delivery.read`, `case.manage`.
* **admin** and **owner** — every `PROJECT_PERMISSIONS` entry.

`admin` and `owner` keep their permissions even when a custom role would override them. The console
shows the same thing: each built-in role's permissions, and every member's effective set, under
**Settings → Members**.

## Custom roles [#custom-roles]

A workspace admin can define **custom roles** (**Settings → Members**) — an author who cannot
publish, an approver who cannot edit, an operator who only retries deliveries — and assign one to
any project membership. The custom role **replaces** the built-in role's permissions, except for
admins and owners, who always keep theirs.

A role change applies on the next request, everywhere.

## Per-decision access [#per-decision-access]

A decision can also carry its own access (**Access**, on the decision):

* **Grants** add decision permissions (edit, simulate, publish, deploy, approve) to one member.
* **Restricted** — when on, the decision ignores the project role's decision permissions
  altogether, so only the people granted on it — and project admins — can change it. Everyone in
  the project can still read it.

## One model, three scopes [#one-model-three-scopes]

Platform, workspace and project are scopes of the same model: each has a catalog of permissions,
roles are named bundles of them, and the question "may they?" is always `can(grants, permission)` in
`@decision-control/core`. Scopes never inherit from each other.

| Scope     | Proved by                                         | Catalog                                       |
| --------- | ------------------------------------------------- | --------------------------------------------- |
| Platform  | The user's platform role                          | `PLATFORM_PERMISSIONS`                        |
| Workspace | Membership of the workspace                       | `WORKSPACE_PERMISSIONS`                       |
| Project   | Membership of the project, or an API key's scopes | `PROJECT_PERMISSIONS` (+ per-decision grants) |

## How a request is checked [#how-a-request-is-checked]

<Diagram node="access-check" kind="example" />

1. **Find the policy.** Every guarded route is listed in one table. A route with no policy is
   closed, for every method.
2. **Prove the scope.** The policy says which level answers. The caller must belong to it, or the
   request is refused with `NOT_A_MEMBER` (platform: `You are not a platform administrator`).
3. **Check the permission.** The permission the route needs must be among those the level grants
   the caller, or the request is refused with `FORBIDDEN` naming the permission. On a decision,
   its grants and restriction adjust the project permissions first.

* **What if a route needs no permission?** Its policy says so explicitly (`null`): membership, or a
  signed-in session, is enough.
* **What can an API key do?** It resolves to project permissions from its scopes, never to
  administration, and it cannot reach workspace or platform routes.
* **When does a change apply?** On the next request: roles are read per request (with a short
  cache that a change invalidates).

## Matrix [#matrix]

Generated from the catalog and the access table, so it cannot drift from the code. A permission with 0 routes is checked inside the handler instead, against the thing it acts on (`deploy.protected` against the target environment).

{/* permission-matrix:start (generated: bun run access:matrix) */}

### Platform [#platform]

| Permission                      | Built-in roles | Routes |
| ------------------------------- | -------------- | ------ |
| `platform.overview.read`        | SUPPORT, ADMIN | 2      |
| `platform.observability.read`   | SUPPORT, ADMIN | 11     |
| `platform.logs.read`            | SUPPORT, ADMIN | 8      |
| `platform.logs.manage`          | ADMIN          | 2      |
| `platform.workers.manage`       | ADMIN          | 9      |
| `platform.sessions.read`        | SUPPORT, ADMIN | 2      |
| `platform.sessions.revoke`      | SUPPORT, ADMIN | 2      |
| `platform.security.read`        | SUPPORT, ADMIN | 4      |
| `platform.outbox.manage`        | ADMIN          | 0      |
| `platform.jobs.read`            | SUPPORT, ADMIN | 0      |
| `platform.jobs.manage`          | ADMIN          | 0      |
| `platform.catalog.read`         | SUPPORT, ADMIN | 0      |
| `platform.announcements.read`   | SUPPORT, ADMIN | 2      |
| `platform.announcements.manage` | ADMIN          | 4      |
| `platform.invitations.read`     | SUPPORT, ADMIN | 2      |
| `platform.invitations.manage`   | ADMIN          | 2      |
| `platform.config.manage`        | ADMIN          | 2      |
| `platform.limits.read`          | SUPPORT, ADMIN | 3      |
| `platform.limits.manage`        | ADMIN          | 3      |
| `user.read`                     | SUPPORT, ADMIN | 7      |
| `user.manage`                   | ADMIN          | 5      |
| `session.revoke`                | SUPPORT, ADMIN | 2      |
| `platform.workspace.read`       | SUPPORT, ADMIN | 12     |
| `platform.workspace.manage`     | ADMIN          | 7      |
| `platform.project.read`         | SUPPORT, ADMIN | 19     |
| `platform.project.manage`       | ADMIN          | 7      |
| `execution.read.all`            | SUPPORT, ADMIN | 5      |
| `audit.read.all`                | SUPPORT, ADMIN | 7      |

Open to any member of the scope (no permission): 0 routes.

### Workspace [#workspace]

| Permission                 | Built-in roles       | Routes |
| -------------------------- | -------------------- | ------ |
| `workspace.read`           | MEMBER, ADMIN, OWNER | 3      |
| `workspace.manage`         | ADMIN, OWNER         | 5      |
| `workspace.member.manage`  | ADMIN, OWNER         | 2      |
| `workspace.project.create` | ADMIN, OWNER         | 1      |
| `workspace.role.manage`    | ADMIN, OWNER         | 3      |
| `workspace.sso.manage`     | ADMIN, OWNER         | 4      |
| `workspace.scim.manage`    | ADMIN, OWNER         | 5      |
| `workspace.logs.manage`    | ADMIN, OWNER         | 6      |

Open to any member of the scope (no permission): 4 routes.

### Project [#project]

| Permission           | Built-in roles               | Routes |
| -------------------- | ---------------------------- | ------ |
| `decision.edit`      | EDITOR, ADMIN, OWNER         | 14     |
| `decision.simulate`  | EDITOR, ADMIN, OWNER         | 4      |
| `decision.publish`   | EDITOR, ADMIN, OWNER         | 5      |
| `decision.deploy`    | EDITOR, ADMIN, OWNER         | 5      |
| `deploy.protected`   | ADMIN, OWNER                 | 0      |
| `review.approve`     | EDITOR, ADMIN, OWNER         | 2      |
| `table.edit`         | EDITOR, ADMIN, OWNER         | 8      |
| `table.publish`      | EDITOR, ADMIN, OWNER         | 1      |
| `dataset.edit`       | EDITOR, ADMIN, OWNER         | 4      |
| `globals.edit`       | EDITOR, ADMIN, OWNER         | 3      |
| `assistant.use`      | EDITOR, ADMIN, OWNER         | 11     |
| `execution.read`     | VIEWER, EDITOR, ADMIN, OWNER | 11     |
| `delivery.read`      | EDITOR, ADMIN, OWNER         | 4      |
| `delivery.retry`     | ADMIN, OWNER                 | 3      |
| `audit.read`         | ADMIN, OWNER                 | 5      |
| `case.read`          | VIEWER, EDITOR, ADMIN, OWNER | 8      |
| `case.manage`        | EDITOR, ADMIN, OWNER         | 16     |
| `case.configure`     | ADMIN, OWNER                 | 4      |
| `environment.manage` | ADMIN, OWNER                 | 3      |
| `integration.manage` | ADMIN, OWNER                 | 30     |
| `schedule.manage`    | ADMIN, OWNER                 | 13     |
| `apikey.manage`      | ADMIN, OWNER                 | 4      |
| `member.manage`      | ADMIN, OWNER                 | 6      |
| `project.manage`     | ADMIN, OWNER                 | 8      |

Open to any member of the scope (no permission): 43 routes.

{/* permission-matrix:end */}

## Routing [#routing]

Every guarded route is mapped to the scope and permission it needs, by route pattern, in one table
(`apps/api/src/access/policies`), enforced by a single middleware (`authorize`). A route the table
does not list is closed for every method, and a test fails with its name. Routes outside the table
(sign-in, SCIM, the machine surface behind an API key, the public form) are listed in that test
with the reason.

Reading the project's API keys needs `apikey.manage`, and its webhooks `integration.manage`: a
viewer or editor no longer lists them.

Someone who manages members without being an admin cannot hand out more than they hold: no admin
or owner roles, no custom role with permissions they lack, no changes to themselves.

`/auth/me` returns the caller's permissions in every scope — `user.platform_permissions`, each
workspace's `permissions` and each project's `permissions` — and a decision's detail returns the
caller's permissions on it, so the console only offers what will work (`useCan()`).
