Key0Error class, which extends the native Error with a machine-readable error code, an HTTP status code, and optional structured details.
Key0Error Class
toJSON()
Returns a serializable object suitable for HTTP response bodies. Thedetails field is only included when present.
Error Codes Reference
JSON Error Response
All Key0 HTTP integrations (Express, Hono, Fastify) serialize errors usingKey0Error.toJSON(). The response body follows this shape:
details is present (e.g., PROOF_ALREADY_REDEEMED):
Handling Errors
In Client Code
In Server Code
Key0ErrorCode Type
The union type of all valid error codes:Related
ChallengeEngine
The state machine that throws most of these error codes.
API Reference Overview
How errors are surfaced across the x402 HTTP endpoint.

