Skip to main content

Error codes

Protekt uses standardized error codes to help you quickly identify and resolve issues during authentication, session management, and API interactions. Each error includes a machine-readable code and a human-readable message.

Understanding these error codes allows you to build better error handling, display meaningful feedback to users, and debug issues efficiently in development and production.

Error response format

All errors returned by Protekt follow a consistent structure:

{
"error": "invalid_credentials",
"message": "The email or password provided is incorrect.",
"statusCode": 401
}

Where:

  • error: A unique identifier for the error type
  • message: A human-readable explanation
  • statusCode: The corresponding HTTP status code

Common error codes

Protekt groups errors into categories based on where they occur in the authentication lifecycle. This makes it easier to quickly identify whether an issue is related to login, token handling, permissions, or system-level failures.

Authentication errors

These errors typically occur during login or identity verification. You should handle them gracefully in your UI and avoid exposing sensitive details.

CodeDescriptionHTTP
invalid_credentialsIncorrect email or password401
user_not_foundNo user exists with the provided identifier404
email_not_verifiedUser must verify email before login403
account_lockedAccount temporarily locked due to suspicious activity423

Token and session errors

These errors usually require re-authentication or token refresh. In most cases, enabling automatic refresh in the SDK prevents user disruption.

CodeDescriptionHTTP
invalid_tokenToken is malformed or invalid401
token_expiredAccess token has expired401
refresh_token_invalidRefresh token is invalid or revoked401
session_not_foundSession does not exist404
session_revokedSession has been revoked401

Authorization errors

These errors occur when a user is authenticated but not authorized. Ensure proper role or permission checks in your application.

CodeDescriptionHTTP
insufficient_permissionsUser lacks required permissions403
access_deniedAccess to resource is forbidden403

Server errors

Implement retries and fallback mechanisms for these errors.

CodeDescriptionHTTP
internal_errorUnexpected server error500
service_unavailableTemporary outage or maintenance503