What is x402?
x402 is an open protocol that uses HTTP status code 402 Payment Required to enable native, per-request API monetization — with no accounts, API keys, or billing infrastructure.
The Problem
Traditional API monetization requires:
- Developer account registration
- API key management
- Monthly subscription billing
- Rate limit enforcement
- Credit card processing
This works for humans with browsers, but completely breaks for AI agents — they can't sign up for accounts or manage billing.
How x402 Fixes It
x402 adds a payment layer directly into the HTTP request cycle. A resource server announces its price inside the 402 response. The client signs a USDC payment and retries the request with a X-PAYMENT header. A facilitator verifies and settles the transaction on-chain.
The result: any HTTP client with a funded wallet can pay for any x402 endpoint — zero setup.
The Protocol Flow
1. Client sends a normal HTTP request
GET /api/price-feed HTTP/1.1
2. Server responds with 402 + payment requirements
HTTP/1.1 402 Payment Required
X-Payment-Required: [{"scheme":"exact","network":"solana:5eykt4...","maxAmountRequired":"10000","asset":"EPjFW...","payTo":"BqVq3..."}]
3. Client builds and signs USDC payment
(using @x402/fetch, @x402/node, or MCP orchus_fetch)
4. Client retries with signed payment
GET /api/price-feed HTTP/1.1
X-Payment: <signed-payment-payload>
5. Server forwards to facilitator for verification + settlement
POST x402.agentstrail.ai/settle
6. Facilitator submits Solana tx, returns receipt
7. Server delivers the response
HTTP/1.1 200 OKx402 Versions
| Version | Header | Network format | Used by |
|---|---|---|---|
| v2 | X-Payment-Required | CAIP-2 (solana:5eykt4...) | @x402/core 2.x |
| v1 | X-Payment-Required | human-readable (solana, base) | older SDKs |
The Orchus MCP server and facilitator support both v1 and v2 on Solana and Base.
Key Concepts
Facilitator — the trusted third party that verifies signed payments and submits Solana transactions. Orchus runs its own at x402.agentstrail.ai.
Scheme — the payment scheme. Currently exact (pay exactly the listed amount in USDC).
Asset — the USDC SPL token mint address. Verified by the facilitator before settlement.
maxAmountRequired — the price in atomic USDC units (6 decimals). 10000 = 0.01 USDC.