> ## 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.

# Supabase

> Learn how to connect Opal to Supabase to manage organization and project roles, and optionally project Auth users.

With the Supabase integration, you can manage access to a Supabase organization from Opal:

* See who is a member, and which organization or project role they hold
* Let people request just-in-time access to the organization and to a project, as **Read-Only**, **Developer**, **Administrator**, or **Owner**
* Invite someone who is not yet a member, and remove them when access should end
* Optionally review the Postgres role on a project's Auth users, for people Opal already knows
* Delegate approvals to the right owners, and revoke access when a time-bound grant expires

Opal connects to one Supabase organization through a personal access token. To manage several organizations, add a Supabase app in Opal for each one.

## Supported resources

| Resource | Read | Grant and revoke access | Notes |
| - | - | - | - |
| Organization members | Yes | Invite and remove | Matched by email. An invitation joins with **No access** until you grant a role. |
| Supabase Organization | Yes | Yes | **Read-Only**, **Developer**, **Administrator**, and **Owner**. One role per person. An organization role applies to every project. |
| Supabase Project | Yes | Grant only | The same four roles, for members scoped to that project. Opal cannot take a project role away. |
| Project Auth users | Optional | Role only | Off unless you turn it on. Imports a user only when Opal already knows their email. Does not create or delete Auth users. |

## Requirements

Before you begin, you must:

* Be an Opal Admin.
* Be an Owner of the Supabase organization. The token acts as the person who creates it. Changing roles and inviting members needs an Owner, and Supabase only allows those changes on a Team or Enterprise plan.
* Be on version `1.1262.0` or later, if you self-host Opal

Use a dedicated Owner account for the token when you can. A token can change the organization, so treat it like an Owner credential.

## 1. Create a personal access token

In Supabase, open **Account**, then **Access Tokens**, and create a fine-grained token scoped to this organization.

Give the token **Read** access to:

* Organization Settings
* Organization Members
* Organization Projects, if Opal should sync projects
* Projects, if Opal should sync projects

If Opal should grant and revoke roles or invite members, also give it **Read-write** access to Organization Settings. A read-only connection does not need that permission.

If you will turn on **Sync project Auth users**, also give the token **Read** access to each project's API keys and database. Opal uses the project's API key to read Auth users, and the database to learn which Postgres roles can be granted.

Copy the token. Supabase shows it only once. You enter it in Opal in the next step.

> [!NOTE]
>
> A classic account-wide Owner token also works, as a last resort. Prefer a fine-grained token scoped to the one organization, with only the permissions above.

## 2. Create the Supabase app in Opal

In Opal, go to **Inventory** > **+ App** and select **Supabase**.

| Field | Value |
| - | - |
| App name | A name for this organization in Opal, for example `Supabase`. |
| 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. |
| Organization slug | The ID in the organization URL. For `https://supabase.com/dashboard/org/acme`, the slug is `acme`. |
| Personal access token | The token from [step 1](#1-create-a-personal-access-token). |
| Access | **Read and write** to grant, revoke, invite, and remove. **Read only** to sync who has access and change nothing in Supabase. Read only needs no write permission, and Opal hides grant and remove. |
| Projects | **Sync** to import projects. **Don't sync** to leave projects out of Opal. |
| Sync project Auth users | Leave this off unless you want to review Auth users. See [Auth users](#auth-users). |

Opal checks the token when you save the app.

## 3. Check the app setup

Open the app's **Setup** tab.

| Check | If it fails |
| - | - |
| Read organization members | The app is not healthy and sync does not run. The token needs Read access to Organization Members, and **Organization slug** must be the organization on the token. |
| Read projects | Shown when projects are set to sync. The token needs Read access to Organization Projects. |
| Plan allows changing roles | A warning, not a failure. Supabase only lets Team and Enterprise organizations change roles or invite members. Opal can still sync a Free or Pro organization. This check is skipped when Access is **Read only**. |
| Read Auth users | Shown only when Auth users are on and projects are synced. The token needs Read access to the project's API keys and database. |

## 4. Import the organization and projects

Opal pulls access only for items you import.

1. On the app's **Assets** tab, select **Import assets**.
2. Import **Supabase Organization**, and the projects you want people to request.
3. Turn on requests for those items.

Organization members appear on the app's **Accounts** tab after the next sync. A pending invitation is not listed until the person accepts it. Supabase keeps an invitation open for 24 hours.

Each imported project gets an Auth item, named `<project> Auth`, only when **Sync project Auth users** is on. You do not import that item yourself.

## How access maps to Opal

### Organization role

The organization appears in Opal as **Supabase Organization**, with **Read-Only**, **Developer**, **Administrator**, and **Owner**. Each person holds one organization role, so requesting another role replaces the current one. That role applies to every project in the organization.

**Read-Only** exists on Team and Enterprise plans only.

| When you revoke | What Supabase does |
| - | - |
| **Owner** or **Administrator** | The person becomes **Developer**. They stay in the organization. |
| **Developer** or **Read-Only** | Supabase removes the person from the organization, including every project role they hold. |

> [!NOTE]
>
> Do not make **Owner** or **Administrator** time-bound if you expect the person to lose access when the grant expires. Opal can only demote those roles to **Developer**.

### Projects

Each project appears in Opal as a **Supabase Project**, with the same four roles. A project lists the people scoped to it directly, and inherits everyone who holds an organization role.

Project roles exist on Team and Enterprise plans. On those plans a member can hold **No access** on the organization and a role on specific projects. Opal does not offer **No access** as a role you can request. Granting a project role moves that project out of any other project role the person holds on it.

Opal cannot revoke a project role. Supabase has no call that removes one. To take a project role away, change it in Supabase, or remove the person from the organization.

### Inviting and removing people

When Access is **Read and write**, Opal can invite an email to the organization. Supabase creates the invitation with **No access**, on Team and Enterprise plans only. The person is matched in Opal after they accept and a sync lists them. Until then the invitation can still be accepted, and they join with no role.

Removing the person in Opal removes their organization membership. If they have not accepted yet, Opal revokes the invitation. Opal does not delete their Auth users.

### Auth users

Turn this on only for projects whose Auth users are people in your company. A project can hold millions of end users, and Opal cannot ask Supabase for just the emails it already knows. Leave it off when those users are your customers.

Opal imports an Auth user only when their email is already an organization member's email, or an Opal user's primary email. It never creates an Opal user from an Auth user. Users without an email are skipped, and so are anonymous, unconfirmed, banned, and deleted users.

The roles you can grant are the Postgres roles that `authenticator` can assume in that project. `anon` is left out, because it is the role of a request with no user. `service_role` bypasses row level security, so Opal syncs it but does not let anyone request it.

An Auth user holds one role. The usual role is `authenticated`.

* Granting a role sets that role. Opal refuses the grant while the user holds some other role besides `authenticated`. Revoke the current role first.
* Revoking a role other than `authenticated` sets the user back to `authenticated`.
* Opal cannot revoke `authenticated`. The only way to take it away is to delete the Auth user, and Opal does not delete Auth users.
* The person must already have an Auth account in that project, on one of their emails. Opal does not create Auth users.

A paused or restarting project keeps its Auth item and the grants on it, but Opal does not read its users until the project is healthy again.

## Changing what the connection syncs

You can change these on the app's **Setup** tab after the app exists.

* **Access** set to **Read only** stops grants, revokes, invites, and removals. Opal hides those actions. Set it back to **Read and write** to allow them again. The token still needs Read-write access to Organization Settings.
* **Projects** set to **Don't sync** removes imported projects on the next sync, and each project's Auth users with them. Opal does not call Supabase to list projects while this is off.
* Turning off **Sync project Auth users** removes imported Auth users on the next sync. The projects stay.

Before it saves a change that removes imported items, Opal lists how many items would go, how many grants Opal made, and how many requests are still pending. When Opal made grants, you type the app name to confirm. Access Opal granted stays in Supabase. Opal stops tracking it, so it will not expire or be revoked.

## What Opal does not manage

* Creating, pausing, or deleting Supabase projects
* Database schemas, row level security, storage, and edge functions
* Creating or deleting Auth users
* Revoking the `authenticated` role, or any project-scoped member role
* Auth users who are not already people in Opal
* Changing roles or sending invitations on a Free or Pro plan

## Troubleshooting

| What you see | What to do |
| - | - |
| The token could not read this organization | Check **Organization slug** against the organization URL, and give the token Read access to Organization Settings. Copy the token again if it was created for a different organization. |
| Cannot read organization members | Give the token Read access to Organization Members. The person who created the token must still be a member. |
| Cannot read projects | Give the token Read access to Organization Projects and Projects, or set **Projects** to **Don't sync**. |
| Opal can sync this organization but not change roles | The organization is not on a Team or Enterprise plan. Supabase refuses role changes and invitations on other plans. Set **Access** to **Read only**, or upgrade the plan. |
| Cannot read a project's Auth users | Give the token Read access to the project's API keys and database. The project must be healthy. A paused project is skipped. |
| A grant fails because the plan does not allow it | Role changes and invitations need Team or Enterprise. The token also needs Read-write access to Organization Settings, from an Owner. |
| Revoking Owner left the person as Developer | That is what Supabase allows. Remove a **Developer** or **Read-Only** role to take the person out of the organization. |
| A project role will not revoke | Opal cannot remove a project-scoped role. Change it in Supabase, or remove the person from the organization. |
| An Auth role grant is refused | The user already holds a role other than `authenticated`. Revoke that role first. Opal will not grant a second one. |
| Customers appear as Auth users | Turn **Sync project Auth users** off for that connection. Opal only keeps Auth users whose email it already knows, but reading them still walks the whole project. |


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