How it works
The server adds x402 middleware to the endpoints it wants to monetize. When a request arrives without payment, the server responds with HTTP402 Payment Required and a PAYMENT-REQUIRED header containing the price, token, and network. The client signs an ERC-3009 authorization for the specified amount and resubmits. The facilitator settles the payment on-chain, and the server returns the resource.
Request flow
- Client sends an HTTP request to the server.
- Server returns
402 Payment Requiredwith aPAYMENT-REQUIREDheader containing the price, token, network, and recipient. - Client signs an ERC-3009 authorization for the specified amount and resubmits the request with a
PAYMENT-SIGNATUREheader. - Facilitator verifies the signature and settles the transfer on-chain.
- Server returns the resource with a
PAYMENT-RESPONSEheader containing the settlement receipt.
Pricing
Prices are denominated in USDT0 atomic units (6 decimals). A cost parameter of"1000" translates to exactly 0.05. This precision allows servers to set prices at fractions of a cent.
Infrastructure
On Stable, Semantic Pay operates a public facilitator. Developers can point their middleware to this endpoint without running their own settlement infrastructure. x402 provides middleware for Express (@x402/express), Hono (@x402/hono), and Next.js (@x402/next). The pattern is the same across all frameworks: create a facilitator client, register the EVM scheme, and apply middleware.
What makes it different
Traditional API monetization requires user registration, API key management, usage tracking, billing cycles, and payment processor integration. With x402, the server attaches a payment handler to each endpoint, the client pays per request, and settlement completes within the same HTTP lifecycle. The server does not need to know who the client is — only that a valid payment was submitted.| Aspect | Traditional (API key + billing cycle) | Stable (x402) |
|---|---|---|
| Server-side setup | Registration, API keys, usage tracking, billing cycles, payment processor | x402 payment handler per endpoint |
| Client onboarding | Account creation, API key issuance | None (wallet only) |
| Billing model | Monthly or usage-based invoicing | Per-request settlement |
| Client identity required | Yes (API key) | No (only valid payment) |
| Settlement | End of billing cycle | Within request lifecycle (under 1 second) |
| Minimum viable price | ~$0.30 (card processing floor) | $0.001 (USDT0 atomic units) |
| Client type | Human users only (sign-up required) | Any wallet: humans, AI agents, scripts |

