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

# Cloudflare

> Learn how to connect Opal to Cloudflare to manage account permissions, IAM user groups, Zero Trust Access groups, and Access applications.

With the Cloudflare integration, you can manage access to your Cloudflare account and Zero Trust from Opal:

* Allow users to request account-wide permissions, IAM user group membership, and Zero Trust Access group membership from the web and Slack
* Review who can reach each Zero Trust Access application
* Optionally invite and remove Cloudflare account members from Opal
* Optionally list account API tokens for access reviews
* Automatically revoke access when a time-bound grant expires

Opal connects to one Cloudflare account through an account-owned API token. To manage several accounts, add a Cloudflare app in Opal for each one.

## Supported resources

| Resource | Read | Grant and revoke access |
| - | - | - |
| Cloudflare Account (account permissions) | ✔️ | ✔️ |
| IAM user groups (membership and permissions) | ✔️ | ✔️ |
| Zero Trust Access groups (email members) | ✔️ | ✔️ |
| Zero Trust Access applications | ✔️ | |
| Account API tokens | ✔️ | |

Opal syncs account members (including pending invites). By default it doesn't invite or remove members, so your identity provider can keep provisioning Cloudflare over SCIM. You can turn member invites and removals on in the app settings.

### How Cloudflare access maps to Opal

* **Account permissions**: your Cloudflare account appears as **Cloudflare Account**, with each account-scoped permission group as an access level. Opal grants and revokes these through Cloudflare policies. Zone-scoped or deny policies don't count as account access. If a permission is bundled with others in one policy, Opal refuses to revoke it alone and asks you to split the policy in Cloudflare first.
* **IAM user groups**: each IAM user group appears as a **Cloudflare User Group**. You can grant and revoke membership, and grant or revoke the account permissions the group holds.
* **Access groups**: each Zero Trust Access group appears as a **Cloudflare Access Group**. Opal syncs people named by email rules, and can add or remove those email rules. Rules that admit people by email domain, identity-provider group, or similar aren't listed as members; the group's description names those rules, and any exclude or require rules Opal doesn't apply, so the member list isn't mistaken for everyone the group admits. Revoking the last email leaves a rule that matches nobody, because Cloudflare rejects an empty include list.
* **Access applications**: each Access application appears as a **Cloudflare Access Application**, read-only. People named by email in allow policies show as direct access; Access groups included by a policy show as the path to the app. Change who can reach an app by managing those Access groups, not the application itself.
* **Account API tokens**: optional and off by default. When enabled, each account API token appears as a **Cloudflare Account API Token**, read-only, so reviews can see which non-human credentials exist. Tokens have no email, so they aren't shown as users holding access.

### Limitations

* Opal syncs account-wide permissions only. Permissions scoped to zones or other resource groups aren't included yet.
* Access-application rules that name identity-provider groups (for example Entra or Okta) aren't linked to those groups in Opal yet.
* SCIM-managed IAM user groups may reject membership changes from Opal; Cloudflare's own error explains when the identity provider owns the group.

## Requirements

Before you begin, you must:

* Be an Opal Admin
* Have a Cloudflare account admin who can create an account-owned API token
* Ask the Opal team to enable the Cloudflare integration for your organization

## Configuration steps

### 1. Find your Account ID

In the Cloudflare dashboard:

1. Open [Account home](https://dash.cloudflare.com/?to=/:account/home).
2. Press **Command + K** (Mac) or **Ctrl + K** (Windows), type `Copy account ID`, and run the suggested command.

You can also copy the 32-character **Account ID** from **Manage Account**. You'll enter it in Opal in step 3. See Cloudflare's guide to [find account and zone IDs](https://developers.cloudflare.com/fundamentals/account/find-account-and-zone-ids/).

### 2. Create an account-owned API token

1. In the Cloudflare dashboard, go to **Manage account** > **Account API Tokens**.
2. Select **Create Token**, name it (for example `Opal`), choose an optional expiration, and set the permissions below.
3. Select **Continue to summary**, then **Create Token**, and copy the token. Cloudflare shows it only once.

Prefer an [account-owned API token](https://developers.cloudflare.com/fundamentals/api/get-started/account-owned-tokens/) so access keeps working when the person who made it leaves. A user token from **My Profile > API Tokens** with the same permissions also works.

Grant the permissions that match what you plan to sync:

| Permission | Needed to |
| - | - |
| Account Settings Read | Sync members, account permissions, and IAM user groups |
| Account Settings Edit | Grant or revoke account permissions, user group membership, and invites |
| Access: Groups Read | Sync Access groups |
| Access: Groups Edit | Grant or revoke Access group email members |
| Access: Apps and Policies Read | Sync Access applications |
| Account API Tokens Read | List account API tokens |

For a read-only connection, grant only the Read permissions. For a connection that can change access, use Edit instead of Read where you need writes.

Copy the token. Cloudflare shows it only once.

### 3. Create the Cloudflare app in Opal

In Opal, go to **Inventory** > **+ App** and select **Cloudflare**. Fill in the following fields:

| Field | Value |
| - | - |
| App name | A name for the Cloudflare app in Opal, for example `Cloudflare`. |
| App admin | The owner who administers the app in Opal. |
| Description | A short description that helps requesters understand what this app is. |
| Visibility | Who in your organization can see the app. |
| Account ID | The Account ID from step 1. |
| API token | The token from step 2. |
| Access | **Read and write** to grant and revoke, or **Read only** to sync without changing Cloudflare. |
| Members | **Managed outside Opal** (default) if your identity provider provisions Cloudflare, or **Opal invites and removes members**. |
| IAM user groups | **Sync** (default) or **Don't sync**. |
| Zero Trust Access groups | **Sync** (default) or **Don't sync**. |
| Zero Trust Access applications | **Sync** (default) or **Don't sync**. |
| Account API tokens | **Don't sync** (default) or **Sync**. |

Opal checks the credentials when you save the app. You can change the sync settings later on the app's **Setup** tab. A deselected kind makes no API calls and skips its validations.

![The Cloudflare app's Setup tab in Opal, with the Access, Members, IAM user groups, and Zero Trust Access groups settings.](https://mintcdn.com/opalsecurity/pBQpCMT_mO-nsJVp/images/docs/cloudflare-opal-setup.png?fit=max\&auto=format\&n=pBQpCMT_mO-nsJVp\&q=85\&s=01318ec6f3be433eae6061e56aec302a)

### 4. Import assets

After you save the app, import the items you want to manage: on the app's **Assets** tab, select **Import assets**, choose the account, user groups, Access groups, and Access applications, and turn on requests for the items people should be able to request. Opal pulls access only for imported items, so members appear after the next sync.

![Opal's Import assets dialog for a Cloudflare app, listing two Zero Trust Access groups typed Cloudflare Access Group.](https://mintcdn.com/opalsecurity/pBQpCMT_mO-nsJVp/images/docs/cloudflare-import-access-groups.png?fit=max\&auto=format\&n=pBQpCMT_mO-nsJVp\&q=85\&s=cb599fc9f2faf19816dbe72173244abe)

After the sync, an Access application's **User Access** tab shows people named by email in its policies as **Direct**, and people who reach it through an included Access group as **Indirect**.

![The User Access tab of a Cloudflare Access Application in Opal, with one user who has direct access and one with indirect access through an Access group.](https://mintcdn.com/opalsecurity/pBQpCMT_mO-nsJVp/images/docs/cloudflare-access-application-users.png?fit=max\&auto=format\&n=pBQpCMT_mO-nsJVp\&q=85\&s=88d588cca27df9d9e29616eb8946d814)

## Troubleshooting

| Error or symptom | Fix |
| - | - |
| Cloudflare rejected the credentials | Create a new account-owned API token and paste it again. Confirm the Account ID matches the account the token belongs to. |
| A validation asks for Account Settings Read | Add **Account Settings Read** (or Edit) to the token. |
| A validation asks for Access: Groups or Apps and Policies | Add the matching Access permission, or set that sync setting to **Don't sync**. |
| Access applications validation passes but no apps appear | A token without **Access: Apps and Policies Read** can get an empty list instead of a 403. Grant that permission and sync again. |
| A grant or revoke fails naming Account Settings Edit | The token needs **Account Settings Edit**, or set **Access** to **Read only** if you only need sync. |
| A grant or revoke fails naming Access: Groups Edit | The token needs **Access: Groups Edit**. |
| A revoke fails because a policy bundles other permissions | In Cloudflare, split that policy so the permission has its own policy, then retry. |
| Membership change fails on a SCIM-managed user group | Manage that group's membership in your identity provider. |


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