Skip to main content
All errors raised by the Key0 SDK use the 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. The details field is only included when present.

Error Codes Reference


JSON Error Response

All Key0 HTTP integrations (Express, Hono, Fastify) serialize errors using Key0Error.toJSON(). The response body follows this shape:
When 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:

ChallengeEngine

The state machine that throws most of these error codes.

API Reference Overview

How errors are surfaced across the x402 HTTP endpoint.