GoTrueAdminApi
import { GoTrueAdminApi } from "https://esm.sh/@supabase/supabase-js@2.99.0/dist/index.d.mts";§Constructors
Creates an admin API client that can be used to manage users and OAuth clients.
import { GoTrueAdminApi } from '@supabase/auth-js'
const admin = new GoTrueAdminApi({
url: 'https://xyzcompany.supabase.co/auth/v1',
headers: { Authorization: `Bearer ${process.env.SUPABASE_SERVICE_ROLE_KEY}` },
})
§Properties
Creates a new custom OIDC/OAuth provider.
For OIDC providers, the server fetches and validates the OpenID Connect discovery document
from the issuer's well-known endpoint (or the provided discovery_url) at creation time.
This may return a validation error (error_code: "validation_failed") if the discovery
document is unreachable, not valid JSON, missing required fields, or if the issuer
in the document does not match the expected issuer.
This function should only be called on a server. Never expose your service_role key in the browser.
Creates a new OAuth client. Only relevant when the OAuth 2.1 server is enabled in Supabase Auth.
This function should only be called on a server. Never expose your service_role key in the browser.
Deletes a custom provider.
This function should only be called on a server. Never expose your service_role key in the browser.
Deletes an OAuth client. Only relevant when the OAuth 2.1 server is enabled in Supabase Auth.
This function should only be called on a server. Never expose your service_role key in the browser.
Gets details of a specific custom provider by identifier.
This function should only be called on a server. Never expose your service_role key in the browser.
Gets details of a specific OAuth client. Only relevant when the OAuth 2.1 server is enabled in Supabase Auth.
This function should only be called on a server. Never expose your service_role key in the browser.
Lists all custom providers with optional type filter.
This function should only be called on a server. Never expose your service_role key in the browser.
Lists all OAuth clients with optional pagination. Only relevant when the OAuth 2.1 server is enabled in Supabase Auth.
This function should only be called on a server. Never expose your service_role key in the browser.
Regenerates the secret for an OAuth client. Only relevant when the OAuth 2.1 server is enabled in Supabase Auth.
This function should only be called on a server. Never expose your service_role key in the browser.
Updates an existing custom provider.
When issuer or discovery_url is changed on an OIDC provider, the server re-fetches and
validates the discovery document before persisting. This may return a validation error
(error_code: "validation_failed") if the discovery document is unreachable, invalid, or
the issuer does not match.
This function should only be called on a server. Never expose your service_role key in the browser.
Updates an existing OAuth client. Only relevant when the OAuth 2.1 server is enabled in Supabase Auth.
This function should only be called on a server. Never expose your service_role key in the browser.
Contains all custom OIDC/OAuth provider administration methods.
Contains all MFA administration methods.
Contains all OAuth client administration methods. Only relevant when the OAuth 2.1 server is enabled in Supabase Auth.
§Methods
Creates a new user.
This function should only be called on a server. Never expose your service_role key in the browser.
Delete a user. Requires a service_role key.
The user id you want to remove.
If true, then the user will be soft-deleted from the auth schema. Soft deletion allows user identification from the hashed user ID but is not reversible. Defaults to false for backward compatibility.
This function should only be called on a server. Never expose your service_role key in the browser.
Generates email links and OTPs to be sent via a custom email provider.
The user's email.
User password. For signup only.
Optional user metadata. For signup only.
The redirect url which should be appended to the generated link
Get user by id.
The user's unique identifier
This function should only be called on a server. Never expose your service_role key in the browser.
Sends an invite link to an email address.
The email address of the user.
Additional options to be included when inviting.
Get a list of users.
This function should only be called on a server. Never expose your service_role key in the browser.
An object which supports page and perPage as numbers, to alter the paginated results.
Updates the user data. Changes are applied directly without confirmation flows.
The user's unique identifier
The data you want to update.
This function should only be called on a server. Never expose your service_role key in the browser.
// Server-side (Edge Function)
const { data, error } = await supabase.auth.admin.updateUserById(
userId,
{ user_metadata: { preferences: { theme: 'dark' } } }
)
// Client-side (to sync the changes)
const { data, error } = await supabase.auth.refreshSession()
// onAuthStateChange listeners will now be notified with updated user