Documentation
Everything you need to put x402 pricing in front of your API.
What is swerver
Swerver is a high-performance HTTP server and reverse proxy written from scratch in Zig. It supports HTTP/1.1, HTTP/2, and HTTP/3 (QUIC) with TLS 1.3, zero-copy request parsing, and pre-allocated buffer pools. It handles millions of requests per second on commodity hardware.
x402 payment negotiation is built in as native middleware. When a request hits a paid route, swerver returns the 402 challenge, verifies the payment signature, and proxies the paid request to your upstream origin. No sidecar, no plugin, no extra hop.
When you create a gateway on this platform, swerver is the runtime that serves it. Every request to your proxy URL (slug--gw.swerver.net) goes through swerver. This dashboard is the managed control plane. You configure gateways, routes, and pricing here. Swerver picks up the configuration and handles the rest.
How x402 works
x402 is an open payment protocol that uses HTTP status code 402 to negotiate per-request payments. When a client makes a request to a paid endpoint, the flow is:
- Client sends a request to your gateway proxy URL.
- Swerver returns
402 Payment Requiredwith pricing details, the wallet address, and accepted networks in the response headers. - Client submits payment (USDC on Base) and retries with a payment proof header.
- Swerver verifies the payment, proxies the request to your upstream API, and returns the response.
Clients that already have an x402 SDK handle this automatically. From the API provider side, you just create a gateway and set prices. Swerver handles negotiation, verification, and settlement.
Quick start
1. Create a gateway
In the dashboard, click New gateway. Give it a name, a slug (this becomes your proxy subdomain), and the upstream URL of the API you want to monetize.
Your gateway gets a proxy URL: https://{slug}--gw.swerver.net
2. Add routes
Routes define which paths on your API are proxied and how they're priced. On the gateway detail page, add a route with:
- Path - the URL path to match, e.g.
/v1/search - Method - GET, POST, or * for any method
- Price - cost per request in USDC (e.g. $0.01)
3. Enable the gateway
Toggle the gateway on. Swerver starts proxying traffic. If x402 is enabled, unpaid requests get a 402 response with payment instructions.
4. Set up payouts
Go to Settings and connect Stripe to receive automatic payouts. Revenue from x402 payments settles in USDC and is converted to USD for deposit to your bank account.
Making requests
Once your gateway is live, clients make requests to your proxy URL instead of the upstream API directly.
curl https://myapi--gw.swerver.net/v1/search?q=hello # Response: 402 Payment Required # Headers include: # X-Payment-Amount: 10000 # X-Payment-Asset: 0x833589f... (USDC on Base) # X-Payment-Receiver: 0xYourWallet...
After payment, the client retries with the payment receipt:
curl https://myapi--gw.swerver.net/v1/search?q=hello \ -H "X-Payment: <payment-proof>" # Response: 200 OK (proxied from your upstream API)
x402-compatible SDKs and AI agents handle this flow automatically. The payment negotiation is invisible to the end user.
Upstream authentication
If your upstream API requires authentication, add an API key during gateway creation. Swerver injects it as an Authorization: Bearer header on every proxied request. The key is encrypted at rest and never exposed in API responses or the dashboard UI.
Clients never see or need your upstream credentials. They pay via x402, and swerver handles forwarding with the right auth headers.
Pricing and settlement
Prices are set per route in USDC. The sweet spot for AI agent traffic is $0.01 to $0.10 per request. Set prices too high and agents will skip your API. Set them too low and it's not worth the settlement overhead.
Direct settlement (default)
By default, x402 payments settle directly to your wallet on-chain. You provide a USDC wallet address when creating a gateway, and every paid request settles USDC directly to that address on Base. There is no platform fee on direct settlements.
Managed payouts (optional)
If you don't want to deal with wallets or on-chain settlement, you can connect Stripe in Settings. Swerver collects USDC on your behalf, converts it to USD, and deposits it to your bank account. Managed payouts have a 2% platform fee to cover conversion and processing costs.
| Plan | Gateways | Routes / gateway | Managed payout fee | Price |
|---|---|---|---|---|
| Free | 1 | 3 | 2% | $0 |
| Pro | 3 | 10 | 2% | $19/mo |
| Business | 10 | Unlimited | 2% | $49/mo |
| Enterprise | Unlimited | Unlimited | 0% | Custom |
Direct settlement to your own wallet is always free on every plan. The managed payout fee only applies when using Stripe-based payouts.
Concepts
Gateway
A gateway is a reverse proxy that sits in front of your API. It gets its own subdomain (slug--gw.swerver.net), handles x402 payment negotiation, and forwards paid requests to your upstream URL.
Route
A route maps a path and method on your gateway to a price. You can have multiple routes per gateway with different prices. Routes without x402 enabled are proxied for free.
Settlement
When a client pays for a request, the USDC transfer is recorded as a settlement. Settlements track the amount, network, platform fee, and your net payout. View them on the Revenue page.
Payout
Payouts aggregate your settled revenue and send it to your connected Stripe account as USD. You can trigger payouts manually or set up automatic scheduling.
Agent integration
x402 is designed for machine-to-machine payments. AI agents with x402 support can discover your API through the directory, negotiate pricing automatically, and pay per request without human intervention.
To make your API discoverable, add tags when creating routes. Tagged endpoints appear in the directory where agents can browse available APIs by category and price.
Support
Questions or issues? Email info@swerver.net.