Error Code Reference

All errors thrown by the Calimatic Auth SDK are instances of CalimaticAuthError. This class exposes three properties:

PropertyTypeDescription
statusnumberHTTP status code returned by the API
codeAuthErrorCodeValueMachine-readable error code (one of the values below)
messagestringHuman-readable error description

Usage

import { CalimaticAuthError, AuthErrorCode } from '@calimatic/auth-sdk';

try {
  await client.auth.login({ email, password });
} catch (err) {
  if (err instanceof CalimaticAuthError) {
    switch (err.code) {
      case AuthErrorCode.INVALID_CREDENTIALS:
        // wrong email or password
        break;
      case AuthErrorCode.ACCOUNT_LOCKED:
        // too many failed attempts
        break;
      default:
        console.error(err.code, err.message);
    }
  }
}

Authentication Errors

INVALID_CREDENTIALS

HTTP Status401
TriggerThe email or password provided did not match any active account.
TroubleshootingVerify the email address and password are correct. Check for leading/trailing whitespace.
Thrown byauth.login

ACCOUNT_LOCKED

HTTP Status423
TriggerThe account has been temporarily locked due to too many consecutive failed login attempts.
TroubleshootingWait for the lockout to expire (check security.lockoutStatus() for remaining time), or call security.unlock() from an admin client.
Thrown byauth.login

INVALID_CLIENT

HTTP Status401
TriggerThe x-client-id or x-client-secret headers are missing, unknown, or do not match a registered app client.
TroubleshootingVerify the clientId and clientSecret in your HeadlessAuthConfig match the app client registered in the Calimatic Auth developer portal.
Thrown byAll endpoints (every request requires valid client credentials)

INVALID_TOKEN

HTTP Status401
TriggerThe Bearer access token provided is expired or otherwise invalid.
TroubleshootingRefresh the token via auth.refresh(), or provide an onRefresh callback when constructing the client to enable automatic retry.
Thrown bymfa.status, mfa.enroll, mfa.confirmEnrollment, mfa.disable, mfa.backupCodes.count, mfa.backupCodes.regenerate

TOKEN_EXPIRED

HTTP Status401
TriggerThe refresh token is expired or has been explicitly revoked.
TroubleshootingThe user must log in again with auth.login() to obtain a new refresh token.
Thrown byauth.refresh, auth.logout

EMAIL_NOT_VERIFIED

HTTP Status403 (login blocked)
TriggerLogin was attempted but the user's email address has not yet been verified.
TroubleshootingCall email.sendVerification() to resend the verification link, then prompt the user to check their inbox.
Thrown byauth.login

MFA Errors

MFA_REQUIRED

HTTP StatusN/A (200 response with mfaRequired: true)
TriggerLogin succeeded but the user has MFA enrolled — a challenge token is issued instead of access tokens. This is not an error; it is part of the normal step-up flow.
TroubleshootingCheck 'mfaRequired' in result after auth.login(). If true, call mfa.verify() with the mfaToken and a TOTP code or backup code.
Thrown byNot thrown as an error — returned as MfaChallengeResponse from auth.login

MFA_INVALID_CODE

HTTP Status401
TriggerThe TOTP code or backup code provided was incorrect.
TroubleshootingVerify the code is current (TOTP codes expire every 30 seconds). If using a backup code, ensure it has not already been used.
Thrown bymfa.verify, mfa.confirmEnrollment, mfa.disable, mfa.backupCodes.regenerate

MFA_CHALLENGE_EXPIRED

HTTP Status401
TriggerThe mfaToken received from auth.login() has expired before mfa.verify() was called. MFA tokens are short-lived (typically 5 minutes).
TroubleshootingRestart the login flow — call auth.login() again to obtain a fresh MFA challenge token.
Thrown bymfa.verify

MFA_ALREADY_ENROLLED

HTTP Status409
TriggerAn attempt was made to enroll TOTP when the user already has MFA enabled.
TroubleshootingCall mfa.disable() first if re-enrollment is needed, then call mfa.enroll() again.
Thrown bymfa.enroll

MFA_NOT_ENROLLED

HTTP Status400
TriggerAn MFA operation (verify, disable, backup codes) was attempted but the user has not enrolled TOTP.
TroubleshootingCall mfa.enroll() followed by mfa.confirmEnrollment() to set up TOTP before attempting this operation.
Thrown bymfa.disable, mfa.backupCodes.count, mfa.backupCodes.regenerate

Request Errors

VALIDATION_ERROR

HTTP Status400
TriggerThe request body failed server-side Zod schema validation (e.g., missing required field, invalid email format, password too short).
TroubleshootingCheck the error.message property for the specific field that failed validation. Ensure all required fields are present and correctly typed.
Thrown byAll endpoints that accept a request body

USER_NOT_FOUND

HTTP Status404
TriggerThe userId provided does not correspond to any user in the platform database.
TroubleshootingVerify the userId is correct. The user may have been deleted, or you may be using the wrong ID format (must be a UUID).
Thrown bysessions.list, sessions.revoke, sessions.revokeAll, security.lockoutStatus, security.unlock

CONFLICT

HTTP Status409
TriggerA resource already exists that would conflict with the requested operation (e.g., email address already registered during signup, or session already inactive).
TroubleshootingCheck whether the resource already exists before creating it. For signup, the user may need to log in instead.
Thrown byauth.signup

RATE_LIMITED

HTTP Status429
TriggerToo many requests have been made from this client in a short window.
TroubleshootingBack off and retry using exponential delay. The Retry-After response header (when present) indicates when the client may retry.
Thrown byAll endpoints

Server Errors

INTERNAL_ERROR

HTTP Status500
TriggerAn unexpected error occurred on the server (e.g., database failure, Keycloak unreachable).
TroubleshootingRetry the request. If the error persists, contact the Calimatic platform team.
Thrown byAll endpoints

UNKNOWN

HTTP StatusVaries
TriggerThe server returned an error response that could not be mapped to a known AuthErrorCode. This should be rare.
TroubleshootingCheck error.message for details. If this is reproducible, report it — it may indicate a missing error mapping.
Thrown byAll endpoints (fallback)

Error Code Summary

CodeHTTP StatusCategory
INVALID_CREDENTIALS401Authentication
ACCOUNT_LOCKED423Authentication
INVALID_CLIENT401Authentication
INVALID_TOKEN401Authentication
TOKEN_EXPIRED401Authentication
EMAIL_NOT_VERIFIED403Authentication
MFA_REQUIRED200 (not an error)MFA
MFA_INVALID_CODE401MFA
MFA_CHALLENGE_EXPIRED401MFA
MFA_ALREADY_ENROLLED409MFA
MFA_NOT_ENROLLED400MFA
VALIDATION_ERROR400Request
USER_NOT_FOUND404Request
CONFLICT409Request
RATE_LIMITED429Request
INTERNAL_ERROR500Server
UNKNOWNVariesServer