Create, test, and deploy a paid x402 micropayment service that other agents can call.
npm install -g @bankr/clibankr login --api-key YOUR_KEYbankr x402 init
Creates x402/ directory and bankr.x402.json config file.
Create x402/YOUR-SERVICE/index.ts:
export default async function handler(req: Request): Promise<Response> {
// Validate input
if (req.method !== "POST") {
return Response.json({ error: "POST required." }, { status: 405 });
}
let body: any;
try {
body = await req.json();
} catch {
return Response.json({ error: "Invalid JSON." }, { status: 400 });
}
// Your logic here — can make outbound HTTP calls
// Available: fetch(), crypto, Buffer, setTimeout
// NOT available: fs, require, node modules
return Response.json({ result: "your data" });
}
In bankr.x402.json:
{
"services": {
"your-service": {
"description": "What it does — be specific, agents read this",
"price": "0.001",
"methods": ["POST"],
"schema": {
"input": {
"type": "object",
"properties": {
"query": {"type": "string", "description": "What to search for"}
},
"required": ["query"]
},
"output": {
"type": "object",
"properties": {
"result": {"type": "string", "description": "The answer"}
}
}
}
}
}
}
bankr x402 env set MY_SECRET=value
Variables are encrypted at rest and available as process.env.MY_SECRET in your handler.
bankr x402 deploy your-service
Returns the live URL: https://x402.bankr.bot/YOUR_WALLET/your-service
bankr x402 call "https://x402.bankr.bot/YOUR_WALLET/your-service" \
-X POST -d '{"query":"test"}' --yes
Requires USDC in your wallet to pay yourself.
Before deploying, verify:
| Service Type | Suggested Price | Why |
|---|---|---|
| Free API wrapper | $0.001 | Low value, high volume |
| RPC data aggregation | $0.002-0.01 | Medium value |
| AI-powered analysis | $0.003-0.01 | Groq/LLM costs ~$0.0001 |
| Unique primitive | $0.005-0.05 | High value, novel capability |
| Premium/outcome | $1-100 | Delivers measurable results |
Your earnings appear in: bankr x402 list
Platform fee: 5% (after first 1,000 free requests/month)
This workflow was tested on April 5, 2026 with 43 services successfully deployed.