Skip to content
SupportDashboard

Auth

This is the main module to interact with Nhost’s Auth service. Typically you would use this module via the main Nhost client but you can also use it directly if you have a specific use case.

You can import and use this package with:

import { createAPIClient } from "@nhost/nhost-js/auth";
import { createClient } from "@nhost/nhost-js";
const nhost = createClient({
subdomain,
region,
});
await nhost.auth.signUpEmailPassword({
email,
password,
});

The SDK will throw errors in most operations if the request returns a status >=300 or if the request fails entirely (i.e., due to network errors). The type of the error will be a FetchError<ErrorResponse>:

import { createClient } from "@nhost/nhost-js";
import { FetchError } from "@nhost/nhost-js/fetch";
const nhost = createClient({
subdomain,
region,
});
try {
await nhost.auth.signInEmailPassword({
email,
password,
});
} catch (err) {
if (!(err instanceof FetchError)) {
throw err; // Re-throw if it's not a FetchError
}
console.log("Error:", err);
// Error: {
// body: {
// error: 'invalid-email-password',
// message: 'Incorrect email or password',
// status: 401
// },
// status: 401,
// headers: {
// 'content-length': '88',
// 'content-type': 'application/json',
// date: 'Mon, 12 May 2025 08:08:28 GMT'
// }
// }
// error handling...
}

This type extends the standard Error type so if you want to just log the error you can do so like this:

import { createClient } from "@nhost/nhost-js";
import { FetchError } from "@nhost/nhost-js/fetch";
const nhost = createClient({
subdomain,
region,
});
try {
await nhost.auth.signInEmailPassword({
email,
password,
});
} catch (err) {
if (!(err instanceof Error)) {
throw err; // Re-throw if it's not an Error
}
console.log("Error:", err.message);
// Error: Incorrect email or password
}

Map of extension outputs from the client

appid?: boolean;

Application identifier extension output

credProps?: CredentialPropertiesOutput;

Credential properties extension output

hmacCreateSecret?: boolean;

HMAC secret extension output


authenticatorData: string;

(string) - Base64url encoded authenticator data

clientDataJSON: string;

(string) - Base64url encoded client data JSON

signature: string;

(string) - Base64url encoded assertion signature

userHandle?: string;

Base64url encoded user handle


attestationObject: string;

(string) - Base64url-encoded binary data

  • Format - byte
authenticatorData?: string;

Base64url-encoded binary data Format - byte

clientDataJSON: string;

(string) - Base64url-encoded binary data

  • Format - byte
publicKey?: string;

Base64url-encoded binary data Format - byte

publicKeyAlgorithm?: number;

The public key algorithm identifier Format - int64

transports?: string[];

The authenticator transports


authenticatorAttachment?: AuthenticatorAttachment;

The authenticator attachment modality

requireResidentKey?: boolean;

Whether the authenticator must create a client-side-resident public key credential source

residentKey?: ResidentKeyRequirement;

The resident key requirement

userVerification?: UserVerificationRequirement;

A requirement for user verification for the operation


baseURL: string;
addSecurityKey(options?: RequestInit): Promise<FetchResponse<PublicKeyCredentialCreationOptions>>;

Summary: Initialize adding of a new webauthn security key Start the process of adding a new WebAuthn security key to the user’s account. Returns a challenge that must be completed by the user’s authenticator device. Requires elevated permissions.

This method may return different T based on the response code:

  • 200: PublicKeyCredentialCreationOptions
Parameter Type
options? RequestInit

Promise<FetchResponse<PublicKeyCredentialCreationOptions>>

changeUserEmail(body: UserEmailChangeRequest, options?: RequestInit): Promise<FetchResponse<"OK">>;

Summary: Change user email Request to change the authenticated user’s email address. A verification email will be sent to the new address to confirm the change. Requires elevated permissions.

This method may return different T based on the response code:

  • 200: OKResponse
Parameter Type
body UserEmailChangeRequest
options? RequestInit

Promise<FetchResponse<"OK">>

changeUserMfa(options?: RequestInit): Promise<FetchResponse<TotpGenerateResponse>>;

Summary: Generate TOTP secret Generate a Time-based One-Time Password (TOTP) secret for setting up multi-factor authentication

This method may return different T based on the response code:

  • 200: TotpGenerateResponse
Parameter Type
options? RequestInit

Promise<FetchResponse<TotpGenerateResponse>>

changeUserPassword(body: UserPasswordRequest, options?: RequestInit): Promise<FetchResponse<"OK">>;

Summary: Change user password Change the user’s password. The user must be authenticated with elevated permissions or provide a valid password reset ticket.

All of the user’s existing sessions are revoked atomically as part of this operation, including the session used to make the request. Clients must treat the user as signed out after a successful response and obtain a new session via sign-in.

This method may return different T based on the response code:

  • 200: OKResponse
Parameter Type
body UserPasswordRequest
options? RequestInit

Promise<FetchResponse<"OK">>

changeUserPhoneNumber(body: UserPhoneNumberChangeRequest, options?: RequestInit): Promise<FetchResponse<"OK">>;

Summary: Change user phone number Request to change the authenticated user’s phone number. A one-time password is sent via SMS to the new phone number; complete the change by calling /user/phone-number/change/verify with the OTP. The current phone_number is left unchanged until verification succeeds. Requires elevated permissions.

This method may return different T based on the response code:

  • 200: OKResponse
Parameter Type
body UserPhoneNumberChangeRequest
options? RequestInit

Promise<FetchResponse<"OK">>

createPAT(body: CreatePATRequest, options?: RequestInit): Promise<FetchResponse<CreatePATResponse>>;

Summary: Create a Personal Access Token (PAT) Generate a new Personal Access Token for programmatic API access. PATs are long-lived tokens that can be used instead of regular authentication for automated systems. Requires elevated permissions.

This method may return different T based on the response code:

  • 200: CreatePATResponse
Parameter Type
body CreatePATRequest
options? RequestInit

Promise<FetchResponse<CreatePATResponse>>

deanonymizeUser(body: UserDeanonymizeRequest, options?: RequestInit): Promise<FetchResponse<"OK">>;

Summary: Deanonymize an anonymous user Convert an anonymous user to a regular user by adding email and optionally password credentials. A confirmation email will be sent if the server is configured to do so.

This method may return different T based on the response code:

  • 200: OKResponse
Parameter Type
body UserDeanonymizeRequest
options? RequestInit

Promise<FetchResponse<"OK">>

deanonymizeUserSms(body: UserDeanonymizeSmsRequest, options?: RequestInit): Promise<FetchResponse<"OK">>;

Summary: Deanonymize an anonymous user with SMS OTP Convert an anonymous user to a regular user by adding a phone number. A one-time password is sent to the phone number; the user completes verification by calling /signin/passwordless/sms/otp with the OTP, which marks the phone number as verified and returns a session.

This method may return different T based on the response code:

  • 200: OKResponse
Parameter Type
body UserDeanonymizeSmsRequest
options? RequestInit

Promise<FetchResponse<"OK">>

elevateOTPEmail(options?: RequestInit): Promise<FetchResponse<"OK">>;

Summary: Request a one-time password by email to elevate an already signed in user Send a one-time password to the signed in user’s email address to start elevation

This method may return different T based on the response code:

  • 200: OKResponse
Parameter Type
options? RequestInit

Promise<FetchResponse<"OK">>

elevateOTPSms(options?: RequestInit): Promise<FetchResponse<"OK">>;

Summary: Request a one-time password by SMS to elevate an already signed in user Send a one-time password to the signed in user’s verified phone number to start elevation

This method may return different T based on the response code:

  • 200: OKResponse
Parameter Type
options? RequestInit

Promise<FetchResponse<"OK">>

elevateTotp(body: ElevateTotpRequest, options?: RequestInit): Promise<FetchResponse<SessionPayload>>;

Summary: Elevate access for an already signed in user using TOTP MFA Verify a TOTP code to elevate the permissions of an already signed in user

This method may return different T based on the response code:

  • 200: SessionPayload
Parameter Type
body ElevateTotpRequest
options? RequestInit

Promise<FetchResponse<SessionPayload>>

elevateWebauthn(options?: RequestInit): Promise<FetchResponse<PublicKeyCredentialRequestOptions>>;

Summary: Elevate access for an already signed in user using FIDO2 Webauthn Generate a Webauthn challenge for elevating user permissions

This method may return different T based on the response code:

  • 200: PublicKeyCredentialRequestOptions
Parameter Type
options? RequestInit

Promise<FetchResponse<PublicKeyCredentialRequestOptions>>

getElevationMethods(options?: RequestInit): Promise<FetchResponse<ElevationMethodsResponse>>;

Summary: Get available elevation methods List the authenticated user’s available elevation methods, whether elevation is required under the configured mode, and whether the current session is elevated.

This method may return different T based on the response code:

  • 200: ElevationMethodsResponse
Parameter Type
options? RequestInit

Promise<FetchResponse<ElevationMethodsResponse>>

getJWKs(options?: RequestInit): Promise<FetchResponse<JWKSet>>;

Summary: Get public keys for JWT verification in JWK Set format Retrieve the JSON Web Key Set (JWKS) containing public keys used to verify JWT signatures. This endpoint is used by clients to validate access tokens.

This method may return different T based on the response code:

  • 200: JWKSet
Parameter Type
options? RequestInit

Promise<FetchResponse<JWKSet>>

getOAuthAuthorizationServer(options?: RequestInit): Promise<FetchResponse<OAuth2DiscoveryResponse>>;

Summary: OAuth2 Authorization Server Metadata Returns the Authorization Server Metadata (RFC 8414). Same content as OpenID Discovery.

This method may return different T based on the response code:

  • 200: OAuth2DiscoveryResponse
Parameter Type
options? RequestInit

Promise<FetchResponse<OAuth2DiscoveryResponse>>

getOpenIDConfiguration(options?: RequestInit): Promise<FetchResponse<OAuth2DiscoveryResponse>>;

Summary: OpenID Connect Discovery Returns the OpenID Provider Metadata (RFC 8414)

This method may return different T based on the response code:

  • 200: OAuth2DiscoveryResponse
Parameter Type
options? RequestInit

Promise<FetchResponse<OAuth2DiscoveryResponse>>

getProviderTokens(provider: SignInProvider, options?: RequestInit): Promise<FetchResponse<ProviderSession>>;

Summary: Retrieve OAuth2 provider tokens from callback After successful OAuth2 authentication, retrieve the provider session containing access token, refresh token, and expiration information for the specified provider. To ensure the data isn’t stale this endpoint must be called immediately after the OAuth callback to obtain the tokens. The session is cleared from the database during this call, so subsequent calls will fail without going through the sign-in flow again. It is the user’s responsibility to store the session safely (e.g., in browser local storage).

This method may return different T based on the response code:

  • 200: ProviderSession
Parameter Type
provider SignInProvider
options? RequestInit

Promise<FetchResponse<ProviderSession>>

getUser(options?: RequestInit): Promise<FetchResponse<User>>;

Summary: Get user information Retrieve the authenticated user’s profile information including roles, metadata, and account status.

This method may return different T based on the response code:

  • 200: User
Parameter Type
options? RequestInit

Promise<FetchResponse<User>>

getVersion(options?: RequestInit): Promise<FetchResponse<GetVersionResponse200>>;

Summary: Get service version Retrieve version information about the authentication service

This method may return different T based on the response code:

  • 200: GetVersionResponse200
Parameter Type
options? RequestInit

Promise<FetchResponse<GetVersionResponse200>>

healthCheckGet(options?: RequestInit): Promise<FetchResponse<"OK">>;

Summary: Health check (GET) Verify if the authentication service is operational using GET method

This method may return different T based on the response code:

  • 200: OKResponse
Parameter Type
options? RequestInit

Promise<FetchResponse<"OK">>

healthCheckHead(options?: RequestInit): Promise<FetchResponse<void>>;

Summary: Health check (HEAD) Verify if the authentication service is operational using HEAD method

This method may return different T based on the response code:

  • 200: void
Parameter Type
options? RequestInit

Promise<FetchResponse<void>>

linkIdToken(body: LinkIdTokenRequest, options?: RequestInit): Promise<FetchResponse<"OK">>;

Summary: Link a user account with the provider’s account using an id token Link the authenticated user’s account with an external OAuth provider account using an ID token. Requires elevated permissions.

This method may return different T based on the response code:

  • 200: OKResponse
Parameter Type
body LinkIdTokenRequest
options? RequestInit

Promise<FetchResponse<"OK">>

oauth2AuthorizePostURL(body: Oauth2AuthorizePostBody, options?: RequestInit): string;

Summary: OAuth2 Authorization Endpoint (POST) Initiates an OAuth2 authorization code flow via POST. Validates the request and redirects to the login UI for user authentication and consent.

As this method is a redirect, it returns a URL string instead of a Promise

Parameter Type
body Oauth2AuthorizePostBody
options? RequestInit

string

oauth2AuthorizeURL(params?: Oauth2AuthorizeParams, options?: RequestInit): string;

Summary: OAuth2 Authorization Endpoint Initiates an OAuth2 authorization code flow. Validates the request and redirects to the login UI for user authentication and consent.

As this method is a redirect, it returns a URL string instead of a Promise

Parameter Type
params? Oauth2AuthorizeParams
options? RequestInit

string

oauth2Introspect(body: OAuth2IntrospectRequest, options?: RequestInit): Promise<FetchResponse<OAuth2IntrospectResponse>>;

Summary: OAuth2 Token Introspection (RFC 7662) Introspect a token to determine its current state and metadata.

This method may return different T based on the response code:

  • 200: OAuth2IntrospectResponse
Parameter Type
body OAuth2IntrospectRequest
options? RequestInit

Promise<FetchResponse<OAuth2IntrospectResponse>>

oauth2Jwks(options?: RequestInit): Promise<FetchResponse<OAuth2JWKSResponse>>;

Summary: OAuth2 Provider JWKS Endpoint Returns the JSON Web Key Set containing public keys used for OAuth2/OIDC token signing.

This method may return different T based on the response code:

  • 200: OAuth2JWKSResponse
Parameter Type
options? RequestInit

Promise<FetchResponse<OAuth2JWKSResponse>>

oauth2LoginGet(params?: Oauth2LoginGetParams, options?: RequestInit): Promise<FetchResponse<OAuth2LoginResponse>>;

Summary: Get authorization request details for consent screen Called by the consent UI to get details about the pending authorization request.

This method may return different T based on the response code:

  • 200: OAuth2LoginResponse
Parameter Type
params? Oauth2LoginGetParams
options? RequestInit

Promise<FetchResponse<OAuth2LoginResponse>>

oauth2LoginPost(body: OAuth2LoginRequest, options?: RequestInit): Promise<FetchResponse<OAuth2LoginCompleteResponse>>;

Summary: Complete login/consent for an authorization request Called by the consent UI after user authenticates and consents. Sets the user on the auth request and redirects back to the client with an authorization code.

This method may return different T based on the response code:

  • 200: OAuth2LoginCompleteResponse
Parameter Type
body OAuth2LoginRequest
options? RequestInit

Promise<FetchResponse<OAuth2LoginCompleteResponse>>

oauth2Revoke(body: OAuth2RevokeRequest, options?: RequestInit): Promise<FetchResponse<void>>;

Summary: OAuth2 Token Revocation (RFC 7009) Revoke an access token or refresh token.

This method may return different T based on the response code:

  • 200: void
Parameter Type
body OAuth2RevokeRequest
options? RequestInit

Promise<FetchResponse<void>>

oauth2Token(body: OAuth2TokenRequest, options?: RequestInit): Promise<FetchResponse<OAuth2TokenResponse>>;

Summary: OAuth2 Token Endpoint Exchange an authorization code for tokens, or refresh an existing token. Supports grant_type authorization_code and refresh_token.

This method may return different T based on the response code:

  • 200: OAuth2TokenResponse
Parameter Type
body OAuth2TokenRequest
options? RequestInit

Promise<FetchResponse<OAuth2TokenResponse>>

oauth2UserinfoGet(options?: RequestInit): Promise<FetchResponse<OAuth2UserinfoResponse>>;

Summary: OpenID Connect UserInfo Endpoint (GET) Returns claims about the authenticated user based on the access token scopes.

This method may return different T based on the response code:

  • 200: OAuth2UserinfoResponse
Parameter Type
options? RequestInit

Promise<FetchResponse<OAuth2UserinfoResponse>>

oauth2UserinfoPost(options?: RequestInit): Promise<FetchResponse<OAuth2UserinfoResponse>>;

Summary: OpenID Connect UserInfo Endpoint (POST) Returns claims about the authenticated user based on the access token scopes.

This method may return different T based on the response code:

  • 200: OAuth2UserinfoResponse
Parameter Type
options? RequestInit

Promise<FetchResponse<OAuth2UserinfoResponse>>

pushChainFunction(chainFunction: ChainFunction): void;

Add a middleware function to the fetch chain

Parameter Type Description
chainFunction ChainFunction The middleware function to add

void

refreshProviderToken(
provider: SignInProvider,
body: RefreshProviderTokenRequest,
options?: RequestInit
): Promise<FetchResponse<ProviderSession>>;

Summary: Refresh OAuth2 provider tokens Refresh the OAuth2 provider access token using a valid refresh token. Returns a new provider session with updated access token, refresh token (if rotated by provider), and expiration information. This endpoint allows maintaining long-lived access to provider APIs without requiring the user to re-authenticate.

This method may return different T based on the response code:

  • 200: ProviderSession
Parameter Type
provider SignInProvider
body RefreshProviderTokenRequest
options? RequestInit

Promise<FetchResponse<ProviderSession>>

refreshToken(body: RefreshTokenRequest, options?: RequestInit): Promise<FetchResponse<Session>>;

Summary: Refresh access token Generate a new JWT access token using a valid refresh token. The refresh token used will be revoked and a new one will be issued.

This method may return different T based on the response code:

  • 200: Session
Parameter Type
body RefreshTokenRequest
options? RequestInit

Promise<FetchResponse<Session>>

sendPasswordResetEmail(body: UserPasswordResetRequest, options?: RequestInit): Promise<FetchResponse<"OK">>;

Summary: Request password reset Request a password reset for a user account. An email with a verification link will be sent to the user’s email address to complete the password reset process.

This method may return different T based on the response code:

  • 200: OKResponse
Parameter Type
body UserPasswordResetRequest
options? RequestInit

Promise<FetchResponse<"OK">>

sendVerificationEmail(body: UserEmailSendVerificationEmailRequest, options?: RequestInit): Promise<FetchResponse<"OK">>;

Summary: Send verification email Send an email verification link to the specified email address. Used to verify email addresses for new accounts or email changes.

This method may return different T based on the response code:

  • 200: OKResponse
Parameter Type
body UserEmailSendVerificationEmailRequest
options? RequestInit

Promise<FetchResponse<"OK">>

signInAnonymous(body?: SignInAnonymousRequest, options?: RequestInit): Promise<FetchResponse<SessionPayload>>;

Summary: Sign in anonymously Create an anonymous user session without providing credentials. Anonymous users can be converted to regular users later via the deanonymize endpoint. This endpoint always creates a new user and is not gated by AUTH_DISABLE_AUTO_SIGNUP; it is controlled by AUTH_DISABLE_SIGNUP and AUTH_ANONYMOUS_USERS_ENABLED.

This method may return different T based on the response code:

  • 200: SessionPayload
Parameter Type
body? SignInAnonymousRequest
options? RequestInit

Promise<FetchResponse<SessionPayload>>

signInEmailPassword(body: SignInEmailPasswordRequest, options?: RequestInit): Promise<FetchResponse<SignInEmailPasswordResponse>>;

Summary: Sign in with email and password Authenticate a user with their email and password. Returns a session object or MFA challenge if two-factor authentication is enabled.

This method may return different T based on the response code:

  • 200: SignInEmailPasswordResponse
Parameter Type
body SignInEmailPasswordRequest
options? RequestInit

Promise<FetchResponse<SignInEmailPasswordResponse>>

signInIdToken(body: SignInIdTokenRequest, options?: RequestInit): Promise<FetchResponse<SessionPayload>>;

Summary: Sign in with an ID token Authenticate using an ID token from a supported OAuth provider (Apple or Google). If the user doesn’t exist and AUTH_DISABLE_AUTO_SIGNUP is not set, a new account will be created. When AUTH_DISABLE_AUTO_SIGNUP is enabled, users must use the /signup/idtoken endpoint to register first.

This method may return different T based on the response code:

  • 200: SessionPayload
Parameter Type
body SignInIdTokenRequest
options? RequestInit

Promise<FetchResponse<SessionPayload>>

signInOTPEmail(body: SignInOTPEmailRequest, options?: RequestInit): Promise<FetchResponse<"OK">>;

Summary: Sign in with email OTP Initiate email-based one-time password authentication. Sends an OTP to the specified email address. If the user doesn’t exist and AUTH_DISABLE_AUTO_SIGNUP is not set, a new account will be created with the provided options. When AUTH_DISABLE_AUTO_SIGNUP is enabled, users must use the /signup/otp/email endpoint to register first.

This method may return different T based on the response code:

  • 200: OKResponse
Parameter Type
body SignInOTPEmailRequest
options? RequestInit

Promise<FetchResponse<"OK">>

signInPasswordlessEmail(body: SignInPasswordlessEmailRequest, options?: RequestInit): Promise<FetchResponse<"OK">>;

Summary: Sign in with magic link email Initiate passwordless authentication by sending a magic link to the user’s email. If the user doesn’t exist and AUTH_DISABLE_AUTO_SIGNUP is not set, a new account will be created with the provided options. When AUTH_DISABLE_AUTO_SIGNUP is enabled, users must use the /signup/passwordless/email endpoint to register first.

This method may return different T based on the response code:

  • 200: OKResponse
Parameter Type
body SignInPasswordlessEmailRequest
options? RequestInit

Promise<FetchResponse<"OK">>

signInPasswordlessSms(body: SignInPasswordlessSmsRequest, options?: RequestInit): Promise<FetchResponse<"OK">>;

Summary: Sign in with SMS OTP Initiate passwordless authentication by sending a one-time password to the user’s phone number. If the user doesn’t exist and AUTH_DISABLE_AUTO_SIGNUP is not set, a new account will be created with the provided options. When AUTH_DISABLE_AUTO_SIGNUP is enabled, users must use the /signup/passwordless/sms endpoint to register first.

This method may return different T based on the response code:

  • 200: OKResponse
Parameter Type
body SignInPasswordlessSmsRequest
options? RequestInit

Promise<FetchResponse<"OK">>

signInPAT(body: SignInPATRequest, options?: RequestInit): Promise<FetchResponse<SessionPayload>>;

Summary: Sign in with Personal Access Token (PAT) Authenticate using a Personal Access Token. PATs are long-lived tokens that can be used for programmatic access to the API.

This method may return different T based on the response code:

  • 200: SessionPayload
Parameter Type
body SignInPATRequest
options? RequestInit

Promise<FetchResponse<SessionPayload>>

signInProviderURL(
provider: SignInProvider,
params?: SignInProviderParams,
options?: RequestInit
): string;

Summary: Sign in with an OAuth2 provider Initiate OAuth2 authentication flow with a social provider. Redirects the user to the provider’s authorization page. If the user doesn’t exist and AUTH_DISABLE_AUTO_SIGNUP is not set, a new account will be created upon callback. When AUTH_DISABLE_AUTO_SIGNUP is enabled, users must use the /signup/provider/{provider} endpoint to register first.

As this method is a redirect, it returns a URL string instead of a Promise

Parameter Type
provider SignInProvider
params? SignInProviderParams
options? RequestInit

string

signInWebauthn(body?: SignInWebauthnRequest, options?: RequestInit): Promise<FetchResponse<PublicKeyCredentialRequestOptions>>;

Summary: Sign in with Webauthn Initiate a Webauthn sign-in process by sending a challenge to the user’s device. The user must have previously registered a Webauthn credential.

This method may return different T based on the response code:

  • 200: PublicKeyCredentialRequestOptions
Parameter Type
body? SignInWebauthnRequest
options? RequestInit

Promise<FetchResponse<PublicKeyCredentialRequestOptions>>

signOut(body: SignOutRequest, options?: RequestInit): Promise<FetchResponse<"OK">>;

Summary: Sign out End the current user session by invalidating refresh tokens. Optionally sign out from all devices.

This method may return different T based on the response code:

  • 200: OKResponse
Parameter Type
body SignOutRequest
options? RequestInit

Promise<FetchResponse<"OK">>

signUpEmailPassword(body: SignUpEmailPasswordRequest, options?: RequestInit): Promise<FetchResponse<SessionPayload>>;

Summary: Sign up with email and password Register a new user account with email and password. Returns a session if email verification is not required, otherwise returns null session.

This method may return different T based on the response code:

  • 200: SessionPayload
Parameter Type
body SignUpEmailPasswordRequest
options? RequestInit

Promise<FetchResponse<SessionPayload>>

signUpIdToken(body: SignUpIdTokenRequest, options?: RequestInit): Promise<FetchResponse<SessionPayload>>;

Summary: Sign up with ID token Register a new user account using an ID token from Apple or Google. Use this endpoint to explicitly register a new account. When AUTH_DISABLE_AUTO_SIGNUP is enabled, this is the only way to register through this method. If the user already exists, a user-already-exists error is returned.

This method may return different T based on the response code:

  • 200: SessionPayload
Parameter Type
body SignUpIdTokenRequest
options? RequestInit

Promise<FetchResponse<SessionPayload>>

signUpOTPEmail(body: SignUpOTPEmailRequest, options?: RequestInit): Promise<FetchResponse<"OK">>;

Summary: Sign up with email OTP Register a new user account using email OTP authentication. Sends a one-time password to the specified email address. Use this endpoint to explicitly register a new account. When AUTH_DISABLE_AUTO_SIGNUP is enabled, this is the only way to register through this method.

This method may return different T based on the response code:

  • 200: OKResponse
Parameter Type
body SignUpOTPEmailRequest
options? RequestInit

Promise<FetchResponse<"OK">>

signUpPasswordlessEmail(body: SignUpPasswordlessEmailRequest, options?: RequestInit): Promise<FetchResponse<"OK">>;

Summary: Sign up with magic link email Register a new user account using passwordless email authentication. Sends a magic link to the specified email address for verification. Use this endpoint to explicitly register a new account. When AUTH_DISABLE_AUTO_SIGNUP is enabled, this is the only way to register through this method.

This method may return different T based on the response code:

  • 200: OKResponse
Parameter Type
body SignUpPasswordlessEmailRequest
options? RequestInit

Promise<FetchResponse<"OK">>

signUpPasswordlessSms(body: SignUpPasswordlessSmsRequest, options?: RequestInit): Promise<FetchResponse<"OK">>;

Summary: Sign up with SMS OTP Register a new user account using SMS OTP authentication. Sends a one-time password to the specified phone number. Use this endpoint to explicitly register a new account. When AUTH_DISABLE_AUTO_SIGNUP is enabled, this is the only way to register through this method.

This method may return different T based on the response code:

  • 200: OKResponse
Parameter Type
body SignUpPasswordlessSmsRequest
options? RequestInit

Promise<FetchResponse<"OK">>

signUpProviderURL(
provider: SignInProvider,
params?: SignUpProviderParams,
options?: RequestInit
): string;

Summary: Sign up with OAuth provider Initiate OAuth signup flow with the specified provider. Redirects to the provider’s authorization page. Use this endpoint to explicitly register a new account. When AUTH_DISABLE_AUTO_SIGNUP is enabled, this is the only way to register through this method. If the user already exists at callback time, they are redirected with error=user-already-exists.

As this method is a redirect, it returns a URL string instead of a Promise

Parameter Type
provider SignInProvider
params? SignUpProviderParams
options? RequestInit

string

signUpWebauthn(body: SignUpWebauthnRequest, options?: RequestInit): Promise<FetchResponse<PublicKeyCredentialCreationOptions>>;

Summary: Sign up with Webauthn Initiate a Webauthn sign-up process by sending a challenge to the user’s device. The user must not have an existing account.

This method may return different T based on the response code:

  • 200: PublicKeyCredentialCreationOptions
Parameter Type
body SignUpWebauthnRequest
options? RequestInit

Promise<FetchResponse<PublicKeyCredentialCreationOptions>>

tokenExchange(body: TokenExchangeRequest, options?: RequestInit): Promise<FetchResponse<SessionPayload>>;

Summary: Exchange authorization code for session Exchange an authorization code (obtained via PKCE flow) together with the original code_verifier for a session containing access and refresh tokens.

This method may return different T based on the response code:

  • 200: SessionPayload
Parameter Type
body TokenExchangeRequest
options? RequestInit

Promise<FetchResponse<SessionPayload>>

verifyAddSecurityKey(body: VerifyAddSecurityKeyRequest, options?: RequestInit): Promise<FetchResponse<VerifyAddSecurityKeyResponse>>;

Summary: Verify adding of a new webauthn security key Complete the process of adding a new WebAuthn security key by verifying the authenticator response. Requires elevated permissions.

This method may return different T based on the response code:

  • 200: VerifyAddSecurityKeyResponse
Parameter Type
body VerifyAddSecurityKeyRequest
options? RequestInit

Promise<FetchResponse<VerifyAddSecurityKeyResponse>>

verifyChangeUserMfa(body: UserMfaRequest, options?: RequestInit): Promise<FetchResponse<"OK">>;

Summary: Manage multi-factor authentication Activate or deactivate multi-factor authentication for the authenticated user

This method may return different T based on the response code:

  • 200: OKResponse
Parameter Type
body UserMfaRequest
options? RequestInit

Promise<FetchResponse<"OK">>

verifyChangeUserPhoneNumber(body: UserPhoneNumberChangeVerifyRequest, options?: RequestInit): Promise<FetchResponse<"OK">>;

Summary: Verify phone number change Complete a previously-requested phone number change by submitting the OTP that was sent via SMS. On success the staged phone number becomes the user’s verified phone number. Requires elevated permissions.

This method may return different T based on the response code:

  • 200: OKResponse
Parameter Type
body UserPhoneNumberChangeVerifyRequest
options? RequestInit

Promise<FetchResponse<"OK">>

verifyElevateOTPEmail(body: ElevateOTPEmailVerifyRequest, options?: RequestInit): Promise<FetchResponse<SessionPayload>>;

Summary: Elevate access for an already signed in user using a one-time password sent by email Verify a one-time password sent by email to elevate the permissions of an already signed in user

This method may return different T based on the response code:

  • 200: SessionPayload
Parameter Type
body ElevateOTPEmailVerifyRequest
options? RequestInit

Promise<FetchResponse<SessionPayload>>

verifyElevateOTPSms(body: ElevateOTPSmsVerifyRequest, options?: RequestInit): Promise<FetchResponse<SessionPayload>>;

Summary: Elevate access for an already signed in user using a one-time password sent by SMS Verify a one-time password sent by SMS to elevate the permissions of an already signed in user

This method may return different T based on the response code:

  • 200: SessionPayload
Parameter Type
body ElevateOTPSmsVerifyRequest
options? RequestInit

Promise<FetchResponse<SessionPayload>>

verifyElevateWebauthn(body: SignInWebauthnVerifyRequest, options?: RequestInit): Promise<FetchResponse<SessionPayload>>;

Summary: Verify FIDO2 Webauthn authentication using public-key cryptography for elevation Complete Webauthn elevation by verifying the authentication response

This method may return different T based on the response code:

  • 200: SessionPayload
Parameter Type
body SignInWebauthnVerifyRequest
options? RequestInit

Promise<FetchResponse<SessionPayload>>

verifySignInMfaTotp(body: SignInMfaTotpRequest, options?: RequestInit): Promise<FetchResponse<SessionPayload>>;

Summary: Verify TOTP for MFA Complete the multi-factor authentication by verifying a Time-based One-Time Password (TOTP). Returns a session if validation is successful.

This method may return different T based on the response code:

  • 200: SessionPayload
Parameter Type
body SignInMfaTotpRequest
options? RequestInit

Promise<FetchResponse<SessionPayload>>

verifySignInOTPEmail(body: SignInOTPEmailVerifyRequest, options?: RequestInit): Promise<FetchResponse<SignInOTPEmailVerifyResponse>>;

Summary: Verify email OTP Complete email OTP authentication by verifying the one-time password. Returns a session if validation is successful.

This method may return different T based on the response code:

  • 200: SignInOTPEmailVerifyResponse
Parameter Type
body SignInOTPEmailVerifyRequest
options? RequestInit

Promise<FetchResponse<SignInOTPEmailVerifyResponse>>

verifySignInPasswordlessSms(body: SignInPasswordlessSmsOtpRequest, options?: RequestInit): Promise<FetchResponse<SignInPasswordlessSmsOtpResponse>>;

Summary: Verify SMS OTP and complete authentication Complete passwordless SMS authentication by verifying the one-time password and returning a session.

This method may return different T based on the response code:

  • 200: SignInPasswordlessSmsOtpResponse
Parameter Type
body SignInPasswordlessSmsOtpRequest
options? RequestInit

Promise<FetchResponse<SignInPasswordlessSmsOtpResponse>>

verifySignInWebauthn(body: SignInWebauthnVerifyRequest, options?: RequestInit): Promise<FetchResponse<SessionPayload>>;

Summary: Verify Webauthn sign-in Complete the Webauthn sign-in process by verifying the response from the user’s device. Returns a session if validation is successful.

This method may return different T based on the response code:

  • 200: SessionPayload
Parameter Type
body SignInWebauthnVerifyRequest
options? RequestInit

Promise<FetchResponse<SessionPayload>>

verifySignUpWebauthn(body: SignUpWebauthnVerifyRequest, options?: RequestInit): Promise<FetchResponse<SessionPayload>>;

Summary: Verify Webauthn sign-up Complete the Webauthn sign-up process by verifying the response from the user’s device. Returns a session if validation is successful.

This method may return different T based on the response code:

  • 200: SessionPayload
Parameter Type
body SignUpWebauthnVerifyRequest
options? RequestInit

Promise<FetchResponse<SessionPayload>>

verifyTicketURL(params?: VerifyTicketParams, options?: RequestInit): string;

Summary: Verify email and authentication tickets Verify tickets created by email verification, magic link authentication, or password reset processes. Redirects the user to the appropriate destination upon successful verification.

As this method is a redirect, it returns a URL string instead of a Promise

Parameter Type
params? VerifyTicketParams
options? RequestInit

string

verifyToken(body?: VerifyTokenRequest, options?: RequestInit): Promise<FetchResponse<string>>;

Summary: Verify JWT token Verify the validity of a JWT access token. If no request body is provided, the Authorization header will be used for verification.

This method may return different T based on the response code:

  • 200: string
Parameter Type
body? VerifyTokenRequest
options? RequestInit

Promise<FetchResponse<string>>


expiresAt: string;

(string) - Expiration date of the PAT

  • Format - date-time
metadata?: Record<string, unknown>;

Example - {"name":"my-pat","used-by":"my-app-cli"}


id: string;

(string) - ID of the PAT

  • Example - "2c35b6f3-c4b9-48e3-978a-d4d0f1d42e24"
  • Pattern - \b[0-9a-f]{8}\b-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-\b[0-9a-f]{12}\b
personalAccessToken: string;

(string) - PAT

  • Example - "2c35b6f3-c4b9-48e3-978a-d4d0f1d42e24"
  • Pattern - \b[0-9a-f]{8}\b-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-\b[0-9a-f]{12}\b

authenticatorAttachment?: string;

The authenticator attachment

clientExtensionResults?: AuthenticationExtensionsClientOutputs;

Map of extension outputs from the client

id: string;

(string) - The credential’s identifier

rawId: string;

(string) - Base64url-encoded binary data

  • Format - byte
response: AuthenticatorAssertionResponse;

(AuthenticatorAssertionResponse) -

type: string;

(string) - The credential type represented by this object


authenticatorAttachment?: string;

The authenticator attachment

clientExtensionResults?: AuthenticationExtensionsClientOutputs;

Map of extension outputs from the client

id: string;

(string) - The credential’s identifier

rawId: string;

(string) - Base64url-encoded binary data

  • Format - byte
response: AuthenticatorAttestationResponse;

(AuthenticatorAttestationResponse) -

type: string;

(string) - The credential type represented by this object


alg: number;

(number) - The cryptographic algorithm identifier

type: "public-key";

(CredentialType) - The valid credential types


Credential properties extension output

rk?: boolean;

Indicates if the credential is a resident key


otp: string;

(string) - One time password


otp: string;

(string) - One time password


otp: string;

(string) - One time password


Elevation status of the user

elevationRequired: boolean;

(boolean) - Whether protected endpoints require an elevated session. When true and no methods are available, the user must set up a second factor first

  • Example - true
methods: ElevationMethod[];

(ElevationMethod[]) - Methods the user can use to elevate their session

  • Example - ["webauthn","totp"]
sessionElevated: boolean;

(boolean) - Whether the bearer token has an elevated claim matching its subject

  • Example - false

Standardized error response

error: ErrorResponseError;

(ErrorResponseError) - Error code identifying the specific application error

message: string;

(string) - Human-friendly error message

  • Example - "Invalid email format"
status: number;

(number) - HTTP status error code

  • Example - 400

version: string;

(string) - The version of the authentication service

  • Example - "1.2.3"

JSON Web Key for JWT verification

alg: string;

(string) - Algorithm used with this key

  • Example - "RS256"
e: string;

(string) - RSA public exponent

  • Example - "AQAB"
kid: string;

(string) - Key ID

  • Example - "key-id-1"
kty: string;

(string) - Key type

  • Example - "RSA"
n: string;

(string) - RSA modulus

  • Example - "abcd1234..."
use: string;

(string) - Key usage

  • Example - "sig"

JSON Web Key Set for verifying JWT signatures

keys: JWK[];

(JWK[]) - Array of public keys


idToken: string;

(string) - Apple ID token

nonce?: string;

Nonce used during sign in process

provider: IdTokenProvider;

(IdTokenProvider) -


Challenge payload for multi-factor authentication

ticket: string;

(string) - Ticket to use when completing the MFA challenge

  • Example - "mfaTotp:abc123def456"

Parameters for the oauth2Authorize method.

client_id: string;

(string) - The OAuth2 client identifier (RFC 6749 Section 2.2).

code_challenge?: string;

PKCE code challenge derived from the code verifier (RFC 7636 Section 4.2).

code_challenge_method?: "S256";

Only S256 is supported. The plain method is not allowed.

nonce?: string;

String value used to associate a client session with an ID token (OpenID Connect Core Section 3.1.2.1).

prompt?: string;

Space-delimited list of prompts to present to the user (OpenID Connect Core Section 3.1.2.1).

redirect_uri: string;

(string) - The URI to redirect the user-agent to after authorization (RFC 6749 Section 3.1.2).

resource?: string;

Resource indicator for the target service (RFC 8707).

response_type: string;

(string) - The authorization response type. Only ‘code’ is supported (RFC 6749 Section 3.1.1).

scope?: string;

Space-delimited list of requested scopes (RFC 6749 Section 3.3).

state?: string;

Opaque value used to maintain state between the request and callback (RFC 6749 Section 4.1.1).


client_id: string;

(string) -

code_challenge?: string;
code_challenge_method?: string;

Only S256 is supported. The plain method is not allowed.

nonce?: string;
prompt?: string;
redirect_uri: string;

(string) -

resource?: string;
response_type: string;

(string) -

scope?: string;
state?: string;

authorization_endpoint: string;

(string) -

authorization_response_iss_parameter_supported?

Section titled “authorization_response_iss_parameter_supported?”
authorization_response_iss_parameter_supported?: boolean;
claims_supported?: string[];
client_id_metadata_document_supported?: boolean;
code_challenge_methods_supported?: string[];
grant_types_supported?: string[];
id_token_signing_alg_values_supported?: string[];
introspection_endpoint?: string;
issuer: string;

(string) -

jwks_uri: string;

(string) -

request_parameter_supported?: boolean;
response_types_supported: string[];

(string[]) -

revocation_endpoint?: string;
scopes_supported?: string[];
subject_types_supported?: string[];
token_endpoint: string;

(string) -

token_endpoint_auth_methods_supported?: string[];
userinfo_endpoint?: string;

error: string;

(string) - OAuth2 error code

error_description?: string;

Human-readable error description


client_id?: string;
client_secret?: string;
token: string;

(string) -

token_type_hint?: OAuth2IntrospectRequestToken_type_hint;

active: boolean;

(boolean) -

client_id?: string;
exp?: number;
iat?: number;
iss?: string;
scope?: string;
sub?: string;
token_type?: string;

keys: JWK[];

(JWK[]) -


redirectUri: string;

(string) -

  • Format - uri

Parameters for the oauth2LoginGet method.

request_id: string;

(string) - The pending authorization request identifier.


requestId: string;

(string) -

  • Format - uuid

clientId: string;

(string) -

redirectUri: string;

(string) -

requestId: string;

(string) -

  • Format - uuid
scopes: string[];

(string[]) -


client_id?: string;
client_secret?: string;
token: string;

(string) -

token_type_hint?: OAuth2RevokeRequestToken_type_hint;

client_id?: string;
client_secret?: string;
code?: string;
code_verifier?: string;
grant_type: OAuth2TokenRequestGrant_type;

(OAuth2TokenRequestGrant_type) -

redirect_uri?: string;
refresh_token?: string;
resource?: string;

access_token: string;

(string) -

expires_in: number;

(number) -

id_token?: string;
refresh_token?: string;
scope?: string;
token_type: string;

(string) -


email?: string;
email_verified?: boolean;
locale?: string;
name?: string;
phone_number?: string;
phone_number_verified?: boolean;
picture?: string;
sub: string;

(string) -


redirectTo?: string;

Example - "https://my-app.com/catch-redirection" Format - uri


OAuth2 provider session containing access and refresh tokens

accessToken: string;

(string) - OAuth2 provider access token for API calls

  • Example - "ya29.a0AfH6SMBx..."
expiresAt: string;

(string) - Timestamp when the access token expires

  • Example - "2024-12-31T23:59:59Z"
  • Format - date-time
expiresIn: number;

(number) - Number of seconds until the access token expires

  • Example - 3599
refreshToken?: string;

OAuth2 provider refresh token for obtaining new access tokens (if provided by the provider) Example - "1//0gK8..."


connection?: string;

(workos) Specifies the connection to use for authentication

organization?: string;

(workos) Specifies the organization to use for authentication


attestation?: ConveyancePreference;

The attestation conveyance preference

attestationFormats?: AttestationFormat[];

The preferred attestation statement formats

authenticatorSelection?: AuthenticatorSelection;
challenge: string;

(string) - Base64url-encoded binary data

  • Format - byte
excludeCredentials?: PublicKeyCredentialDescriptor[];

A list of PublicKeyCredentialDescriptor objects representing public key credentials that are not acceptable to the caller

extensions?: Record<string, unknown>;

Additional parameters requesting additional processing by the client and authenticator

hints?: PublicKeyCredentialHints[];

Hints to help guide the user through the experience

pubKeyCredParams: CredentialParameter[];

(CredentialParameter[]) - The desired credential types and their respective cryptographic parameters

rp: RelyingPartyEntity;

(RelyingPartyEntity) -

timeout?: number;

A time, in milliseconds, that the caller is willing to wait for the call to complete

user: UserEntity;

(UserEntity) -


id: string;

(string) - Base64url-encoded binary data

  • Format - byte
transports?: AuthenticatorTransport[];

The authenticator transports that can be used

type: "public-key";

(CredentialType) - The valid credential types


allowCredentials?: PublicKeyCredentialDescriptor[];

A list of CredentialDescriptor objects representing public key credentials acceptable to the caller

challenge: string;

(string) - Base64url-encoded binary data

  • Format - byte
extensions?: Record<string, unknown>;

Additional parameters requesting additional processing by the client and authenticator

hints?: PublicKeyCredentialHints[];

Hints to help guide the user through the experience

rpId?: string;

The RP ID the credential should be scoped to

timeout?: number;

A time, in milliseconds, that the caller is willing to wait for the call to complete

userVerification?: UserVerificationRequirement;

A requirement for user verification for the operation


Request to refresh OAuth2 provider tokens

refreshToken: string;

(string) - OAuth2 provider refresh token obtained from previous authentication

  • Example - "1//0gK8..."

Request to refresh an access token

refreshToken: string;

(string) - Refresh token used to generate a new access token

  • Example - "2c35b6f3-c4b9-48e3-978a-d4d0f1d42e24"
  • Pattern - \b[0-9a-f]{8}\b-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-\b[0-9a-f]{12}\b

id: string;

(string) - A unique identifier for the Relying Party entity, which sets the RP ID

name: string;

(string) - A human-palatable name for the entity


User authentication session containing tokens and user information

accessToken: string;

(string) - JWT token for authenticating API requests

  • Example - "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
accessTokenExpiresIn: number;

(number) - Expiration time of the access token in seconds

  • Example - 900
  • Format - int64
refreshToken: string;

(string) - Token used to refresh the access token

  • Example - "2c35b6f3-c4b9-48e3-978a-d4d0f1d42e24"
  • Pattern - \b[0-9a-f]{8}\b-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-\b[0-9a-f]{12}\b
refreshTokenId: string;

(string) - Identifier for the refresh token

  • Example - "2c35b6f3-c4b9-48e3-978a-d4d0f1d42e24"
  • Pattern - \b[0-9a-f]{8}\b-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-\b[0-9a-f]{12}\b
user?: User;

User profile and account information


Container for session information

session?: Session;

User authentication session containing tokens and user information


displayName?: string;

Example - "John Smith"

locale?: string;

A two or three characters locale Example - "en" MinLength - 2 MaxLength - 3

metadata?: Record<string, unknown>;

Example - {"firstName":"John","lastName":"Smith"}


Request to authenticate using email and password

email: string;

(string) - User’s email address

  • Example - "john.smith@nhost.io"
  • Format - email
password: string;

(string) - User’s password

  • Example - "Str0ngPassw#ord-94|%"
  • MinLength - 3
  • MaxLength - 50

Response for email-password authentication that may include a session or MFA challenge

mfa?: MFAChallengePayload;

Challenge payload for multi-factor authentication

session?: Session;

User authentication session containing tokens and user information


idToken: string;

(string) - Apple ID token

nonce?: string;

Nonce used during sign in process

options?: SignUpOptions;
provider: IdTokenProvider;

(IdTokenProvider) -


otp: string;

(string) - One time password

ticket: string;

(string) - Ticket

  • Pattern - ^mfaTotp:.*$

email: string;

(string) - A valid email

  • Example - "john.smith@nhost.io"
  • Format - email
options?: SignUpOptions;

email: string;

(string) - A valid email

  • Example - "john.smith@nhost.io"
  • Format - email
otp: string;

(string) - One time password


session?: Session;

User authentication session containing tokens and user information


codeChallenge?: string;

PKCE code challenge (S256). When provided, the verification redirect will contain an authorization code instead of a refresh token. Pattern - ^[A-Za-z0-9_-]{43}$ MinLength - 43 MaxLength - 43

email: string;

(string) - A valid email

  • Example - "john.smith@nhost.io"
  • Format - email
options?: SignUpOptions;

otp: string;

(string) - One-time password received by SMS

phoneNumber: string;

(string) - Phone number of the user

  • Example - "+123456789"

mfa?: MFAChallengePayload;

Challenge payload for multi-factor authentication

session?: Session;

User authentication session containing tokens and user information


options?: SignUpOptions;
phoneNumber: string;

(string) - Phone number of the user

  • Example - "+123456789"

personalAccessToken: string;

(string) - PAT

  • Example - "2c35b6f3-c4b9-48e3-978a-d4d0f1d42e24"
  • Pattern - \b[0-9a-f]{8}\b-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-\b[0-9a-f]{12}\b

Parameters for the signInProvider method.

allowedRoles?: string[];

Array of allowed roles for the user

codeChallenge?: string;

PKCE code challenge (S256). When provided, the callback redirect will contain an authorization code instead of a refresh token.

connect?: string;

If set, this means that the user is already authenticated and wants to link their account. This needs to be a valid JWT access token.

defaultRole?: string;

Default role for the user

displayName?: string;

Display name for the user

locale?: string;

A two or three characters locale

metadata?: Record<string, unknown>;

Additional metadata for the user (JSON encoded string)

providerSpecificParams?: ProviderSpecificParams;

Additional provider-specific parameters

redirectTo?: string;

URI to redirect to

state?: string;

Opaque state value to be returned by the provider

upstreamParams?: Record<string, string>;

Extra parameters forwarded to the upstream OAuth2 provider’s authorization URL. Reserved OAuth2/OIDC parameters are rejected.

  • Extra parameters forwarded to the upstream OAuth2 provider’s authorization URL (e.g. Google’s prompt or login_hint). Reserved OAuth2/OIDC parameters are rejected.

email?: string;

A valid email Example - "john.smith@nhost.io" Format - email


credential: CredentialAssertionResponse;

(CredentialAssertionResponse) -

email?: string;

A valid email. Deprecated, no longer used Example - "john.smith@nhost.io" Format - email


all?: boolean;

Sign out from all connected devices

refreshToken?: string;

Refresh token for the current session


Request to register a new user with email and password

codeChallenge?: string;

PKCE code challenge (S256). When provided and email verification is required, the verification redirect will contain an authorization code instead of a refresh token. Pattern - ^[A-Za-z0-9_-]{43}$ MinLength - 43 MaxLength - 43

email: string;

(string) - Email address for the new user account

  • Example - "john.smith@nhost.io"
  • Format - email
options?: SignUpOptions;
password: string;

(string) - Password for the new user account

  • Example - "Str0ngPassw#ord-94|%"
  • MinLength - 3
  • MaxLength - 50

idToken: string;

(string) - Apple or Google ID token

nonce?: string;

Nonce used during sign in process

options?: SignUpOptions;
provider: IdTokenProvider;

(IdTokenProvider) -


allowedRoles?: string[];

Example - ["me","user"]

defaultRole?: string;

Example - "user"

displayName?: string;

Example - "John Smith" Pattern - ^[\p{L}\p{N}\p{S} ,.’-]+$ MaxLength - 32

locale?: string;

A two or three characters locale Example - "en" MinLength - 2 MaxLength - 3

metadata?: Record<string, unknown>;

Example - {"firstName":"John","lastName":"Smith"}

redirectTo?: string;

Example - "https://my-app.com/catch-redirection" Format - uri


email: string;

(string) - A valid email

  • Example - "john.smith@nhost.io"
  • Format - email
options?: SignUpOptions;

codeChallenge?: string;

PKCE code challenge (S256). When provided, the verification redirect will contain an authorization code instead of a refresh token. Pattern - ^[A-Za-z0-9_-]{43}$ MinLength - 43 MaxLength - 43

email: string;

(string) - A valid email

  • Example - "john.smith@nhost.io"
  • Format - email
options?: SignUpOptions;

options?: SignUpOptions;
phoneNumber: string;

(string) - Phone number of the user

  • Example - "+123456789"

Parameters for the signUpProvider method.

allowedRoles?: string[];

Array of allowed roles for the user

codeChallenge?: string;

PKCE code challenge (S256). When provided, the callback redirect will contain an authorization code instead of a refresh token.

defaultRole?: string;

Default role for the user

displayName?: string;

Display name for the user

locale?: string;

A two or three characters locale

metadata?: Record<string, unknown>;

Additional metadata for the user (JSON encoded string)

providerSpecificParams?: ProviderSpecificParams;

Additional provider-specific parameters

redirectTo?: string;

URI to redirect to

state?: string;

Opaque state value to be returned by the provider

upstreamParams?: Record<string, string>;

Extra parameters forwarded to the upstream OAuth2 provider’s authorization URL. Reserved OAuth2/OIDC parameters are rejected.

  • Extra parameters forwarded to the upstream OAuth2 provider’s authorization URL (e.g. Google’s prompt or login_hint). Reserved OAuth2/OIDC parameters are rejected.

email: string;

(string) - A valid email

  • Example - "john.smith@nhost.io"
  • Format - email
options?: SignUpOptions;

codeChallenge?: string;

PKCE code challenge (S256). When provided and email verification is required, the verification redirect will contain an authorization code instead of a refresh token. Pattern - ^[A-Za-z0-9_-]{43}$ MinLength - 43 MaxLength - 43

credential: CredentialCreationResponse;

(CredentialCreationResponse) -

nickname?: string;

Nickname for the security key

options?: SignUpOptions;

Request to exchange an authorization code for a session using PKCE

code: string;

(string) - The authorization code received from the redirect

codeVerifier: string;

(string) - The original PKCE code verifier (43-128 characters)

  • MinLength - 43
  • MaxLength - 128

Response containing TOTP setup information for MFA

imageUrl: string;

(string) - URL to QR code image for scanning with an authenticator app

  • Example - "data:image/png;base64,iVBORw0KGg..."
totpSecret: string;

(string) - TOTP secret key for manual setup with an authenticator app

  • Example - "ABCDEFGHIJK23456"

User profile and account information

activeMfaType?: string;

Active MFA type for the user

avatarUrl: string;

(string) - URL to the user’s profile picture

  • Example - "https://myapp.com/avatars/user123.jpg"
createdAt: string;

(string) - Timestamp when the user account was created

  • Example - "2023-01-15T12:34:56Z"
  • Format - date-time
defaultRole: string;

(string) - Default authorization role for the user

  • Example - "user"
displayName: string;

(string) - User’s display name

  • Example - "John Smith"
email?: string;

User’s email address Example - "john.smith@nhost.io" Format - email

emailVerified: boolean;

(boolean) - Whether the user’s email has been verified

  • Example - true
id: string;

(string) - Unique identifier for the user

  • Example - "2c35b6f3-c4b9-48e3-978a-d4d0f1d42e24"
  • Pattern - \b[0-9a-f]{8}\b-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-\b[0-9a-f]{12}\b
isAnonymous: boolean;

(boolean) - Whether this is an anonymous user account

  • Example - false
locale: string;

(string) - User’s preferred locale (language code)

  • Example - "en"
  • MinLength - 2
  • MaxLength - 3
metadata: Record<string, unknown> | null;

(Record<string, unknown> | null) - Custom metadata associated with the user

  • Example - {"firstName":"John","lastName":"Smith"}
phoneNumber?: string;

User’s phone number Example - "+12025550123"

phoneNumberVerified: boolean;

(boolean) - Whether the user’s phone number has been verified

  • Example - false
roles: string[];

(string[]) - List of roles assigned to the user

  • Example - ["user","customer"]

codeChallenge?: string;

PKCE code challenge (S256). When provided, the verification redirect will contain an authorization code instead of a refresh token. Pattern - ^[A-Za-z0-9_-]{43}$ MinLength - 43 MaxLength - 43

connection?: string;

Deprecated, will be ignored

email: string;

(string) - A valid email

  • Example - "john.smith@nhost.io"
  • Format - email
options?: SignUpOptions;
password?: string;

A password of minimum 3 characters Example - "Str0ngPassw#ord-94|%" MinLength - 3 MaxLength - 50

signInMethod: UserDeanonymizeRequestSignInMethod;

(UserDeanonymizeRequestSignInMethod) - Which sign-in method to use


options?: SignUpOptions;
phoneNumber: string;

(string) - Phone number of the user

  • Example - "+123456789"

codeChallenge?: string;

PKCE code challenge (S256). When provided, the verification redirect will contain an authorization code instead of a refresh token. Pattern - ^[A-Za-z0-9_-]{43}$ MinLength - 43 MaxLength - 43

newEmail: string;

(string) - A valid email

  • Example - "john.smith@nhost.io"
  • Format - email
options?: OptionsRedirectTo;

codeChallenge?: string;

PKCE code challenge (S256). When provided, the verification redirect will contain an authorization code instead of a refresh token. Pattern - ^[A-Za-z0-9_-]{43}$ MinLength - 43 MaxLength - 43

email: string;

(string) - A valid email

  • Example - "john.smith@nhost.io"
  • Format - email
options?: OptionsRedirectTo;

displayName: string;

(string) - A human-palatable name for the user account, intended only for display

id: string;

(string) - The user handle of the user account entity

name: string;

(string) - A human-palatable name for the entity


Request to activate or deactivate multi-factor authentication

activeMfaType?: UserMfaRequestActiveMfaType;

Type of MFA to activate. Use empty string to disable MFA. Example - "totp"

code: string;

(string) - Verification code from the authenticator app when activating MFA

  • Example - "123456"

newPassword: string;

(string) - A password of minimum 3 characters

  • Example - "Str0ngPassw#ord-94|%"
  • MinLength - 3
  • MaxLength - 50
ticket?: string;

Ticket to reset the password, required if the user is not authenticated Pattern - ^passwordReset:.*$


codeChallenge?: string;

PKCE code challenge (S256). When provided, the verification redirect will contain an authorization code instead of a refresh token. Pattern - ^[A-Za-z0-9_-]{43}$ MinLength - 43 MaxLength - 43

email: string;

(string) - A valid email

  • Example - "john.smith@nhost.io"
  • Format - email
options?: OptionsRedirectTo;

newPhoneNumber: string;

(string) - New phone number to bind to the user once verified via SMS OTP

  • Example - "+123456789"

newPhoneNumber: string;

(string) - The phone number that was previously requested via /user/phone-number/change

  • Example - "+123456789"
otp: string;

(string) - One-time password received via SMS at the new phone number

  • Example - "123456"

credential: CredentialCreationResponse;

(CredentialCreationResponse) -

nickname?: string;

Optional nickname for the security key


id: string;

(string) - The ID of the newly added security key

  • Example - "123e4567-e89b-12d3-a456-426614174000"
nickname?: string;

The nickname of the security key if provided


Parameters for the verifyTicket method.

codeChallenge?: string;

PKCE code challenge (S256). When present, the redirect will contain an authorization code instead of a refresh token.

redirectTo: string;

(RedirectToQuery) - Target URL for the redirect

  • Target URL for the redirect
ticket: string;

(TicketQuery) - Ticket

  • Ticket
type?: TicketTypeQuery;

Type of the ticket. Deprecated, no longer used

  • Type of the ticket

token?: string;

JWT token to verify

type AttestationFormat =
| "packed"
| "tpm"
| "android-key"
| "android-safetynet"
| "fido-u2f"
| "apple"
| "none";

The attestation statement format


type AuthenticatorAttachment = "platform" | "cross-platform";

The authenticator attachment modality


type AuthenticatorTransport =
"usb" | "nfc" | "ble" | "smart-card" | "hybrid" | "internal";

The authenticator transports that can be used


type ConveyancePreference = "none" | "indirect" | "direct" | "enterprise";

The attestation conveyance preference


type CredentialType = "public-key";

The valid credential types


type ElevationMethod = "webauthn" | "totp" | "otp-email" | "otp-sms";

Method that can be used to elevate a session


type ErrorResponseError =
| "default-role-must-be-in-allowed-roles"
| "disabled-endpoint"
| "disabled-user"
| "user-already-exists"
| "email-already-verified"
| "forbidden-anonymous"
| "internal-server-error"
| "invalid-email-password"
| "invalid-request"
| "locale-not-allowed"
| "password-too-short"
| "password-in-hibp-database"
| "redirectTo-not-allowed"
| "role-not-allowed"
| "signup-disabled"
| "unverified-user"
| "user-not-anonymous"
| "invalid-pat"
| "invalid-refresh-token"
| "invalid-ticket"
| "disabled-mfa-totp"
| "no-totp-secret"
| "invalid-totp"
| "mfa-type-not-found"
| "totp-already-active"
| "invalid-state"
| "oauth-token-echange-failed"
| "oauth-profile-fetch-failed"
| "oauth-provider-error"
| "invalid-otp"
| "otp-too-many-attempts"
| "cannot-send-sms"
| "provider-account-already-linked";

Error code identifying the specific application error


type GetCode_challenge_method = "S256";

type IdTokenProvider = "apple" | "google";

type OAuth2IntrospectRequestToken_type_hint = "access_token" | "refresh_token";

type OAuth2RevokeRequestToken_type_hint = "access_token" | "refresh_token";

type OAuth2TokenRequestGrant_type = "authorization_code" | "refresh_token";

type OKResponse = "OK";

type PublicKeyCredentialHints = "security-key" | "client-device" | "hybrid";

Hints to help guide the user through the experience


type RedirectToQuery = string;

Target URL for the redirect


type ResidentKeyRequirement = "discouraged" | "preferred" | "required";

The resident key requirement


type SignInProvider =
| "apple"
| "github"
| "google"
| "linkedin"
| "discord"
| "spotify"
| "twitch"
| "gitlab"
| "bitbucket"
| "workos"
| "azuread"
| "entraid"
| "strava"
| "facebook"
| "windowslive"
| "twitter";

type TicketQuery = string;

Ticket


type TicketTypeQuery =
"emailVerify" | "emailConfirmChange" | "signinPasswordless" | "passwordReset";

Type of the ticket


type URLEncodedBase64 = string;

Base64url-encoded binary data


type UserDeanonymizeRequestSignInMethod = "email-password" | "passwordless";

Which sign-in method to use


type UserMfaRequestActiveMfaType = "totp" | "";

Type of MFA to activate. Use empty string to disable MFA.


type UserVerificationRequirement = "required" | "preferred" | "discouraged";

A requirement for user verification for the operation

function createAPIClient(
baseURL: string,
chainFunctions?: ChainFunction[],
): Client;
Parameter Type Default value
baseURL string undefined
chainFunctions? ChainFunction[] []

Client


function generateCodeChallenge(verifier: string): Promise<string>;

Derive a S256 code challenge from a code verifier.

Parameter Type
verifier string

Promise<string>


function generateCodeVerifier(): string;

Generate a cryptographically random PKCE code verifier (43 base64url characters).

string


function generatePKCEPair(): Promise<{
challenge: string;
verifier: string;
}>;

Generate a PKCE code verifier and its S256 challenge in one call.

Promise<{ challenge: string; verifier: string; }>