Table of Contents

Class AdminClient

Namespace
Supabase.Gotrue
Assembly
Supabase.Gotrue.dll

Admin client for interacting with the Gotrue API. Intended for use on servers or other secure environments.

This client does NOT manage user sessions or track any other state.

public class AdminClient : IGotrueAdminClient<User>, IGettableHeaders
Inheritance
AdminClient
Implements
Inherited Members

Constructors

AdminClient(string, ClientOptions?)

Initialize the client with a service key.

public AdminClient(string serviceKey, ClientOptions? options = null)

Parameters

serviceKey string

A valid JWT. Must be a full-access API key (e.g. 'service_role' or 'supabase_admin').

options ClientOptions

Properties

GetHeaders

Headers sent to the API on every request.

public Func<Dictionary<string, string>>? GetHeaders { get; set; }

Property Value

Func<Dictionary<string, string>>

Options

The initialized client options.

public ClientOptions Options { get; }

Property Value

ClientOptions

Methods

CreateUser(AdminUserAttributes)

Creates a user using the admin key (not the anonymous key). Used in trusted server environments, not client apps.

public Task<User?> CreateUser(AdminUserAttributes attributes)

Parameters

attributes AdminUserAttributes

Returns

Task<User>

CreateUser(string, string, AdminUserAttributes?)

Creates a user using the admin key (not the anonymous key). Used in trusted server environments, not client apps.

public Task<User?> CreateUser(string email, string password, AdminUserAttributes? attributes = null)

Parameters

email string
password string
attributes AdminUserAttributes

Returns

Task<User>

DeleteFactor(MfaAdminDeleteFactorParams)

Deletes a factor on a user. This will log the user out of all active sessions if the deleted factor was verified.

public Task<MfaAdminDeleteFactorResponse?> DeleteFactor(MfaAdminDeleteFactorParams deleteFactorParams)

Parameters

deleteFactorParams MfaAdminDeleteFactorParams

Returns

Task<MfaAdminDeleteFactorResponse>

A MfaAdminDeleteFactorResponse containing the deleted factor id.

DeleteUser(string)

Creates a user using the admin key (not the anonymous key). Used in trusted server environments, not client apps.

public Task<bool> DeleteUser(string uid)

Parameters

uid string

Returns

Task<bool>

Generates email links and OTPs to be sent via a custom email provider.

public Task<GenerateLinkResponse?> GenerateLink(GenerateLinkOptions options)

Parameters

options GenerateLinkOptions

Options for this call. Password is required for SignUp, Data is an optional parameter for SignUp.

Returns

Task<GenerateLinkResponse>

GetUser(string)

Gets a user from a user's JWT. This is using the GoTrue server to validate a user's JWT.

public Task<User?> GetUser(string jwt)

Parameters

jwt string

Returns

Task<User>

GetUserById(string)

Gets a user by ID from the server using the admin key (not the anonymous key).

public Task<User?> GetUserById(string userId)

Parameters

userId string

Returns

Task<User>

InviteUserByEmail(string, InviteUserByEmailOptions?)

Sends an email to the user.

public Task<bool> InviteUserByEmail(string email, InviteUserByEmailOptions? options = null)

Parameters

email string
options InviteUserByEmailOptions

Returns

Task<bool>

ListFactors(MfaAdminListFactorsParams)

Lists all factors associated to a specific user.

public Task<MfaAdminListFactorsResponse?> ListFactors(MfaAdminListFactorsParams listFactorsParams)

Parameters

listFactorsParams MfaAdminListFactorsParams

Returns

Task<MfaAdminListFactorsResponse>

A list of Factor that this user has enabled.

ListUsers(string?, string?, SortOrder, int?, int?)

Lists users

public Task<UserList<User>?> ListUsers(string? filter = null, string? sortBy = null, Constants.SortOrder sortOrder = SortOrder.Descending, int? page = null, int? perPage = null)

Parameters

filter string

A string for example part of the email

sortBy string

Snake case string of the given key, currently only created_at is supported

sortOrder Constants.SortOrder

asc or desc, if null desc is used

page int?

page to show for pagination

perPage int?

items per page for pagination

Returns

Task<UserList<User>>

Update(UserAttributes)

Updates a User using the service key

public Task<User?> Update(UserAttributes attributes)

Parameters

attributes UserAttributes

Returns

Task<User>

UpdateUserById(string, AdminUserAttributes)

Update user by Id

public Task<User?> UpdateUserById(string userId, AdminUserAttributes userData)

Parameters

userId string
userData AdminUserAttributes

Returns

Task<User>