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.
403 auth/user-token-required or oauth/user-token-required), so this SDK has no functions for them. Call them from your client with the user’s session. To delete an account from your server, use users.deleteUser.
signUp
Creates a new user account and returns credentials.The user’s birthdate: a
Date, or a full UTC timestamp string such as "1990-05-17T00:00:00.000Z". A date alone ("1990-05-17") or a time with an offset is refused with 400 auth/invalid-body and param: "birthdate".Key-value data no API response returns to any user. Users can also write their own, so don’t treat it as trusted.
How the confirmation email is sent when the project requires email verification before sign-in.
mode defaults to "link"; "code" emails a 6-digit code and returns a verificationId. redirectUrl (link mode) must be on the project’s Verified Domains. Ignored when the setting is off. See Sign Up.An avatar image to upload, up to 50 MB. Raw bytes carry no type, so pass
mimeType with a Uint8Array (image/jpeg, image/png or image/webp; without it the file goes as application/octet-stream and is refused with 400 auth/unsupported-file-type); a Blob keeps its own type. options says how to process the image and must include mode (see Upload Image). With an image, the request is sent as multipart/form-data.A banner image to upload; same shape as
avatarFile.Promise<SignUpResponse | EmailVerificationRequiredResponse>: { success: true, user, accessToken, refreshToken }, or, when the project requires email verification before sign-in, { success: true, emailVerificationRequired: true, verificationId? } with no tokens.
signIn
Authenticates an existing user and returns fresh credentials.How the new confirmation email is sent when sign-in is refused because the account’s email isn’t confirmed. Ignored when the project doesn’t require email verification before sign-in.
Promise<{ success: true; user: AuthUser; accessToken: string; refreshToken: string }> (see AuthUser)
When the project requires email verification before sign-in and the account’s email isn’t confirmed, a correct password rejects with a 403 whose body is EmailNotVerifiedErrorBody ({ error, code: "auth/email-not-verified", verificationId? }, read from err.response.data), and a new confirmation email is sent (unless one went out in the last 10 minutes).
signOut
Invalidates a refresh token, ending the user’s session.Optional. The device the user is signing out on —
{ platform: "ios" | "android", token }
or { platform: "web", subscription }. When supplied (and the project has the
push bundle), the server deletes that user’s push binding for the device in the
same transaction as the sign-out. Omit it and the sign-out revokes the token
family only, leaving any push binding in place.Promise<SignOutPushUnbindSkipped | null>: null when signed out (204), or { pushUnbindSkipped: true, code: "auth/push-unbind-status-unknown", message } (200) when signed out without the requested push unbind.
requestNewAccessToken
Exchanges a valid refresh token for a new access token. The refresh token rotates: store the returnedrefreshToken in place of the one you sent.
Promise<RequestNewAccessTokenResponse>: { success: true, accessToken, refreshToken, user: AuthUser }, or { user: null, accessToken: null } when refreshToken is empty.
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.Promise<{ success: true; user: AuthUser; accessToken: string; refreshToken: string }> (see AuthUser)
requestPasswordReset
Sends a password reset email to the specified address.Promise<void>
resetPassword
Completes a password reset using a token from the reset email. This revokes every session for that user and removes every push binding they hold, on every device — a reset is the remedy for a suspected compromise, so nothing is spared and there is no field to spare one with. The user signs in again everywhere, and each device re-binds for push on its own once it is next opened. Projects without thepush bundle skip the binding step and are otherwise unaffected. Contrast Change Password, which a user calls with their own access token: it keeps their current session and can keep one device’s binding.
Promise<void>
verifyEmail
Marks a user’s email address as verified using a code from the verification email.The
verificationId returned with a sign-up code (by signUp, or in the body of a sign-in refused with auth/email-not-verified). Required to confirm such a code; leave it out for a code from sendVerificationEmail.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.mode defaults to "code". In code mode tokenFormat is required and decides what else applies — tokenLength only with a short format, never with "hex" — enforced by TypeScript as a discriminated union, not just documented:
"code" (the default) emails a short token the user enters; "link" emails a verification URL.Format of the generated token.
- Required in code mode — the server’s default is
"hex", which produces a 64-character token no one would want to type, so the SDK makes you choose. - Optional when
mode: "link"(defaults to"hex") — the token sits in a URL, never read by a human, so format doesn’t matter.
Length of the generated token (4–12).
- Optional in code mode with a
"numeric","alpha"or"alphanumeric"token (defaults to6). - Not allowed when
tokenFormatis"hex"— hex ignores length and always produces a fixed 64-character token. - Optional when
mode: "link"(defaults to6).
For
mode: "link" only (TypeScript refuses it in code mode) — where to send the user after the link is verified; null for none.Must be an https address on one of your project’s Verified Domains (Dashboard → Settings → Domains). Each entry covers exactly the host it names, never its subdomains: example.com allows https://example.com/… on any port, but not www.example.com, which needs its own entry. A full address such as https://app.example.com covers only that host and port. localhost and *.localhost are always allowed, over http too. Anything else, including a custom-scheme deep link such as myapp://verified, is refused with 400 auth/redirect-url-not-allowed and no email is sent.Promise<void>
