Quick links

Quickstart GuideAPI reference 66 endpointsAuthentication GuideScopes & presets 32 scopesToken lifecycle GuideErrors ReferenceToken console Tool
Documentation menu
QuickstartAuthenticationScopes & presetsToken lifecycleErrorsSecurityJWT & other authAPI referenceToken console

13 structured token errors

Errors

Diagnose merchant-token failures by separating credential validity, route policy, merchant state, resource ownership, and lifecycle conflicts.

401Credential or lifecycle
403Scope, policy, or merchant state
409Lifecycle conflict

Structured response shape

Authentication and token-management errors use structured Nest responses with a machine-readable code and a human-readable message.

Error response
{
  "code": "API_TOKEN_INVALID",
  "message": "Invalid API token."
}

Do not parse message text for control flow. Branch on the HTTP status and stable code.

Start with the status family

401

Re-authenticate or replace

The bearer credential is invalid or inactive. Stop blind retries and inspect format, version, expiry, revocation, and live owner state.

403

Change policy, not the token string

The credential may be valid, but the route, scope, merchant state, or existing permission denies the action.

409

Resolve lifecycle state

The action conflicts with capacity, naming, editability, or deletion rules. Fetch fresh token metadata before retrying.

Error catalog

401
API_TOKEN_INVALID

Malformed, unknown, wrong-version, or otherwise invalid token.

401
API_TOKEN_INACTIVE

Revoked or expired token, missing owner, suspended owner, role changed, or invalidated ownership.

403
API_TOKEN_SCOPE_REQUIRED

The token is valid but lacks the handler's required scope.

403
API_TOKEN_ROUTE_NOT_ALLOWED

API tokens are not enabled for the handler or the route is explicitly denied.

403
API_TOKEN_MERCHANT_INACTIVE

The bound merchant is missing or no longer active.

409
API_TOKEN_LIMIT_REACHED

All five merchant token slots are occupied.

409
API_TOKEN_NAME_EXISTS

The name already exists for the merchant, case-insensitively.

404
API_TOKEN_NOT_FOUND

The token ID is invalid or not owned by the authenticated merchant.

409
API_TOKEN_NOT_EDITABLE

The token is revoked, expired, or became inactive during update or rotation.

409
API_TOKEN_DELETE_REQUIRES_INACTIVE

An active unexpired token must be revoked before deletion.

403
API_TOKEN_INVALID_SCOPES

Scopes are empty, duplicated, unknown, or unsupported.

403
API_TOKEN_INVALID_EXPIRY

Expiration is invalid or less than 24 hours in the future.

403
API_TOKEN_INVALID_NAME

The name is empty or exceeds 64 characters.

Production handling guidance

01Redact credentials

Log the code, status, route template, token record ID if already known, and correlation metadata—never the bearer value.

02Refresh policy state

For scope or lifecycle conflicts, load current token metadata with an interactive JWT instead of inferring state from an old cache.

03Bound retries

Do not indefinitely retry invalid credentials. Retry transient transport failures separately from deterministic 401/403/409 responses.

04Preserve ambiguity

Unknown, expired, and revoked credentials intentionally avoid revealing whether a secret previously existed.

Feature-specific errors are separate.API.md does not enumerate validation, not-found, conflict, or payment errors produced by the underlying business services.