You built an API. It's good. Developers use it. But there's a new type of customer knocking on your door — and they can't sign up.
AI agents are the fastest-growing consumer of APIs right now. They discover endpoints, try to call them — and hit your signup page. Account creation, email verification, credit card form. They can't continue. They leave. You never know they were there.
This isn't a future problem. It's happening today.
The opportunity you're missing
AI agents already spend millions on API calls every month. Coinbase's x402 protocol has settled over 75 million transactions. The agent economy is real.
Quick math: 10,000 agents call your API once a day at $0.01 each. That's $100/day — or $36,500/year. From traffic you're currently losing.
The solution: HTTP 402
HTTP 402 means "Payment Required." It's been in the HTTP spec since 1997. Nobody used it — until now.
Here's how it works:
- An agent sends a request to your API
- Your server responds with 402 Payment Required (price, token, wallet)
- The agent pays in USDC and retries
- Your API responds with 200 OK and the data
No accounts. No API keys. No invoices. Just HTTP.
Add it to your API in 5 minutes
Install:
npm install @monapi/sdk @x402/express
Add one function call:
import express from "express";
import { monapi } from "@monapi/sdk";
const app = express();
app.use(monapi({
wallet: process.env.WALLET,
price: 0.01, // $0.01 per request
}));
app.get("/api/weather", (req, res) => {
res.json({ temp: 22, city: "Berlin" });
});
app.listen(3000);
Test it:
$ curl -i localhost:3000/api/weather
HTTP/1.1 402 Payment Required
X-Payment-Price: 0.01
X-Payment-Token: USDC
X-Payment-Network: base
X-Payment-Wallet: 0x83...913
Any x402-compatible agent reads this, pays automatically, and retries. Your API responds normally.
Per-route pricing
Not every endpoint is worth the same:
app.use(monapi({
wallet: process.env.WALLET,
routes: {
"/api/weather": 0.01, // simple lookup
"/api/forecast": 0.05, // more compute
"/api/search": 0.10, // expensive query
},
}));
Also works with Next.js and MCP (Model Context Protocol). Same SDK, different entry points.
What happens under the hood
- Request — Agent calls your endpoint
- 402 — monapi intercepts, returns payment terms
- Payment — Agent signs USDC transfer via EIP-3009 and retries
- 200 — Facilitator verifies, settles on-chain, your API responds
Key details:
- Gas fees are sponsored. Agents only need USDC — no ETH, no MATIC. The x402 facilitator covers gas.
- Settlement in under 2 seconds. On Base, Arbitrum, or Polygon.
- Non-custodial. Payments go directly to your wallet. monapi never touches your funds.
- Free and open source. MIT licensed. No monapi fees.
Who's already paying?
Agents built with Coinbase AgentKit, Cloudflare Workers, and the Vercel AI SDK already support x402 payments. The infrastructure exists today.
Get started
Three options:
-
Interactive CLI:
npx monapi init— detects your framework, configures your wallet, generates code - Copy the code above — install, add middleware, deploy
- Read the full docs — every config option, every framework
Your API is already getting traffic from agents. The only question is whether you're getting paid for it.
Links:
- monapi.dev — Website
- GitHub — Source code
-
npm —
@monapi/sdk - Full article with sources — on monapi.dev
Top comments (0)