Error Codes

All auth errors are plain ConvexError instances with a { code, message } payload. There are no special helpers needed - catch them directly with ConvexError from the convex/values package.

// Unauthenticated callers never reach the handler.
export const authQuery = customQuery(query, auth.ctx());

auth.ctx() throws NOT_SIGNED_IN before your handler runs. In middleware or custom integrations, auth.context(ctx) throws the same structured error.

For authorization checks, auth.member.require(...) also throws a ConvexError on failure:

import { ConvexError } from "convex/values";

try {
  await auth.member.require(ctx, {
    userId,
    groupId,
    grants: ["some.grant"],
  });
} catch (e) {
  if (e instanceof ConvexError) {
    console.log(e.data.code); // e.g. "NOT_A_MEMBER" or "MISSING_GRANTS"
  }
}

Auth errors

CodeDescription
NOT_SIGNED_INNo valid session
NOT_A_MEMBERUser is not a member of the group
MISSING_GRANTSUser is missing required grants
ACCOUNT_NOT_FOUNDAccount does not exist
USER_NOT_FOUNDUser does not exist
INVALID_PARAMETERSBad input arguments
INTERNAL_ERRORUnexpected server error
PROVIDER_NOT_CONFIGUREDProvider not in config

Mounted group SSO admin APIs may also throw FORBIDDEN when the app-level authorization callback rejects the caller.

API key errors

CodeDescription
MISSING_BEARER_TOKENNo/malformed Authorization header
INVALID_API_KEYKey not found
API_KEY_REVOKEDKey has been revoked
API_KEY_EXPIREDKey past expiration
API_KEY_RATE_LIMITEDPer-key rate limit exceeded
SCOPE_CHECK_FAILEDKey lacks required scope

Invite errors

CodeDescription
DUPLICATE_MEMBERSHIPUser is already a member
DUPLICATE_INVITEInvite already exists
INVITE_NOT_FOUNDInvite does not exist
INVITE_NOT_PENDINGInvite is not in pending status
NO_ACTIVE_GROUPNo active group set

Device flow errors

CodeDescription
DEVICE_AUTHORIZATION_PENDINGUser hasn’t entered the code yet
DEVICE_SLOW_DOWNPolling too fast
DEVICE_CODE_EXPIREDCode expired
DEVICE_CODE_INVALIDCode not found or already used
DEVICE_CODE_DENIEDAuthorization explicitly denied
DEVICE_CODE_ALREADY_AUTHORIZEDCode already authorized