Launch offer for the first 500 accounts: $10K MTR free for 24 months + $100 credit →
    .io

    Identities & Identifiers

    A user is addressed by an identifier

    One user can hold several: an email address, a phone number, a username. Each is a row of its own, each is separately verified, and each is scoped to one project and one environment. The kind is part of the lookup, not a hint.

    The three kinds

    KindCanonicalisationCan receive a code
    emailLowercased and trimmedYes — email code
    phoneE.164, alwaysYes — SMS code
    usernameStored as givenNo — password or a second factor only

    Phone numbers are canonicalised to E.164

    One canonicaliser runs on every path — sign-up, prepare and attempt — so a number typed as (555) 123-4567 and one typed as +15551234567 are the same identity. A value that is not a valid phone number is refused rather than stored as-is.

    Code
    await auth.requestCode({ identifier: '+15551234567', kind: 'phone' });
    
    await auth.attempt({
      identifier: '+15551234567',
      kind: 'phone',        // same value as above
      strategy: 'sms_code',
      code: '123456',
    });

    Verification

    An identifier is verified when a code sent to it comes back. Until then it is unverified, and an unverified address does not inherit an organization's entitlements — otherwise claiming a stranger's address would claim their access.

    Codes live ten minutes, are single-use, and are requested with a purpose: sign_in, verify_identifier or reset_password. The purposes are not interchangeable — a code minted for a password reset cannot sign anyone in. If it could, "forgot password" would be a complete authentication bypass for anyone who can request one.

    Codes for returning users

    requestCode is how an existing user gets a fresh code. Sign-up issues one as a side effect, but only for a new identifier — so without requestCode a returning person has no way to sign in passwordlessly at all. That is true for email exactly as much as SMS.

    Code
    await auth.requestCode({ identifier: 'ada@example.com' });
    // -> { sent: true, expiresInMinutes: 10 }

    sent: true means the request was accepted. It does not mean an account exists, and it does not mean delivery succeeded — both are deliberately indistinguishable, for the same enumeration reason as everywhere else.

    Users and customers

    When someone signs in, their user record is linked to a customer record — the thing that holds entitlements, purchases and analytics. The token carries the user as sub and the customer as cus.

    Sandbox and production are separate identity spaces. The same email address in each is two different users, with two different customers, and a token minted in one cannot verify in the other.

    Was this page helpful?

    Or rate this page:

    We use cookies and process your data to provide our services. By continuing, you agree to our Terms and Privacy Policy.