--- id: 'database-token-access-member-access-rules' title: 'Member access rules' description: 'Choose which Postgres roles each team member can assume with database token access and limit each role by expiry, allowed network, and preview branch.' --- A member access rule lets a team member connect to your project database as a [Postgres role](/docs/guides/database/postgres/roles) with their own [access token](/docs/guides/platform/personal-access-tokens) instead of the database password. You can limit each role by expiry, network, and branch and remove one person's access without changing the database password. For how it works and how to connect, see [Database token access](/docs/guides/platform/database-token-access). A rule doesn't create a role or user in the database. It lets the team member assume roles that already exist. Because those roles keep their own passwords, service connections that use them don't change. Rules live on your main project and apply to its [read replicas](/docs/guides/platform/read-replicas) and [preview branches](/docs/guides/deployment/branching). ## Prerequisites - [Turn on database token access](/docs/guides/platform/database-token-access#manage-database-token-access-via-the-dashboard) for the project. - Confirm that the team member has access to the project. ## Choose a role A rule can map any Postgres role that can log in. Even with a valid token, Postgres refuses any role without the `LOGIN` attribute. To give someone less access than `postgres`, create a narrower role with `LOGIN` first. See [Postgres roles](/docs/guides/database/postgres/roles). You can't map the roles Supabase manages for its own services. These are `service_role`, `authenticator`, `pgbouncer`, `supabase_admin`, and every other `supabase_*_admin` role. You can map `supabase_read_only_user` for read-only access. The dashboard lists only the roles you can map. ## Authorize a team member After you create a rule, the team member connects as a mapped role with their access token as the password. For connection strings, see [Connect with database token access](/docs/guides/platform/database-token-access#connect-with-database-token-access). ### In the dashboard 1. Go to [Database Settings](/dashboard/project/_/database/settings) > **Database access** and click **Add member** in the **Members** list. 2. Select the team member. 3. Under **Roles and settings**, select each role the team member can assume. To limit a role, set the fields described in [Restrict a team member's access](#restrict-a-team-members-access). 4. Click **Create rule**. To change a rule, open its **More actions** menu in the **Members** list and click **Edit**. ### With the Management API Create a personal access token in the [Supabase Dashboard](/dashboard/account/tokens) to call the Management API. If you scope the token, give it **Organization members** with **Read only** access and **Database token access** with **Read and write** access. Send every request to the main project's ref because the Management API rejects rule requests sent to a branch. 1. Set your access token, project ref, and organization slug: ```bash export SUPABASE_MANAGEMENT_API_TOKEN="YOUR_ACCESS_TOKEN" export PROJECT_REF="YOUR_PROJECT_REF" export ORG_SLUG="YOUR_ORG_SLUG" ``` The organization slug is the part of your organization's URL in the Supabase Dashboard that follows `/org/`. 2. List the organization's members and copy the `user_id` of the team member you want to authorize: ```bash curl "https://api.supabase.com/v1/organizations/$ORG_SLUG/members" \ -H "Authorization: Bearer $SUPABASE_MANAGEMENT_API_TOKEN" ``` 3. Map the team member to the roles they can assume. Each request replaces the team member's rule. List every role they need. Replace `YOUR_MEMBER_USER_ID` with the `user_id` you copied. To restrict access from the start, add the fields from [Restrict a team member's access](#restrict-a-team-members-access) to this request: ```bash export MEMBER_USER_ID="YOUR_MEMBER_USER_ID" curl -X PUT "https://api.supabase.com/v1/projects/$PROJECT_REF/database/jit" \ -H "Authorization: Bearer $SUPABASE_MANAGEMENT_API_TOKEN" \ -H "Content-Type: application/json" \ -d @- <