Intents Paywall
Charge AI agents and apps per API call or per digital good over x402, with Express, Hono or Next.js middleware. You settle in the asset you choose.
Intents Paywall charges for a request before your handler runs. A caller without a payment gets
402 Payment Required with a standard x402 PAYMENT-REQUIRED header. Its x402 wallet pays in
USDC on Base or Solana, retries, and your handler runs. You’re paid in the asset you chose in the
dashboard.
npm install @intents-fi/paywallExpress
Section titled “Express”import express from "express";import { intentsPaywall } from "@intents-fi/paywall/express";
const app = express();app.use( intentsPaywall({ secretKey: process.env.INTENTS_SECRET_KEY!, // ik_test_… while you build routes: { "GET /report": { price: "0.50", currency: "USD" } }, }),);app.get("/report", (_req, res) => res.json({ report: "…" }));import { intentsPaywall } from "@intents-fi/paywall/hono";app.use(intentsPaywall({ secretKey, routes: { "GET /report": { price: "0.50" } } }));Next.js route handlers
Section titled “Next.js route handlers”import { withPaywall } from "@intents-fi/paywall/next";
export const GET = withPaywall( { secretKey: process.env.INTENTS_SECRET_KEY!, price: "0.05" }, async () => Response.json({ answer: 42 }),);Routes and prices
Section titled “Routes and prices”- Keys are
"METHOD /path", or just"/path"for every method.:parammatches one segment and*matches the rest:"/files/:id": { price: "1.25" }. - Prices are USD with up to two decimals, from
0.01. - Each call is an invoice: the same webhooks (
invoice.paid) and the same Payments list. Unpaid calls to a route reuse the route’s open invoice, so a crawler doesn’t create one per request. - Routes show up in the dashboard’s Paywall page the first time they’re called, with calls paid and revenue.
How a call is paid
Section titled “How a call is paid”- No payment: the middleware asks Intents for the route’s invoice and returns its 402 (the
PAYMENT-REQUIREDheader and the JSON body). - The caller retries with
PAYMENT-SIGNATURE(x402 v2) orX-PAYMENT(v1). - The middleware hands the payment to Intents (
POST /v0/paywall/charge), which verifies and settles it. Only a payment this request settled runs your handler. A replayed signature, or one for an invoice someone else already paid, gets a fresh 402. - Your response carries
PAYMENT-RESPONSE.
The middleware holds no wallet and no key except your secret key. If Intents can’t be reached, it throws: a paywalled route is never served for free.
Small prices
Section titled “Small prices”Most per-call prices are below what cross-chain routes accept, so most paywall payments are
direct: USDC on Base or Solana straight to your own address, with no fee. If you settle in
another asset (BTC, USDT on Tron, SOL…), add a USDC on Base or USDC on Solana payout address under
Settlement in the dashboard, with the usual email code and 24-hour wait. That address takes the
small payments, and larger ones still reach your main asset (0.4%). If there’s no route and no
USDC address, the 402 has no x402 entry (x402.exactError: "below_route_minimum").
Test mode
Section titled “Test mode”With an ik_test_ key, callers pay testnet USDC on Base Sepolia (faucet.circle.com) through the
x402.org facilitator. No real money moves.
See Paying as an agent for the x402 details, and the Express example in
examples/paywall-express.
Charge for a paywalled request (Intents Paywall)
Section titled “Charge for a paywalled request (Intents Paywall)”POST /v0/paywall/charge
Called by @intents/paywall on the merchant’s server with its secret key. Without payment, returns the 402 to send the caller. With payment, verifies and settles it; paid: true means the merchant’s handler may run. Routes are recorded on first use so the dashboard can list them.
| Field | Type | Required | Notes |
|---|---|---|---|
method |
string | yes | HTTP method of the paywalled route |
path |
string | yes | The route as declared in code, e.g. /report |
price |
string | yes | USD, up to 2 decimals |
currency |
USD |
no | |
resource |
string | yes | The URL the caller requested |
description |
string | no | |
payment |
string | no | The caller’s PAYMENT-SIGNATURE or X-PAYMENT header, as received |
curl https://api.intents.fi/v0/paywall/charge \ -X POST \ -H 'authorization: Bearer $INTENTS_SECRET_KEY' \ -H 'content-type: application/json' \ -d '{ "method": "GET", "path": "/report", "price": "0.50", "resource": "https://api.example.com/report", "description": "Pro plan — 1 month" }'const response = await fetch("https://api.intents.fi/v0/paywall/charge", { method: "POST", headers: { authorization: `Bearer ${process.env.INTENTS_SECRET_KEY}`, "content-type": "application/json", }, body: JSON.stringify({ "method": "GET", "path": "/report", "price": "0.50", "resource": "https://api.example.com/report", "description": "Pro plan — 1 month" }),});
if (!response.ok) { const { error } = await response.json(); throw new Error(`${error.code}: ${error.message}`);}const data = await response.json();import osimport httpx
response = httpx.post( "https://api.intents.fi/v0/paywall/charge", headers={"authorization": f"Bearer {os.environ['INTENTS_SECRET_KEY']}"}, json={ "method": "GET", "path": "/report", "price": "0.50", "resource": "https://api.example.com/report", "description": "Pro plan — 1 month" },)response.raise_for_status()data = response.json()| Status | Means |
|---|---|
200 |
What to answer the caller |