auth module handles user authentication flows server-side. This is useful for custom onboarding pipelines, admin-initiated account creation, token introspection, and password management.
All auth functions operate on behalf of your project. The caller is your server, authenticated via API key — not an end user.
signUp
Creates a new user account and returns credentials.The user’s email address.
The user’s plain-text password (hashed server-side).
Display name for the user.
Unique username. Must be available — check with
users.checkUsernameAvailability first.Arbitrary key-value data attached to the user at creation time.
Promise<{ user: AuthUser; accessToken: string; refreshToken: string }>
signIn
Authenticates an existing user and returns fresh credentials.The user’s email address.
The user’s password.
Promise<{ user: AuthUser; accessToken: string; refreshToken: string }>
signOut
Invalidates a refresh token, ending the user’s session.The refresh token to invalidate.
Promise<void>
requestNewAccessToken
Exchanges a valid refresh token for a new access token.A valid, non-expired refresh token.
Promise<{ accessToken: string }>
verifyExternalUser
Verifies a signed JWT representing an externally-authenticated user and returns Sublay credentials. Use this when your application manages its own auth and you want to associate users with Sublay.A JWT signed with your project’s signing secret, containing user identity claims.
Promise<{ user: AuthUser; accessToken: string; refreshToken: string }>
requestPasswordReset
Sends a password reset email to the specified address.The email address to send the reset link to.
Promise<void>
resetPassword
Completes a password reset using a token from the reset email.The reset token from the password reset email link.
The new password to set for the account.
Promise<void>
verifyEmail
Marks a user’s email address as verified using a token from the verification email.The email verification token.
Promise<void>
sendVerificationEmail
Sends (or re-sends) an email-verification message to a user. Verification can be delivered as a short code or as a clickable link.The Sublay user ID to send the verification email to.
"code" emails a short token the user enters; "link" emails a verification URL. Defaults to "code".Format of the generated token:
"hex", "numeric", "alpha", or "alphanumeric".Length of the generated token.
For
mode: "link" — where to send the user after the link is verified.Promise<{ success: boolean }>
changePassword
Changes a user’s password, verifying their current password first. Use this for an authenticated “change password” flow (as opposed to the token-basedresetPassword).
The Sublay user ID whose password to change.
The user’s current password (verified before the change).
The new password to set.
Promise<{ success: boolean; message: string }>
