Skip to content

Error codes

The plugin exports TENANT_AUTH_ERROR_CODES from both the server and client packages.

ts
import { TENANT_AUTH_ERROR_CODES } from "better-auth-tenancy";
// or
import { TENANT_AUTH_ERROR_CODES } from "better-auth-tenancy/client";

Codes

CodeMessage
TENANT_ID_REQUIREDTenant id is required
TENANT_NOT_FOUNDTenant not found
TENANT_ALREADY_EXISTSA tenant with this slug already exists
TENANT_MANAGEMENT_NOT_ALLOWEDYou are not allowed to manage tenants or tenant OAuth configurations
USER_ALREADY_EXISTSA user with this email already exists for this tenant
INVALID_EMAIL_OR_PASSWORDInvalid email or password
EMAIL_NOT_VERIFIEDEmail is not verified
EMAIL_PASSWORD_NOT_ENABLEDEmail and password sign in is not enabled
PROVIDER_NOT_FOUNDOAuth provider not found. Configure it for the tenant or in the auth config
UNSUPPORTED_PROVIDERThis provider is not a supported built-in social provider
OAUTH_CONFIG_NOT_FOUNDOAuth configuration not found for this tenant
FAILED_TO_CREATE_USERFailed to create user
FAILED_TO_CREATE_SESSIONFailed to create session

Usage

The plugin registers these codes on $ERROR_CODES for typed error handling in Better Auth clients:

ts
const authClient = createAuthClient({
  plugins: [tenantAuthClient()],
});

// authClient.$ERROR_CODES.TENANT_NOT_FOUND

HTTP status mapping follows Better Auth conventions (e.g. TENANT_NOT_FOUND → 404, TENANT_MANAGEMENT_NOT_ALLOWED → 403).

Released under the MIT License.