--- id: 'team-database-access' title: 'Map team members to Postgres roles' description: 'Give team members database access through their own access tokens instead of a shared password.' --- Let a team member connect to your project database as a [Postgres role](/docs/guides/database/postgres/roles), using their own [access token](/docs/guides/platform/personal-access-tokens) instead of a shared password. This follows security best practices, allowing each person to only access what they need for as long as they need it. A member access rule maps a team member to one or more Postgres roles they can assume. It creates no new role or user in the database, and the assumed role's permissions apply. The role's own password keeps working, so long-lived service connections don't change. A team member who knows the role's password can connect with it after you remove their mapping. To end that access, change the role's password. For the `postgres` role, see [Changing your project password](/docs/guides/database/postgres/roles#changing-your-project-password). Use this guide when: - Your team shares the `postgres` password, and you want each person to connect with their own credentials. - Someone needs database access that [ends on a date you set](#restrict-a-team-members-access). - You want to [remove one person's access](#remove-a-team-members-access) without changing a password everyone else uses. For details on how database token access works, see [Database token access](/docs/guides/platform/token-access). ## Prerequisites Before you authorize a team member, set up the following: - [Enable database token access](/docs/guides/platform/token-access#manage-temporary-access-via-the-management-api) on the project. - 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 JIT** with **Read and write** access. - Confirm that the team member has access to the project. ## Authorize a team member To authorize a team member: 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 mappings, so list every role they need. 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="the-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 @- <