Avnology ID
SDKsTypeScript SDKAuthentication

Register

Create new user accounts and verify email addresses with the TypeScript SDK.

Register

Create new user accounts with email/password, collect profile data, and verify email addresses.

register()

Create a new user account with email, password, and optional profile traits.

register(params: RegisterParams): Promise<Session>

Parameters

NameTypeRequiredDescription
emailstringyesUser's email address
passwordstringyesPassword (min 8 characters, checked against breach database)
traitsUserTraitsnoProfile data (name, phone, locale, timezone)
organizationIdstringnoRegister directly into an organization

UserTraits

FieldTypeDescription
name.firststringFirst name
name.laststringLast name
phonestringPhone number in E.164 format
localestringPreferred locale (e.g., "en-US")
timezonestringIANA timezone (e.g., "America/New_York")

Returns

Promise<Session> -- The new session. The user is automatically logged in after registration. If email verification is required, the session is created but marked as unverified until the user confirms their email.

Basic usage

import { AvnologyId } from "@avnology/sdk-typescript";

const client = new AvnologyId({
  baseUrl: "https://api.id.avnology.com",
  clientId: "app_abc123",
});

const session = await client.register({
  email: "[email protected]",
  password: "SecurePassword123!",
  traits: {
    name: { first: "Jane", last: "Doe" },
    phone: "+15550100",
    locale: "en-US",
    timezone: "America/New_York",
  },
});

console.log(session.identity.id);    // "usr_abc123..."
console.log(session.identity.email); // "[email protected]"
console.log(session.identity.verifiedAt); // null (pending verification)

Organization registration

Register a user directly into an organization. The organization must allow open registration or the user must have an invitation.

const session = await client.register({
  email: "[email protected]",
  password: "SecurePassword123!",
  traits: { name: { first: "Jane", last: "Doe" } },
  organizationId: "org_abc123",
});

console.log(session.identity.organizationId); // "org_abc123"

Registration with social provider

To register via a social provider (Google, GitHub, Microsoft, Apple), use the same loginWithProvider() method. If the user does not have an existing account, one is automatically created during the OAuth callback.

// This creates a new account if one doesn't exist
client.loginWithProvider("google", {
  returnUrl: "/onboarding",
});

Error handling

import {
  DuplicateAccountError,
  PasswordBreachedError,
  PasswordTooWeakError,
  ValidationError,
  RegistrationDisabledError,
} from "@avnology/sdk-typescript";

try {
  const session = await client.register({ email, password, traits });
} catch (error) {
  if (error instanceof DuplicateAccountError) {
    showError(
      "An account with this email already exists. " +
      "Try logging in or use a different email."
    );
  } else if (error instanceof PasswordBreachedError) {
    showError(
      "This password has been found in a data breach. " +
      "Please choose a different password."
    );
  } else if (error instanceof PasswordTooWeakError) {
    showError(`Password too weak: ${error.reason}`);
    // error.reason: "too_short" | "no_uppercase" | "no_number" | "common_password"
    // error.minLength: 8
  } else if (error instanceof ValidationError) {
    showFieldErrors(error.fieldErrors);
    // e.g., [{ field: "traits.phone", message: "Invalid phone number format" }]
  } else if (error instanceof RegistrationDisabledError) {
    showError("Registration is currently disabled for this application.");
  }
}

verifyEmail()

Verify a user's email address using the verification code sent to their inbox.

verifyEmail(params: VerifyEmailParams): Promise<void>

Parameters

NameTypeRequiredDescription
codestringyes6-digit verification code from email
flowIdstringnoFlow ID (auto-detected from session if omitted)

Basic usage

// After registration, the user receives a verification email with a code
await client.verifyEmail({ code: "482901" });

// Check the session to confirm verification
const session = await client.getSession();
console.log(session.identity.verifiedAt); // "2026-04-08T12:00:00Z"

Resend verification email

await client.resendVerification({ email: "[email protected]" });
showMessage("Verification email sent. Check your inbox.");

Error handling

import { InvalidCodeError, ExpiredFlowError } from "@avnology/sdk-typescript";

try {
  await client.verifyEmail({ code });
} catch (error) {
  if (error instanceof InvalidCodeError) {
    showError("Invalid verification code. Check your email and try again.");
  } else if (error instanceof ExpiredFlowError) {
    showError("This verification code has expired. We'll send you a new one.");
    await client.resendVerification({ email: userEmail });
  }
}

resendVerification()

Resend the email verification code.

resendVerification(params: ResendVerificationParams): Promise<void>

Parameters

NameTypeRequiredDescription
emailstringyesEmail address to resend verification to

Returns

Promise<void> -- Resolves when the email is queued for delivery. Does not throw if the email is not found (to prevent email enumeration).

Common errors

Error classHTTP statusWhen
DuplicateAccountError409Email already registered
PasswordBreachedError400Password found in HIBP database
PasswordTooWeakError400Password fails policy requirements
ValidationError422Invalid field values
RegistrationDisabledError403Registration disabled for this app/org
InvalidCodeError400Wrong verification code
ExpiredFlowError410Verification code expired
RateLimitError429Too many requests

See also

On this page