Quickstart
Ship a paid HTTP endpoint in ~5 minutes — five lines of middleware, USDC on Base, signed receipt back.
Wrap a handler so paying agents (or anyone with USDC on Base) can call it.
Building the agent side — an agent that consumes paid APIs, with its own wallet, inbox, and vault? That's Mailgent.
1. Create a project
console.loomal.ai → Create a project. You get an API key (loid-...).
In the project's Pay tab, switch Accept payments on — it's off by default on a fresh project.
2. Install the SDK and wrap your handler
npm install @loomal/sdk expressimport express from "express";
import { requirePayment } from "@loomal/sdk/paywall/express";
const app = express();
app.set("trust proxy", true);
app.get(
"/search",
requirePayment({ amount: "0.05" }),
(req, res) => res.json({ results: [/* ... */] }),
);
app.listen(3030);Set LOOMAL_API_KEY=loid-... and run the server. The middleware handles the 402 challenge, verifies the signed retry, settles on Base, and returns the X-Payment-Response header.
Other frameworks:
| Stack | Import |
|---|---|
| Hono | @loomal/sdk/paywall/hono |
| MCP (per-tool) | @loomal/sdk/paywall/mcp |
| FastAPI (Python) | pip install "loomal-sdk[fastapi]" |
3. Make a paid request
You need a caller with a few cents of USDC on Base to call your endpoint. The simplest path is to run a working caller from loomal-ai/loomal-pay-examples (clone, install, run).
When the call succeeds, your project's Pay → Activity tab shows the settled payment with an on-chain link.
4. Where to go next
- Full payment flow (raw REST, webhooks, refunds): Accept Payments.
- Working example to clone: Paid Search API.