Monetize Gateway
Charge AI agents per call for your API, MCP server, or any REST endpoint. Put a paywall in front of it, share a gateway URL, get paid in USDC over x402 — no signup, no card, no session.
Monetize Gateway
Sell-side, self-serve
The Monetize Gateway is how you charge agents. Put a paywall in front of an endpoint you own; an agent that calls it pays per request in USDC over x402 before the call reaches your backend. Live on Base mainnet.
A paywall is a thin x402 seller in front of one of your endpoints. You
declare a price and where the money should land; CodeSpar issues an
HTTP 402 challenge on every unpaid call, verifies the agent's signed payment,
settles it on-chain, seals a receipt, and only then proxies the request to your
upstream. Private headers stay private; there is no order, no session, and no
account for the caller to create.
The flow
agent ──GET──▶ gw.codespar.dev/<slug> ──▶ 402 (price, payTo, network)
◀────────────────────────────────────┘
agent ──GET + X-PAYMENT──▶ gw.codespar.dev/<slug>
│ verify signature
│ settle USDC on Base ──▶ your payTo
│ seal receipt
└──▶ proxy to your upstream ──▶ 200 + dataEvery paid call settles USDC to the address you chose and closes with a hash-chained receipt. A caller that does not pay gets the 402 back; nothing reaches your upstream until the payment verifies.
Create a paywall
Admin auth required. See Authentication.
curl -X POST https://api.codespar.dev/v1/paywalls \
-H "authorization: Bearer $CODESPAR_API_KEY" \
-H "content-type: application/json" \
-d '{
"slug": "market-data",
"name": "Market data API",
"upstream_url": "https://api.yourservice.com/quote",
"price": "0.01",
"payto": { "kind": "provisioned" },
"consumer_id": "your-consumer"
}'The response carries the gateway URL you share with agents:
{
"id": "pw_...",
"slug": "market-data",
"price": "0.01",
"currency": "USDC",
"gateway_url": "https://gw.codespar.dev/market-data",
"payto_kind": "provisioned",
"active": true
}Who gets paid: payto
Settlement is non-custodial either way — the USDC lands directly at the destination you name, never in a CodeSpar pooled account.
payto.kind | Money lands in | When to use |
|---|---|---|
provisioned | The CodeSpar-derived wallet of the consumer_id you pass | You want a governed wallet you can also spend from, with receipts on both sides |
byo | The payto.address you pass (a 0x EVM address) | You already have a wallet and want the funds there directly |
Pricing
price is a decimal string of USDC per call, minimum "0.01". Endpoint-level
pricing: one paywall, one price. Charge different prices by creating more
paywalls in front of different upstream paths.
Path passthrough
gw.codespar.dev/<slug> and gw.codespar.dev/<slug>/<path> both dispatch to the
paywall; the trailing path is forwarded to your upstream_url. So a single
paywall can front a whole API surface, charging the same price per call.
Earnings
Read what a paywall has earned — an aggregate over its settled payments:
curl https://api.codespar.dev/v1/paywalls/pw_.../stats \
-H "authorization: Bearer $CODESPAR_API_KEY"{ "settled_count": 128, "gross": "1.28", "last_settled_at": "2026-07-10T21:04:11Z" }The dashboard's Machine payments page shows the same figure inline on each paywall.
Manage
GET /v1/paywalls— list your project's paywalls.PATCH /v1/paywalls/:id— changename,upstream_url,price, oractive(pause/resume).DELETE /v1/paywalls/:id— remove it.
Full field and error reference: Paywalls API.
Also settles in Pix
The same per-call idea runs on the LATAM lane: a paywall priced in BRL settles in Pix under the same mandate and receipt model. USDC/x402 is the global, developer-facing slot; Pix is the Brazil slot of the same runtime.
Related
- Pay to Agent — the other direction: an agent pays another agent by Agent ID.
- Facilitator — how x402 verification and settlement work.
- Audit chain — the receipt every settlement seals.
Directed-pay
Consumer-mandate flow — accounts charge an end-consumer's rail (Pix consent, card token, TED debit-auth) under a signed, capped, revocable consent. The non-wallet half of AgentGate's commerce primitives.
Pay to Agent
Pay another agent by Agent ID instead of a raw address. The recipient must be a registered, non-revoked identity — never an anonymous wallet. Payouts, splits, and tips over USDC on Base mainnet.