v1 · OpenAPI 3.1Dashboard

Users and sign-in

Sign-up and sign-in

The client part of the SDK talks to the sign-in host of the application's region with the publishable key. Every method returns a promise and throws FoxLoginError when the call fails. The examples below share one client:

Browser
import { FoxLogin, FoxLoginError } from "foxlogin";

const fox = new FoxLogin({ publishableKey: "pk_live_eu_…" });

For Google accounts, see Sign in with Google.

Sign-up with an email code

signUp({ email, password, country, name }) emails a six-digit code and answers { status: "verification_sent" }; name is optional. An address that already has an account gets an email saying so instead of a code, and the response stays the same, so nobody can use sign-up to find out who is registered. verifySignUp({ email, code }) creates the account on the first correct code and signs it in.

Browser
await fox.signUp({ email, password, country: "TR", name: "Elif Kaya" });

// Later, when the user has typed the code from the email:
const result = await fox.verifySignUp({ email, code });
if (result.status === "signed_in") showApp(result.user);
Rule Value
country Required. ISO 3166-1 alpha-2, such as DE or TR. Anything else is 400 invalid_country.
Password 8 to 256 characters, otherwise 400 weak_password.
Email A malformed address is 400 invalid_email.
Code Six digits, valid for 15 minutes, 5 wrong attempts. After that, or once expired, 400 invalid_code.
Country restriction If the application accepts only listed countries, any other country gets 422 country_not_allowed.
Rate limit 10 sign-ups per minute per IP address, then 429 rate_limited.

Password sign-in

signIn({ email, password }) returns { status: "signed_in", user }, or { status: "mfa_required", mfaToken } when the user has two-factor authentication on.

Browser
try {
  const result = await fox.signIn({ email, password });
  if (result.status === "mfa_required") askForTotpCode(result.mfaToken);
  else showApp(result.user);
} catch (e) {
  if (e instanceof FoxLoginError && e.code === "invalid_credentials") {
    showError("Wrong email or password.");
  } else {
    throw e;
  }
}

A wrong email, a wrong password and a locked account all get the same 401 invalid_credentials, so the answer never says which one it was. Each account gets 10 attempts per minute, and each IP address 30 per minute across accounts.

Email-code sign-in

For passwordless sign-in, sendSignInCode({ email }) emails a code and always answers { status: "code_sent" }, whether or not the account exists. signInWithCode({ email, code }) signs the user in.

Browser
await fox.sendSignInCode({ email });

// When the user has typed the code:
const result = await fox.signInWithCode({ email, code });

A wrong or expired code returns 401 invalid_code on this endpoint, while the other code checks return 400. An account gets at most 3 codes per minute. Users you create through the Management API without a password sign in this way.

Password reset

startPasswordReset({ email }) emails a code and always answers { status: "code_sent" }. confirmPasswordReset({ email, code, password }) sets the new password, ends every other session of the user, and signs in on the current device.

Browser
await fox.startPasswordReset({ email });

// When the user has typed the code and a new password:
const result = await fox.confirmPasswordReset({ email, code, password: newPassword });

A wrong code is 400 invalid_code and a too short or too long password is 400 weak_password.

Client endpoints

The SDK calls these endpoints on https://<region>.auth.foxlogin.app with the X-Fox-Publishable-Key header. The Google start URL carries the publishable key as a query parameter instead, the two-factor step authenticates with mfa_token alone, and the TOTP endpoints with the user's access token. Bodies are JSON.

SDK method HTTP Purpose Success
signUp POST /v1/client/sign_up Email a sign-up code 202 {"status":"verification_sent"}
verifySignUp POST /v1/client/sign_up/verify Create the account and sign in 200 session or mfa_required
signIn POST /v1/client/sign_in Sign in with a password 200 session or mfa_required
sendSignInCode POST /v1/client/sign_in/email_code Email a sign-in code 202 {"status":"code_sent"}
signInWithCode POST /v1/client/sign_in/email_code/verify Sign in with the emailed code 200 session or mfa_required
verifyMfa POST /v1/client/sign_in/mfa Finish a two-factor challenge 200 session
startPasswordReset POST /v1/client/password_reset Email a password reset code 202 {"status":"code_sent"}
confirmPasswordReset POST /v1/client/password_reset/confirm Set a new password, end other sessions, sign in 200 session or mfa_required
refresh, getToken POST /v1/client/token Exchange the refresh token for a new pair 200 token pair
signOut POST /v1/client/sign_out End the session 204
None yet GET /v1/oauth/google/start Send the browser to Google, as a page load 303 redirect
None yet POST /v1/client/oauth/token Exchange the Google fox_code for a session 200 session or mfa_required
None yet POST /v1/client/oauth/complete Create a new Google user with a country and sign in 200 session or mfa_required
None yet POST /v1/client/mfa/totp/setup Start TOTP setup 200 {secret, otpauth_url}
None yet POST /v1/client/mfa/totp/enable Turn TOTP on 200 {recovery_codes}
None yet POST /v1/client/mfa/totp/disable Turn TOTP off 204

A session is { user, session_id, access_token, refresh_token, token_type: "Bearer", expires_in: 600 }. A token pair has the same fields without user.