Skip to main content

Add x402 to an endpoint

payMiddleware accepts x402 by default as part of its dual-protocol behaviour. The standard configuration works with all x402-compatible agents without any additional options.
Dashboard support for managing paid endpoints is coming soon. Use the SDK to configure x402 on your routes.

What the 402 response looks like

When a request arrives without payment, payMiddleware returns:
The PAYMENT-REQUIRED header is the x402 challenge. An x402 agent decodes it, signs an ERC-3009 authorization, and resubmits with PAYMENT-SIGNATURE.

What the 200 response includes

After successful x402 payment:
The response also includes the PAYMENT-RESPONSE header with settlement details — see Handle the payment response.

payMiddleware options

Error handling

Next steps