code without parsing message. Every error response — at every endpoint, for every failure — uses the same shape.
The shape
| Field | Required | Notes |
|---|---|---|
code | yes | A stable identifier from the §11.3 reserved codes. |
message | yes | Human-readable. SHOULD NOT contain sensitive details. |
details | no | Error-specific structured information. Use freely; clients ignore unknown keys. |
Status codes
Services use the standard HTTP status family per §11.2:| Status | Meaning |
|---|---|
400 Bad Request | Malformed request — invalid JSON, missing required fields, invalid DID syntax |
401 Unauthorized | Signature verification failed, key revoked, or attestation invalid |
403 Forbidden | Operation not permitted in the current state |
404 Not Found | Account does not exist (only when implicit signup is disabled) |
409 Conflict | State conflict — e.g., account already CLAIMED, key already revoked |
410 Gone | Account is EXPIRED or invitation has expired |
429 Too Many Requests | Rate limit exceeded |
503 Service Unavailable | Service temporarily unable to process AFAuth requests |
401. Always inspect code.
Consuming errors as a client
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 throwsAFAuthError(code, status, message) from its handlers. Render the throw to the envelope:
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
- Reserved error codes table — the full §11.3 list with status, trigger, and client-side response.
- Spec §11 — normative.
- Test vectors §C.5 — one envelope fixture per reserved code.