We're excited to introduce Sangria — a payment network that makes it dead simple for agents and merchants to pay each other over HTTP.
Why We Built This
The internet was supposed to have native payments. HTTP 402 "Payment Required" has been in the spec since the 90s, but nobody ever built a real protocol around it — until now.
With the x402 protocol, any HTTP endpoint can require payment, and clients can automatically pay and get access. In many deployments, this can reduce or avoid account creation, static API keys, and subscription lock-in for one-off usage, though some merchants or environments may still require app-level identity, API keys, or pre-authorization controls.
How It Works
At a high level, Sangria supports three scenarios depending on who is on the platform:
- Scenario 1 — Client on Sangria, Merchant external (raw x402): the client pays with Sangria Credits while Sangria’s Treasury Wallet settles USDC on-chain.
- Scenario 2 — Both on Sangria: an internal ledger debit/credit (no blockchain, no ERC-3009 signing).
- Scenario 3 — Client external, Merchant on Sangria: the external client pays USDC on-chain and Sangria credits the merchant’s fiat balance.
The basic x402 request loop looks like this:
- Client makes a normal HTTP request
- Server responds with
402 Payment Requiredand a price - A payment authorization is signed via ERC-3009 TransferWithAuthorization
- Client retries the request with the payment header
- Server verifies, settles on-chain, and returns the data
Signing model by scenario:
- Scenario 1: the Sangria backend signs ERC-3009 server-side with the Treasury Wallet (secure key custody; never client-side SDK keys).
- Scenario 2: no signing; purely internal ledger updates.
- Scenario 3: the external client signs ERC-3009 with its own wallet.
from fastapi import FastAPI
from x402.http import FacilitatorConfig, HTTPFacilitatorClient, PaymentOption
from x402.http.middleware.fastapi import PaymentMiddlewareASGI
from x402.http.types import RouteConfig
from x402.mechanisms.evm.exact import ExactEvmServerScheme
from x402.server import x402ResourceServer
app = FastAPI()
facilitator = HTTPFacilitatorClient(FacilitatorConfig(url="https://x402.org/facilitator"))
server = x402ResourceServer(facilitator)
server.register("eip155:84532", ExactEvmServerScheme())
routes = {
"GET /premium": RouteConfig(
accepts=[PaymentOption(scheme="exact", pay_to="0xYourWallet...", price="$0.0001", network="eip155:84532")],
mime_type="application/json",
),
}
app.add_middleware(PaymentMiddlewareASGI, routes=routes, server=server)
@app.get("/premium")
async def premium():
return {"message": "Paid content!", "paid": True}
What's Next
We're working on:
- Variable pricing — pay based on actual usage, not a fixed price
- Multi-chain support — beyond Base Sepolia
- Agent-to-agent payments — autonomous agents transacting with each other
Stay tuned for more updates.