- Home
- Skills
- Web3 & Crypto
- x402 Paid API Builder
More screenshots
Works with the AI Agents you already use
x402 Paid API Builder
Turn any tool or dataset into a pay-per-call API that settles in USDC via the x402 protocol.
$24.99
x402 Paid API Builder
Example session with this skill installed
I have a Node.js function that enriches a company name with its website, employee count, and industry. Set up a paid API for it at 5 cents per call using x402, with a free way for buyers to see what they get before paying.
- Read your context and instructions
- Compiled the x402 paid api
Summary: Your endpoint is built. GET /enrich charges $0.05 per call over x402 on Base Sepolia for testing, and GET / is a free discovery route showing the price and a sample response so buyers can evaluate before paying. The server below is complete once you add your enrichment function and credentials.
The deliverable:
server.ts
```ts
import { createX402Server } from "@coinbase/cdp-sdk/x402";
import { paymentMiddlewareFromHTTPServer } from "@x402/express";
import express from "express";
const app = express();
app.use(express.json());
const payTo = process.env.X402_PAY_TO as `0x${string}`;
if (!payTo) {
throw new Error("Set X402_PAY_TO to the address that should receive payments");
}
const server = await createX402Server({
```
environment: "development", // switch to "production" before accepting real funds
```
payToConfig: {
type: "address",
```
evm: payTo, // one EVM address covers every EVM network the facilitator supports
```
},
routes: {
// Only routes listed here are paid; every other route stays free.
"GET /enrich": {
price: "$0.05",
networks: ["eip155:84532"], // Base Sepolia for testing; Base in production
description:
```
"Enrich a company name with its website, employee count, and industry. Input: company name. Output: website, employees, industry.",
```
},
},
});
app.use(paymentMiddlewareFromHTTPServer(server));
```
// Free discovery route: reachable without payment.
```
app.get("/", (_req, res) => {
res.json({
service: "Company Enrichment API",
```
summary: "Returns the website, employee count, and industry for a given company name.",
```
pricing: [
{
route: "/enrich",
method: "GET",
price: "$0.05",
network: "Base Sepolia while testing; Base in production",
},
],
sample_response: {
company: "Example Corp",
website: "https://example.com",
employees: 1200,
industry: "Software",
},
how_to_pay:
```
"Call the paid route without payment to receive HTTP 402 and the PAYMENT-REQUIRED header, then retry with a signed payment payload using any x402 client.",
```
});
});
```
// Paid route: the real capability.
```ts
app.get("/enrich", async (req, res) => {
const company = String(req.query.company ?? "");
if (!company) {
res.status(400).json({ error: "Provide a company name as the company query parameter." });
return;
}
const result = await enrichCompany(company);
res.json(result);
});
```
// Replace this placeholder with your real enrichment function.
```ts
async function enrichCompany(company: string) {
return { company, website: "", employees: 0, industry: "" };
}
app.listen(8402, () => {
console.log("Paid endpoint listening on port 8402");
console.log(`Receiving payments at ${server.payToEvmAddress}`);
});
**Setup and verification**
1. In package.json set `"type": "module"`, then run `npm install express @coinbase/cdp-sdk @x402/core @x402/evm @x402/svm @x402/extensions @x402/express`
2. Set `CDP_API_KEY_ID`, `CDP_API_KEY_SECRET`, and `X402_PAY_TO` (your receiving address) as shell variables
3. Start the server with `npx tsx server.ts`
4. Verify the paywall: `curl -i "http://localhost:8402/enrich?company=Acme"` returns HTTP 402 with a `PAYMENT-REQUIRED` header
5. Verify the free route: `curl -i http://localhost:8402/` returns the service card with pricing and the sample response
6. Run one paid call from a funded Base Sepolia wallet using any x402 client and confirm HTTP 200
Pricing check from the playbook: company enrichment sits in the $0.05 to $0.25 band, and $0.05 is the right starting point for a service with no payment history. Raise toward $0.10 once the payment log shows repeat buyers.
The route description runs 128 characters, inside the 500-character facilitator limit: "Enrich a company name with its website, employee count, and industry. Input: company name. Output: website, employees, industry."
**Next steps:**
- Create a free CDP API key at the Coinbase Developer Platform and fund a test wallet with Base Sepolia USDC from a public faucet
- Replace the placeholder `enrichCompany` function with your real lookup
- After both verification checks pass, switch `environment` to `"production"` and the route network to `["eip155:8453"]`, set a mainnet receiving address, restart, and re-run the 402 check before announcing the endpoint
Connects securely to your tools. The creator never sees your data.
About this skill
Sell access to any tool, dataset, or computation per call, and get paid in USDC directly to your wallet. This skill has your agent build a complete paid endpoint using the x402 payment protocol, the open standard that turns the reserved HTTP 402 status code into a working paywall for APIs. Buyers include people and AI agents that purchase tool calls mid-task.
What you get
- A complete Express server scaffold with every payment component wired: the Coinbase facilitator, the payment middleware, and route-level pricing
- You fill a small set of clearly marked values: route, price, and description
- A free discovery route on every endpoint, so buyers and agents see the price and a sample response before spending
- A pricing playbook with current per-call price bands by endpoint type, tiering patterns, and discovery-writing rules
- A verification checklist that walks you from testnet to mainnet: 402 check, paid test call, production switch
How it works
| Route | Payment | Purpose |
|---|---|---|
| GET / discovery route | Free | Service summary, price list, sample response |
| Your paid route | $0.01 and up per call | The real capability |
Unpaid requests receive HTTP 402 with payment details in the PAYMENT-REQUIRED header. The client retries with a signed payment payload, the facilitator verifies and settles onchain, and your route returns the result. Settlement goes to a wallet address you control. The default setup runs on Base Sepolia with test USDC; one settings change moves it to Base mainnet for real payments.
Who it is for
- Developers monetizing an existing tool, script, or dataset without building billing, auth, or subscription infrastructure
- API sellers who want per-call revenue from AI agent traffic, where agents discover and pay for services mid-task
- Anyone selling data, enrichment, reports, or generated content by the call
What you need
Node.js 22 or later, a free CDP API key from the Coinbase Developer Platform for the facilitator, and a wallet address that can receive USDC. The skill guides each step, including the faucet for test USDC.
How to use
Skills on Agensi run inside your AI agent. Copy the prompt, paste it into your agent, and it connects to Agensi and installs this skill for you. If a payment is needed, your agent shows it to you first.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill passes our trust checks below.
Security scanned
Passed our 8-point scan before listing
Fresh listing
Recently published to Agensi
Money-back guarantee
Doesn't do what its page promises? You get your money back.
Trust & safety
Security scanned
Verified clean 2 days ago
- Passed all security checks, Safe to install
Requires