
x402 on Stellar
Pay-per-call API monetization using the HTTP 402 Payment Required protocol. Powered by the PerkOS Stellar Relayer.
What is x402?
HTTP status code 402 Payment Required has been reserved in the HTTP specification since 1999, but was never formally implemented — until now. The x402 protocol defines a standard way for servers to require payment before serving a response, and for clients to fulfill that requirement programmatically.
How it works
- Client sends a request to a paid API endpoint
- Server responds with
HTTP 402and a JSON body describing the payment requirements: price, asset, network, and recipient address - Client signs the required payment (a Stellar USDC authorization in this demo)
- Client retries the original request with the signed payment in the
X-PAYMENTheader - Server forwards the payment to a relayer for verification and on-chain settlement
- Once confirmed, the server returns the API response
Why this matters for agents and automation
x402 enables fully programmatic payments. There are no wallet popups, no manual approvals, and no redirect flows. An AI agent or script can pay for API access the same way it sets an HTTP header — making machine-to-machine commerce a first-class pattern.
Why Stellar
Stellar offers near-zero transaction fees (roughly $0.00001 per operation), settlement in under five seconds, and native USDC support via regulated on/off ramps. These properties make it a strong fit for high-frequency micro-payments where cost and speed are critical.
How PerkOS Fits In
The PerkOS Stellar x402 Relayer is the verification and settlement layer that sits between your application and the Stellar network. When a client submits a signed payment via the X-PAYMENT header, the relayer validates the authorization, submits the transaction to Stellar, and confirms settlement — all in a single round-trip.
Live relayer: stellar-relayer.perkos.xyz
How x402 Works
Request
Client calls a paid API endpoint without payment
402 Response
Server returns HTTP 402 with payment requirements (price, asset, address)
Pay & Retry
Client signs a Stellar payment, attaches it as X-PAYMENT header, and retries
Demo Endpoints
/api/weather$0.01 USDCGet current weather data for any city
/api/joke$0.001 USDCGet a random programming joke