@key0ai/key0 and are available as TypeScript imports:
ChallengeState
The state machine for a challenge record. All transitions are atomic and go throughIChallengeStore.transition().
AccessRequest
Sent by the client agent to initiate a payment flow. TherequestId serves as an idempotency key.
Provide either
planId or routeId, not both. The resource field is only used for standalone route-based calls when proxyTo or fetchResource is set on SellerConfig. After payment Key0 proxies to the specified method + path and returns a ResourceResponse instead of an AccessGrant.message/send (as a data part), x402 HTTP request parsing.
Subscription example:
X402Challenge
Returned by the server after receiving anAccessRequest. Contains all information the client needs to make a USDC payment.
PaymentProof
Sent by the client after completing an on-chain USDC transfer. Contains the transaction hash for verification.message/send (as a data part), ChallengeEngine.submitProof() input.
Example:
ResourceResponse
Returned instead ofAccessGrant for route-based standalone calls. Contains the proxied backend API response — no JWT is issued.
request_access tool result for route purchases.
Example:
PAID state (pending refund). The resource.status and resource.body reflect the backend’s error response. For free routes, txHash and explorerUrl are omitted.
PaymentInfo
Available asreq.key0Payment in embedded per-request route handlers and as params.paymentInfo in fetchResource callbacks.
AccessGrant
Returned after successful payment verification for subscription plans. Contains the bearer token for accessing protected resources.ChallengeRecord
The internal record stored inIChallengeStore. Contains all challenge state, timestamps, and the access grant once delivered. Not directly exposed in API responses, but useful for understanding the storage layer.
statetransitions are atomic viaIChallengeStore.transition(id, fromState, toState, updates?, meta?).amountRawis the USDC amount in 6-decimal micro-units (e.g.,100000n= $0.10).accessGrantis persisted durably in the PAID state before the DELIVERED transition, using an outbox pattern.
NetworkConfig
Configuration for a supported blockchain network.NetworkName
The two supported network identifiers.Plan
Defines a pricing plan in the seller’s catalog.
Subscription plan example:
Route
Defines a callable API route in the seller’s route catalog. Routes are how you model free endpoints and pay-per-call endpoints.
Paid route example:
X402PaymentRequiredResponse
The x402 v2 payment-required response. Sent in 402 response bodies and thepayment-required header (base64-encoded).
X402PaymentPayload
The payment payload sent by the client, either in thePAYMENT-SIGNATURE HTTP header (base64url-encoded) or in MCP _meta["x402/payment"].
X402SettleResponse
The settlement receipt, returned in thepayment-response HTTP header (base64-encoded) and in MCP _meta["x402/payment-response"].
Related
Error Codes
Complete reference of all Key0ErrorCode values and HTTP status codes.
State Machine
Visual guide to ChallengeState transitions and invariants.
ChallengeEngine
The engine that orchestrates these data models through the payment lifecycle.
POST /x402/access
The x402 HTTP endpoint that produces and consumes these types.

