Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

add admin methods

dshukertjr8e273c967b34
diff --git a/spec/supabase_dart_v1.yml b/spec/supabase_dart_v1.yml
index 9e6d40a970d..46bf3067102 100644
--- a/spec/supabase_dart_v1.yml
+++ b/spec/supabase_dart_v1.yml
@@ -555,6 +555,157 @@ functions:
final nextLevel = res.nextLevel;
final currentAuthenticationMethods = res.currentAuthenticationMethods;
```
+ - id: admin-api
+ title: 'Overview'
+ notes: |
+ - Any method under the `supabase.auth.admin` namespace requires a `service_role` key.
+ - These methods are considered admin methods and should be called on a trusted server. Never expose your `service_role` key in the Flutter app.
+ examples:
+ - id: create-auth-admin-client
+ name: Create server-side auth client
+ isSpotlight: true
+ code: |
+ ```dart
+ final supabase = SupabaseClient(supabaseUrl, serviceRoleKey);
+ ```
+ - id: get-user-by-id
+ title: 'getUserById()'
+ notes: |
+ Get user by id.
+ - Fetches the user object from the database based on the user's id.
+ - The `getUserById()` method requires the user's id which maps to the `auth.users.id` column.
+ examples:
+ - id: fetch-the-user-object-using-the-access-token-jwt
+ name: Fetch the user object using the access_token jwt
+ isSpotlight: true
+ code: |
+ ```dart
+ final res = await supabase.auth.admin.getUserById(userId);
+ final user = res.user;
+ ```
+ - id: list-users
+ title: 'listUsers()'
+ notes: |
+ Get a list of users.
+ - Defaults to return 50 users per page.
+ examples:
+ - id: get-a-full-list-of-users
+ name: Get a page of users
+ isSpotlight: true
+ code: |
+ ```dart
+ final List<User> users = await supabase.auth.admin.listUsers();
+ ```
+ - id: get-paginated-list-of-users
+ name: Paginated list of users
+ isSpotlight: false
+ code: |
+ ```dart
+ final List<User> res = await supabase.auth.admin.listUsers(
+ page: 1,
+ perPage: 100,
+ );
+ ```
+ - id: create-user
+ title: 'createUser()'
+ notes: |
+ Creates a new user.
+ - To confirm the user's email address or phone number, set `email_confirm` or `phone_confirm` to true. Both arguments default to false.
+ - `createUser()` will not send a confirmation email to the user. You can use [`inviteUserByEmail()`](/docs/reference/dart/auth-admin-inviteuserbyemail) if you want to send them an email invite instead.
+ - If you are sure that the created user's email or phone number is legitimate and verified, you can set the `email_confirm` or `phone_confirm` param to `true`.
+ examples:
+ - id: create-a-new-user-with-custom-user-metadata
+ name: With custom user metadata
+ isSpotlight: true
+ code: |
+ ```dart
+ final res = await supabase.auth.admin.createUser(AdminUserAttributes(
+ email: '[email protected]',
+ password: 'password',
+ userMetadata: {'name': 'Yoda'},
+ ));
+ ```
+ - id: auto-confirm-the-users-email
+ name: Auto-confirm the user's email
+ code: |
+ ```dart
+ final res = await supabase.auth.admin.createUser(AdminUserAttributes(
+ email: '[email protected]',
+ emailConfirm: true,
+ ));
+ ```
+ - id: auto-confirm-the-users-phone-number
+ name: Auto-confirm the user's phone number
+ code: |
+ ```dart
+ final res = await supabase.auth.admin.createUser(AdminUserAttributes(
+ phone: '1234567890',
+ phoneConfirm: true,
+ ));
+ ```
+ - id: delete-user
+ title: 'deleteUser()'
+ notes: |
+ Delete a user.
+ - The `deleteUser()` method requires the user's ID, which maps to the `auth.users.id` column.
+ examples:
+ - id: removes-a-user
+ name: Removes a user
+ isSpotlight: true
+ code: |
+ ```dart
+ await supabase.auth.admin
+ .deleteUser('715ed5db-f090-4b8c-a067-640ecee36aa0');
+ ```
+ - id: invite-user-by-email
+ title: 'inviteUserByEmail()'
+ notes: |
+ Sends an invite link to the user's email address.
+ examples:
+ - id: invite-a-user
+ name: Invite a user
+ isSpotlight: true
+ code: |
+ ```dart
+ final UserResponse res = await supabase.auth.admin
+ .inviteUserByEmail('[email protected]');
+ final User? user = res.user;
+ ```
+ - id: generate-link
+ title: 'generateLink()'
+ notes: |
+ Generates email links and OTPs to be sent via a custom email provider.
+ - The following types can be passed into `generateLink()`: `signup`, `magiclink`, `invite`, `recovery`, `emailChangeCurrent`, `emailChangeNew`, `phoneChange`.
+ - `generateLink()` only generates the email link for `email_change_email` if the "Secure email change" setting is enabled under the "Email" provider in your Supabase project.
+ - `generateLink()` handles the creation of the user for `signup`, `invite` and `magiclink`.
+ examples:
+ - id: generate-a-signup-link
+ name: Generate a signup link
+ isSpotlight: true
+ code: |
+ ```dart
+ final res = await supabase.auth.admin.generateLink(
+ type: GenerateLinkType.signup,
+ email: '[email protected]',
+ password: 'secret',
+ );
+ final actionLink = res.properties.actionLink;
+ ```
+ - id: update-user-by-id
+ title: 'updateUserById()'
+ examples:
+ - id: updates-a-users-email
+ name: Updates a user's email
+ isSpotlight: false
+ code: |
+ ```dart
+ final UserResponse res = await supabase.auth.admin.updateUserById(
+ '6aa5d0d4-2a9f-4483-b6c8-0cf4c6c98ac4',
+ attributes: AdminUserAttributes(
+ email: '[email protected]',
+ ),
+ );
+ ```
- id: invoke
title: 'invoke()'
description: |
@@ -1370,7 +1521,7 @@ functions:
Retrieve URLs for assets in public buckets
title: 'from.getPublicUrl()'
notes: |
- - The bucket needs to be set to public, either via [updateBucket()](/docs/reference/javascript/storage-updatebucket) or by going to Storage on [supabase.com/dashboard](https://supabase.com/dashboard), clicking the overflow menu on a bucket and choosing "Make public"
+ - The bucket needs to be set to public, either via [updateBucket()](/docs/reference/dart/storage-updatebucket) or by going to Storage on [supabase.com/dashboard](https://supabase.com/dashboard), clicking the overflow menu on a bucket and choosing "Make public"
- Policy permissions required:
- `buckets` permissions: none
- `objects` permissions: none