Reference

Error codes

Error codes defined by Auth Service, with HTTP status and default message.

Auth Service uses a structured error response format for the errors raised by its own API routes (/api/* routes, except the BetterAuth handler):

{
  "error": {
    "code": "APP_002",
    "message": "Application not found",
    "details": {}
  }
}

details is included only when the error carries some (for example validation errors, or balance and required on WAL_002). A route may replace the default message with a more specific one (for example AUTH_011 with "Only superadmins can change machine scopes", or SRV_004 with the message reported by the gateway); the tables below list the default messages of the registry in src/errors.ts.

Other responses you may meet:

  • A request body or query that fails validation answers 400 with code APP_001, message "Validation error" and the flattened validation issues in details.
  • Any other unhandled error answers 500 SRV_001 "Internal server error".
  • An unknown path answers 404 with { "error": { "code": "SRV_001", "message": "Not found" } }.
  • The BetterAuth handler under /api/auth/ answers with its own error bodies, and the OAuth endpoints with the OAuth error / error_description format.
  • The Stripe webhook answers 503 with code SRV_002 and the message "Stripe is not configured" when Stripe is not set up.

Codes are never renumbered or reused: a gap in a domain is a retired code. Every code in the registry is raised by at least one route or service.

Authentication (AUTH_)

CodeHTTPDefault message
AUTH_001401Missing or invalid authentication token
AUTH_009400Password too weak
AUTH_011403Insufficient permissions
AUTH_012400Invalid, expired or already used registration invitation
AUTH_013409An account already exists for this email
AUTH_014403This invitation was issued for a different email address
AUTH_015403Verify your email address before accepting this invitation
AUTH_016404Session not found

Application (APP_)

CodeHTTPDefault message
APP_001400Invalid application data
APP_002404Application not found
APP_003409Application slug already exists
APP_005403User does not have access to this application
APP_006403Social provider not enabled for this application
APP_007403System applications cannot be deleted

Permissions (PERM_)

CodeHTTPDefault message
PERM_001400Invalid permission format
PERM_002404Role not found
PERM_003404Permission not found
PERM_004409Role name already exists in this application
PERM_005409Permission already defined
PERM_006400Cannot delete a role that is assigned to users

Subscriptions (SUB_)

CodeHTTPDefault message
SUB_001404Subscription plan not found
SUB_002409User already has an active subscription
SUB_003400Plan has active subscribers, cannot delete
SUB_005403Self-service plan changes require Stripe to be configured
SUB_007409A paid subscription already exists for this application: change its plan instead
SUB_008404This user has no Stripe subscription for this application

Consumption (CONS_)

CodeHTTPDefault message
CONS_001400Invalid key format
CONS_002400Value must be a finite number
CONS_003404User and application combination not found
CONS_004403Caller not authorized (requires client_credentials)
CONS_005400Invalid consumption identifier

Billing (BIL_)

CodeHTTPDefault message
BIL_001503Billing is not configured
BIL_002400Invalid billing configuration
BIL_003403Metered usage limit reached
BIL_004502The payment provider rejected the request

BIL_003 is raised when a metered consumption report would cross the plan price's hard cap. BIL_004 is raised when Stripe refuses a plan change or a cancellation change, or returns no secure checkout or portal URL.

Wallet (WAL_)

CodeHTTPDefault message
WAL_001404Wallet account not found
WAL_002402Insufficient credit balance
WAL_003409Idempotency key already used with different parameters
WAL_004400Invalid wallet amount
WAL_005400Invalid pagination cursor
WAL_006503Online payment is not configured
WAL_007503Usage pricing is not configured

Users (USR_)

CodeHTTPDefault message
USR_001404User not found
USR_002400Cannot delete the last superadmin
USR_003400Invalid user data

Organizations (ORG_)

CodeHTTPDefault message
ORG_001404Organization not found
ORG_002409Organization slug already exists
ORG_003400Invalid organization data
ORG_004404Member not found in organization
ORG_005409User is already a member of this organization

Server (SRV_)

CodeHTTPDefault message
SRV_001500Internal server error
SRV_002503Service temporarily unavailable
SRV_003500Database error
SRV_004502LLM gateway unavailable

SRV_004 is raised, with the message reported by the gateway client, when saving an application or creating or renaming a plan requires gateway teams that could not be created; nothing is saved in that case.

Outbound email (MAIL_)

CodeHTTPDefault message
MAIL_002502Mail transport failure
MAIL_003429Too many email requests, please retry later

Rate limiting (RATE_)

CodeHTTPDefault message
RATE_001429Too many authentication attempts, please retry later

RATE_001 (10 requests per minute and IP on the sign-in, sign-up, password-reset and two-factor verification paths of /api/auth/, and 60 per minute on /api/auth/device when device authorization is enabled) and MAIL_003 (5 per minute and IP on the email-sending paths of /api/auth/) are returned by the /api/auth/ rate-limit hook. Other rate-limited routes (the global limit of 600 requests per minute per IP, the registration routes) answer with the framework's default 429 body.

Copyright © 2026