Better Enrollment

Error codes

Every APIError code the plugin can return.

Errors are Better Auth APIErrors carrying a code and a message:

import { INVITE_ERROR_CODES } from "@octopi-ai/better-enrollment";

Errors from your own gates

Not every error from an invite endpoint is one of the codes below. When your own code rejects a user the plugin is creating, by returning an error from user.validateUserInfo (Better Auth 1.7) or throwing an APIError from a databaseHooks.user.create.before hook, that error reaches the caller unchanged, with your status and code. It is never rewritten into EMAIL_ALREADY_INVITED or PRE_CREATED_USER_MISSING. See Gating invited users.

Invite state

CodeWhen
INVITE_NOT_FOUNDUnknown or no longer valid token
INVITE_EXPIREDThe invite passed its expiresAt
INVITE_REVOKEDThe invite was revoked
INVITE_ALREADY_USEDA single-use invite was already redeemed, or a public invite hit its use cap
EMAIL_ALREADY_INVITEDA pending invite of the same kind (and, for org-join, the same org) already holds that address; resend it
USER_ALREADY_EXISTSapp invite to an address that already has an established account

Roles and permissions

CodeWhen
INVALID_ROLERole rejected at create
ROLE_NO_LONGER_VALIDThe invited role no longer exists at redeem
ROLE_NOT_ALLOWED_FOR_ORG_JOINorg-join invites cannot set an app role
NOT_ALLOWED_TO_MANAGE_INVITESFailed the admin gate

Redemption guards

CodeWhen
PASSWORD_NOT_AVAILABLEA password was sent to a passwordless app
EMAIL_MISMATCHOpen-mode activation guard: the emails do not match
EMAIL_NOT_VERIFIEDOpen-mode activation guard: the email is not verified
USER_BANNEDBanned accounts cannot redeem
NAME_REQUIREDSign-up redemption without a name
ADDITIONAL_FIELD_REQUIREDA required additional field is missing
ADDITIONAL_FIELD_INVALIDAn additional field failed its type check or validator

Organizations

CodeWhen
SEAT_LIMIT_REACHEDNo seats left, at create or at redeem
ORG_INVITE_NOT_ALLOWEDNot permitted to invite into that organization
ORG_DISABLEDThe organization is disabled: create, redeem, and org members managing its invites or usage
ORG_SLUG_TAKENSlug collision while founding an organization the founder names (preset slugs get a suffix)

Listing

CodeWhen
INVALID_CURSORinvite.list received a malformed cursor

Last updated on

On this page