> ## Documentation Index
> Fetch the complete documentation index at: https://docs.formal.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Permissions

> How to configure user permissions for Formal applications (Control Plane)

> [!WARNING]
>
> This page covers **Control Plane permissions** - policies that control access
> to Formal's web interface and APIs. For policies that control data access
> through Connectors (like database query policies), see the
> [Policies](https://docs.formal.ai/docs/guides/policies/introduction.md) section.

## Introduction

Formal's permission system is built on the [Open Policy Agent (OPA)](https://www.openpolicyagent.org/), allowing you to restrict user access to specific applications through Rego policies. By defining granular permissions, you can ensure users have access only to the applications necessary for their roles and responsibilities. These permissions are enforced against our [API endpoints](https://docs.formal.ai/docs/api/introduction.md).

## Default permissions

Upon account creation, Formal operates under an allow-by-default model. Meaning, by default, if no permission blocks an endpoint for a given user, then the endpoint is allowed.

> [!WARNING]
>
> A Permission that leaves `allow` undefined doesn't apply to the request. A
> Permission that can't be evaluated blocks the request with an error: its
> code fails to compile, `allow` is both `true` and `false`, a built-in
> function errors, `allow` isn't a boolean, or evaluation takes longer than
> 200ms. Code that fails to compile never blocks the Permissions API, so you
> can still fix or delete it.
>
> * Set `default allow` in every Permission.
> * Don't make `allow` both `true` and `false` in one Permission. When both rules match, evaluation fails and the request is blocked.
> * Check input names against the [list of inputs](#list-of-inputs). A rule that misspells one never matches.

## Permission actions

A Permission can block a request with an `allow` rule, or rewrite its response with a `response` rule. `allow` runs before the API handles the request. `response` runs after, only for requests that `allow` lets through.

### Rewrite responses

A `response` rule replaces the response a user receives. Use it to hide list items, drop fields, or redact values. It has the same shape as the [rewrite action of policies](https://docs.formal.ai/docs/guides/policies/enforcement.md#rewrite-action).

```Rego theme={"languages":{"custom":["/languages/cel.json","/languages/rego.json"]}}
package formal.app

import future.keywords.if
import future.keywords.in

response := {
  "action": "rewrite",
  "json": object.union(input.response.json, {
    "resources": [r | some r in input.response.json.resources; keep_resource(r)],
  }),
} if {
  input.app.command.name == "ListResources"
  not "admin" in input.user.groups
}

keep_resource(resource) if resource.environment == "production"

keep_resource(resource) if resource.spaceId == "<SPACE_ID>"
```

Users outside `admin` see only production resources and resources in one Space. The rule body decides when the rewrite applies, and `keep_resource` decides which items stay. Each `keep_resource` body is another way to keep an item.

`json` is the whole replacement response, so start from `input.response.json` with `object.union` to keep the other fields. `input.response.json` uses the same camelCase field names as `input.args`.

If a rewrite fails, the API returns an error instead of the original response. A rewrite fails when the rule errors, returns an action other than `rewrite`, or returns `json` that doesn't match the response's fields. It also fails when two Permissions rewrite the same response, so scope each `response` rule to the commands it's for.

A filtered page can hold fewer items than `limit`, or none. `listMetadata.nextCursor` is unchanged, so keep requesting pages until it's empty.

Rewrites apply only to unary API calls, and never to the **Permissions** application, so a broken rule can't lock you out of fixing it. Rules can't read fields the API marks sensitive, such as generated keys. Formal restores those fields after the rewrite, except inside list items. Totals such as `technologySummaries` still count hidden items. Hiding an item from a `List` command doesn't hide it from `Get`, so add a rule for that command too.

## Permission Model

Unlike other software products, Formal does not have the traditional concept of Roles. Instead, users can leverage Permissions to create role based access control (RBAC) using your organization's Groups (which can be SCIM provisioned from your IDP into Formal).

## User experience when blocked

The Formal APIs will return HTTP 403 error status codes if a user is blocked on a particular endpoint. Users who are interacting with the Formal APIs through the Control Plane will experience "Forbidden" toasts or dialogs.

![](https://mintcdn.com/formal/z9GNtynV1YHUDYCN/assets/images/forbidden.png?fit=max\&auto=format\&n=z9GNtynV1YHUDYCN\&q=85\&s=b81e439d98496c239efa9f14433cdc56)

## List of inputs

You can block or allow requests based on the following user and application inputs:

### User inputs

* `input.user.id`
* `input.user.name`
* `input.user.email`
* `input.user.groups`
* `input.user.ip_address`
* `input.user.type` (i.e. `human` or `machine`)
* `input.user.auth_method` — how the request authenticated: `browser_session`, `api_key`, `oidc`, `formal_sig`, or `oauth`
* `input.user.oauth` — the OAuth client acting for the user, present only when `auth_method` is `oauth`. See [OAuth clients](#oauth-clients).

#### OAuth clients

An MCP client that connects to [Formal MCP](https://docs.formal.ai/docs/api/mcp-server.md) with OAuth
calls the API as the user who approved it. Those calls carry `input.user.oauth`:

| Value | Description |
| - | - |
| `input.user.oauth.client.id` | The client's metadata document URL, or the ID of a client pre-registered in Formal. |
| `input.user.oauth.client.name` | The client's display name. A `cimd` client chooses its own, so match on `id` or `type` instead. |
| `input.user.oauth.client.type` | `cimd` for a client identified by its metadata document URL, `pre_registered` for a client pre-registered in Formal. |
| `input.user.oauth.consent_id` | The ID of the user's approval of this client. |
| `input.user.oauth.scopes` | The apps the client may reach, one scope each, named after `input.app.name`: `Policies:read`, or `Policies:write` to call its write commands as well. |

An OAuth client reaches only the apps its scopes name, whatever Permissions
allow, and only their read commands unless its scope for the app is write.
Some writes stay out of its reach under any scope, as
[Formal MCP access](https://docs.formal.ai/docs/api/mcp-server.md#access-per-app) lists. Permissions
apply on top. See
[Keep MCP clients from deleting policies](#example-keep-mcp-clients-from-deleting-policies).

### Application inputs

* `input.app.name`
* `input.app.command.name`
* `input.app.command.type`

The permissions system also supports blocking or allowing requests based on the request payload for any API call based on input arguments (`input.args`).

Argument keys use the API's JSON field names in camelCase, such as `input.args.spaceId` and `input.args.connectorId`.

### Response inputs

* `input.response.json` — the API's response, in the same JSON encoding as `input.args`. Set only while a [`response` rule](#rewrite-responses) evaluates.

### Target inputs

`input.targets` lists every [Space](https://docs.formal.ai/docs/guides/core-concepts/spaces.md), resource, connector, or satellite a resource, connector, or native user API request names, and every object under one:

* the resource, connector, or child object it reads, updates, or deletes, for example `DeleteResource` or `UpdateConnectorListener`
* the parent of an object it creates or lists, for example `CreateNativeUserV3` and `ListResourceHostnames` name their resource
* the object a link joins, for example `CreateConnectorSatelliteLink` names the connector and the satellite
* the Space it assigns, for example `spaceId` on `CreateResource`, `UpdateResource`, `CreateConnector`, `UpdateConnector`, `ListResources`, and `ListConnectors`

Each target has:

* `type` — for example `resource`, `native_user_v3`, `connector_listener`, or `space`
* `id` — the ID from the request
* `space_id` — the Space of the object, or of the resource or connector it belongs to. Empty when the object has no Space or does not exist.
* `resource_id` — the resource the object is or belongs to, for example a native user's resource. Absent for connectors and their objects.
* `connector_id` — the connector the object is or belongs to, for example a listener rule's connector. Absent for resources and their objects.

For example, this request moves a connector to another Space:

```bash theme={"languages":{"custom":["/languages/cel.json","/languages/rego.json"]}}
curl -X POST https://api.formal.ai/core.v1.ConnectorService/UpdateConnector \
  -H "X-Api-Key: <YOUR_API_KEY>" \
  -H "Content-Type: application/json" \
  -d '{"id": "connector_01k9t3c2r5t8y1u4i7o3p6a9s2", "spaceId": "space_01k9t3b7x4c9v2b6n1m8q5w3e7"}'
```

The permission sees the connector from `id`, with its current Space, and the new Space from `spaceId`:

```json theme={"languages":{"custom":["/languages/cel.json","/languages/rego.json"]}}
{
  "targets": [
    { "type": "connector", "id": "connector_01k9t3c2r5t8y1u4i7o3p6a9s2", "space_id": "space_01k9t3a5s8d2f6g1h4j7k3l9z0", "connector_id": "connector_01k9t3c2r5t8y1u4i7o3p6a9s2" },
    { "type": "space", "id": "space_01k9t3b7x4c9v2b6n1m8q5w3e7", "space_id": "space_01k9t3b7x4c9v2b6n1m8q5w3e7" }
  ]
}
```

`input.targets` is absent when the request names none of these objects, for example `ListUsers`, `GetPolicy`, or `ListLogs`. It is also absent for other APIs, such as `UpdateSatelliteV2` or `UpdateSpaceV2`, even when their request includes a Space.

#### List of command types

Here is a table listing all command types that can be used. If the API call contains the operation, then it is categorized as the corresponding type.

| Type | Operations |
| - | - |
| read | `Get`, `List` |
| create | `Create` |
| update | `Update` |
| delete | `Delete` |
| login | `Login` |

#### List of applications

API endpoints are segmented into **Applications.**

Here is a table listing all applications that can be configured for access permissions:

> [accordion] Public API
>
> These applications have [public API endpoints](https://docs.formal.ai/api-reference) accessible via API keys or the Control Plane.
>
> | Name | Description |
> | - | - |
> | [AIAssessment](https://docs.formal.ai/api-reference/corev1aiassessmentservice) | Enable assessments and manage their scoring criteria and labels. |
> | [Approval](https://docs.formal.ai/api-reference/corev1approvalservice) | Manage access requests and related analytics. |
> | [ChangeAuthorization](https://docs.formal.ai/api-reference/corev1changeauthorizationservice) | Manage public signing keys used to cryptographically sign and verify API changes. |
> | [Connector](https://docs.formal.ai/api-reference/corev1connectorservice) | Manage Connector proxy instances and listeners. |
> | [Dashboard](https://docs.formal.ai/api-reference/corev1dashboardservice) | Create and manage dashboards of log-backed widgets and notes. Viewing widget data also needs Logs read access. |
> | [Graph](https://docs.formal.ai/api-reference/corev1graphservice) | View Formal's data graph. |
> | [Group](https://docs.formal.ai/api-reference/corev1groupservice) | Manage user groups for role-based access control. |
> | [Hook](https://docs.formal.ai/api-reference/corev1hookservice) | Manage webhooks and event delivery settings. |
> | [Insights](https://docs.formal.ai/api-reference/corev1insightsservice) | View security findings and suggested next steps. |
> | [IntegrationAIProvider](https://docs.formal.ai/api-reference/corev1integrationaiproviderservice) | Manage AI provider integrations (Anthropic, OpenAI, Cursor). |
> | [IntegrationBI](https://docs.formal.ai/api-reference/corev1integrationbiservice) | Manage BI tool integrations (Metabase, Omni, Fivetran). |
> | [IntegrationCloud](https://docs.formal.ai/api-reference/corev1integrationcloudservice) | Manage cloud provider integrations (AWS, GCP, Azure). |
> | [IntegrationMDM](https://docs.formal.ai/api-reference/corev1integrationmdmservice) | Manage Mobile Device Management integrations. |
> | [IntegrationOIDC](https://docs.formal.ai/api-reference/corev1integrationoidcservice) | Manage OIDC trust configurations for control-plane authentication. |
> | [IntegrationSocket](https://docs.formal.ai/api-reference/corev1integrationsocketservice) | Connect your Socket organization for package firewall checks. |
> | [IntegrationsLog](https://docs.formal.ai/api-reference/corev1integrationslogservice) | Manage log forwarding (Splunk, Datadog, S3, GCS, Azure Blob). |
> | [Inventory](https://docs.formal.ai/api-reference/corev1inventoryservice) | Manage discovered schemas, tables, and columns. |
> | [LLMPricing](https://docs.formal.ai/api-reference/corev1llmpricingservice) | Manage LLM Prices used to estimate AI costs. |
> | [Logs](https://docs.formal.ai/api-reference/corev1logsservice) | View and manage audit logs and retention settings. |
> | [Mcp](https://docs.formal.ai/api-reference/corev1mcpservice) | Manage MCP servers and list observed servers that are not yet managed. |
> | [NativeUser](https://docs.formal.ai/api-reference/corev1nativeuserservice) | Manage Native Users, the credentials Connectors use for Resources. |
> | [OAuth](https://docs.formal.ai/api-reference/corev1oauthservice) | Manage OAuth clients for signing in to upstream MCP servers. |
> | [OrgTheme](https://docs.formal.ai/api-reference/corev1orgthemeservice) | Manage the organization's display name and logo shown in the employee Catalog. |
> | [Permissions](https://docs.formal.ai/api-reference/corev1permissionsservice) | Manage OPA permissions for this API. |
> | [Policies](https://docs.formal.ai/api-reference/corev1policiesservice) | Manage data access policies (masking, blocking, alerts). |
> | [PolicyDataLoader](https://docs.formal.ai/api-reference/corev1policydataloaderservice) | Manage external data loaders for policy context. |
> | [Resource](https://docs.formal.ai/api-reference/corev1resourceservice) | Manage datastores and APIs proxied by Formal. |
> | [Satellite](https://docs.formal.ai/api-reference/corev1satelliteservice) | Manage Satellite deployments for data discovery. |
> | [ScenarioMonitoring](https://docs.formal.ai/api-reference/corev1scenariomonitoringservice) | Manage real-time alerts and monitoring rules. |
> | [Search](https://docs.formal.ai/api-reference/corev1searchservice) | Search across resources, connectors, policies, and more. |
> | [Sessions](https://docs.formal.ai/api-reference/corev1sessionsservice) | View and replay user session recordings. |
> | [Skill](https://docs.formal.ai/api-reference/corev1skillservice) | Manage AI agent skills and list observed skills that are not yet managed. |
> | [Space](https://docs.formal.ai/api-reference/corev1spaceservice) | Manage Spaces for organizing resources by team or project. |
> | [User](https://docs.formal.ai/api-reference/corev1userservice) | Manage users, invitations, and account settings. |
> | [Workflow](https://docs.formal.ai/api-reference/corev1workflowservice) | Manage automated workflows across Formal. |

> [accordion] Control Plane Only
>
> These applications are only accessible through the Control Plane and do not have public API documentation.
>
> > [!NOTE]
> >
> > For Control Plane only applications, we recommend restricting access at the application level rather than by individual command types, since the available commands are not publicly documented.
>
> | Name | Description |
> | - | - |
> | Access | View and manage personal access tokens. |
> | Agent | AI-powered conversational assistant for Formal. |
> | AgentObservability | View AI usage, policy actions, and session activity. |
> | Catalog | Use the employee Catalog: browse MCP servers and skills, link upstream accounts, approve MCP clients, and request access. |
> | DSPM | Manage DSPM jobs and tasks. |
> | Desktop | Approve personal Endpoint logins. |
> | Developer | Manage developer API keys. |
> | DirectorySync | Configure SCIM directory sync with identity providers. |
> | Overview | View dashboard home page statistics. |
> | Slack | Configure Slack notifications and alerts. |
> | Sso | Configure SAML Single Sign-On. |
> | Version | View latest connector and satellite versions. |
>
> The **Catalog** application controls who can use the [employee Catalog](https://docs.formal.ai/docs/guides/ai-governance/catalog.md#the-employee-catalog). Allow the whole application rather than individual commands. Users need several commands to link accounts and approve MCP clients.
>
> ```rego theme={"languages":{"custom":["/languages/cel.json","/languages/rego.json"]}}
> allow if {
>   input.user.type == "human"
>   input.app.name == "Catalog"
> }
> ```
>
> See [Grant access to the Catalog](https://docs.formal.ai/docs/guides/core-concepts/connectors/mcp-gateway.md#grant-access-to-the-catalog).

## Example: Single Application

Below is an example of a Rego policy that grants access to the Sessions application exclusively for users in the admin group.

```Rego theme={"languages":{"custom":["/languages/cel.json","/languages/rego.json"]}}

package formal.app

import future.keywords.in
import future.keywords.if

default allow = false

allow := true if {
    input.app.name == "Sessions"
    "admin" in input.user.groups
}

```

This policy sets the default access to false, meaning no access is granted unless specified by a rule. The allow rule checks if the application requested is Sessions and if the user belongs to the admin group. If both conditions are met, access is granted.

## Example: Granular Access Control

```Rego theme={"languages":{"custom":["/languages/cel.json","/languages/rego.json"]}}
package formal.app

import future.keywords.in
import future.keywords.if

default allow = false

# Allow read access to everyone
allow if {
  input.app.command.type == "read"
}

# Allow everyone to get their own Credentials
allow if {
    input.app.name == "Access"
}

# Allow full access if the user is a member of the security team
allow if {
  "security-admins" in input.user.groups
}

# Allow engineers to access relevant applications
allow if {
  input.app.name in ["Desktop"]
  "engineers" in input.user.groups
}
```

This multi-rule policy demonstrates how to combine different access levels:

* **Broad read access**: Everyone can view most data using `read` command types.
* **Self-service access**: Everyone can manage their own credentials in the **Access** app.
* **Administrative access**: Users in `security-admins` have unrestricted access to all apps.
* **Team-specific access**: Users in the `engineers` group can access developer-focused tools.

Since `default allow = false` is set, any request that does not match at least one of these `allow` rules is blocked. Formal returns a 403 Forbidden error for these requests.

## Example: Argument-based Access Control

```Rego theme={"languages":{"custom":["/languages/cel.json","/languages/rego.json"]}}
package formal.app

import future.keywords.if

default allow = true

allow := false if {
  input.app.command.name == "UpdatePolicy"
  input.args.id == "policy_01kg6rhpe7em4rr2v0mcwm0mp4"
  not "security-admins" in input.user.groups
}
```

This policy blocks updates to the policy with the ID `policy_01kg6rhpe7em4rr2v0mcwm0mp4` unless the user is in the `security-admins` group.

## Example: Scope a machine user to one Space

Run one machine user per environment, for example one per Kubernetes cluster running the [Kubernetes operator](https://docs.formal.ai/docs/guides/core-concepts/kubernetes-operator/introduction.md). This permission only lets the machine user call APIs whose targets are all in one Space:

```Rego theme={"languages":{"custom":["/languages/cel.json","/languages/rego.json"]}}
package formal.app

import future.keywords.every
import future.keywords.if
import future.keywords.in

default allow = true

scoped_machine_user := "<MACHINE_USER_ID>"
allowed_space := "<SPACE_ID>"

# The Kubernetes operator looks up users and groups for native user identity links.
org_reads := {"User": {"ListUsers"}, "Group": {"ListGroups"}}

in_allowed_space if {
  count(input.targets) > 0
  every target in input.targets {
    target.space_id == allowed_space
  }
}

allow := false if {
  input.user.id == scoped_machine_user
  not input.app.command.name in object.get(org_reads, input.app.name, set())
  not in_allowed_space
}
```

The rule fails closed. A request with no targets is denied, so are logs, sessions, inventory, policies, permissions, and unfiltered lists. A request with any target outside the Space is denied, which covers moving an object into or out of the Space.

To scope the machine user to one connector instead, compare `target.connector_id` to the connector's ID. Resources and their objects have no `connector_id`, so that rule denies them.

The operator also reads users and groups to build native user identity links, so `org_reads` allows `ListUsers` and `ListGroups`. Remove them if the cluster does not use identity links. Manage `FormalPolicy` objects from a cluster whose machine user is not scoped, since policies have no Space.

## Example: Restrict Access to Logs

Viewing Connector, Desktop, Control Plane, and workflow logs all use the **Logs** application. There is no separate permission per log source.

```Rego theme={"languages":{"custom":["/languages/cel.json","/languages/rego.json"]}}
package formal.app

import future.keywords.in
import future.keywords.if

default allow = true

allow := false if {
  input.app.name == "Logs"
  not "security-admins" in input.user.groups
}
```

Only users in `security-admins` can open [Logs](https://app.formal.ai/logs) or call Logs APIs. For Control Plane audit fields and more permission patterns, see [Control Plane Logs](https://docs.formal.ai/docs/guides/observability/control-plane-logs.md#permissions-for-viewing-logs).

## Example: Formal MCP only for pre-registered clients

Use `input.user.oauth` to decide which MCP clients may read through
[Formal MCP](https://docs.formal.ai/docs/api/mcp-server.md). Other ways of signing in are unaffected.

```Rego theme={"languages":{"custom":["/languages/cel.json","/languages/rego.json"]}}
package formal.app

import future.keywords.if

default allow = true

allow = false if {
  input.user.auth_method == "oauth"
  input.user.oauth.client.type != "pre_registered"
}
```

## Example: Keep MCP clients from deleting policies

MCP clients you approve for write on Policies can change policies. Use
`input.user.oauth.scopes` to narrow what they can do.

```Rego theme={"languages":{"custom":["/languages/cel.json","/languages/rego.json"]}}
package formal.app

import future.keywords.if
import future.keywords.in

default allow = true

allow = false if {
  "Policies:write" in input.user.oauth.scopes
  input.app.name == "Policies"
  input.app.command.type == "delete"
}
```

MCP clients can still create and update policies, but not delete them.
People and API keys are unaffected.

## Example: Show users only their own logs

```Rego theme={"languages":{"custom":["/languages/cel.json","/languages/rego.json"]}}
package formal.app

import future.keywords.if
import future.keywords.in

response := {
  "action": "rewrite",
  "json": object.union(input.response.json, {
    "logs": [l | some l in input.response.json.logs; l.user.formal.user.email == input.user.email],
  }),
} if {
  input.app.command.name == "ListLogsV2"
  not "security-admins" in input.user.groups
}
```

Users outside `security-admins` see only their own log entries.

## Example: Hide a resource's hostname

```Rego theme={"languages":{"custom":["/languages/cel.json","/languages/rego.json"]}}
package formal.app

import future.keywords.if
import future.keywords.in

response := {
  "action": "rewrite",
  "json": {"resource": object.remove(input.response.json.resource, ["hostname"])},
} if {
  input.app.command.name == "GetResource"
  not "admin" in input.user.groups
}
```

Users outside `admin` get the resource without its hostname.

## Example: Show users only the policies in one folder

```Rego theme={"languages":{"custom":["/languages/cel.json","/languages/rego.json"]}}
package formal.app

import future.keywords.if
import future.keywords.in

response := {
  "action": "rewrite",
  "json": object.union(input.response.json, {
    "policies": [p | some p in input.response.json.policies; in_team_folder(p.folderPath)],
  }),
} if {
  input.app.command.name == "ListPolicies"
  "data-team" in input.user.groups
}

response := {
  "action": "rewrite",
  "json": object.union(input.response.json, {
    "folders": [f | some f in input.response.json.folders; in_team_folder(f.path)],
  }),
} if {
  input.app.command.name == "ListPolicyFolders"
  "data-team" in input.user.groups
}

in_team_folder(path) if path == "Data Team"

in_team_folder(path) if startswith(path, "Data Team/")
```

Members of `data-team` see only the policies in the `Data Team` folder and its subfolders, in the Control Plane and through the API. `folderPath` is empty for a policy that is in no folder. The second rule hides the other folders from the folder list. `totalPolicyCount` still counts every policy.

> [!NOTE]
>
> These rules hide policies from lists. They do not block access by ID: `GetPolicy` still returns a hidden policy.


## Related topics

- [GetPermission](https://docs.formal.ai/api-reference/corev1permissionsservice/getpermission.md)
- [CreatePermission](https://docs.formal.ai/api-reference/corev1permissionsservice/createpermission.md)
- [UpdatePermission](https://docs.formal.ai/api-reference/corev1permissionsservice/updatepermission.md)
- [ListPermissions](https://docs.formal.ai/api-reference/corev1permissionsservice/listpermissions.md)
- [DeletePermission](https://docs.formal.ai/api-reference/corev1permissionsservice/deletepermission.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.