This page covers x402 from the merchant/facilitator perspective. For the
buyer/agent side, see Agent Wallet (Buyer Side).
How It Works
- A request arrives without a valid payment header
- Middleware returns 402 Payment Required with
x402Version,accepts, andresourcefields - The agent’s wallet pays on-chain and retries with an
X-PAYMENTheader - Prism’s Spectrum layer verifies the on-chain transfer
- If valid, the request proceeds and the transaction hash returns in
X-PAYMENT-RESPONSE
Integration
You don’t implement the x402 protocol directly — the Prism SDK middleware handles it. You configure what to charge, and the middleware handles the 402 response, payment verification, and settlement automatically. It’s available for TypeScript, Python, and Java frameworks:Payment Requirements (402 Response)
When the middleware returns 402, the response body contains:
The
resource object contains:
Each entry in
accepts contains:
Payment Verification
When the agent sends a request with theX-PAYMENT header:
- Prism parses the signed payment from the header
- Forwards it to the Spectrum settlement layer
- Spectrum executes the on-chain transfer and verifies: correct amount, correct token, correct recipient, valid signature
- If settlement succeeds, the request proceeds and the transaction hash is returned in the
X-PAYMENT-RESPONSEheader - If settlement fails, the middleware returns 402 with an error
Pricing Models
Fixed Pricing
Set a static price per endpoint — every request costs the same:Tiered Pricing
Different prices for different endpoints:Dynamic Pricing
For endpoints where the price depends on the request, apply per-route middleware:SDK Overview
Framework guides for TypeScript, Python, and Java
x402 Implementation
Both sides of x402: the wallet signs, Prism settles