Skip to main content
AFAuth standardises the error response so clients can program against code without parsing message. Every error response — at every endpoint, for every failure — uses the same shape.

The shape

Status codes

Services use the standard HTTP status family per §11.2: Status alone isn’t enough to act on — multiple codes share 401. Always inspect code.

Consuming errors as a client

This is the typical decision tree. Three codes are particularly worth disambiguating: owner_authentication_required (no owner session at all), owner_session_too_stale (session present but expired against the §7.5 freshness window), and owner_binding_blocked (an agent-signed request to an owner-binding operation). All three return 403, but the user-facing prompt differs — re-authenticate vs. tell the user this is operator-only.

Producing errors as a service

The TypeScript SDK throws AFAuthError(code, status, message) from its handlers. Render the throw to the envelope:
Full reference: examples/recipes/verify.ts.

Custom error codes

Services MAY define additional codes for service-specific conditions — example_quota_exceeded, feature_not_in_plan, etc. Per §11.3, custom codes SHOULD be prefixed with a service-specific namespace so clients can distinguish them from reserved codes.

Further reading