cd /news/developer-tools/monetize-express-js-apis-for-ai-agen… · home topics developer-tools article
[ARTICLE · art-115336] src=dev.to ↗ pub= topic=developer-tools verified=true sentiment=· neutral

Monetize Express.js APIs for AI Agents in 3 Lines of Code with x402

A developer released x402-express, an npm package that lets Express.js developers monetize APIs for AI agents with three lines of code. The middleware returns HTTP 402 Payment Required responses with payment parameters and autonomously verifies settlements on Base.

read1 min views1 publishedAug 29, 2026

AI agents are increasingly making programmatic requests, but traditional billing (credit cards, OAuth, complex API keys) creates friction for automated microtransactions.

With x402-express, you can monetize any Express.js endpoint using HTTP 402 payment requirements on Base in 3 lines of code.

bash

npm install x402-express

Add the middleware to any route you want to protect:

javascript

const express = require('express');

const { x402Middleware } = require('x402-express');

const app = express();

app.get('/api/agent-data', x402Middleware({ price: '0.01' }), (req, res) => {

res.json({ message: "Payment verified via x402!" });

});

app.listen(3000, () => console.log('Server running on port 3000'));

io.github.ihen404/x402-express

When an unauthenticated agent hits your endpoint, x402-express

interceptively returns an HTTP 402 Payment Required

payload containing payment parameters, verifying settlements autonomously.

── more in #developer-tools 4 stories · sorted by recency
── more on @x402-express 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
Live at https://your-agent.zahid.host
Get free account → Pricing
from €0/mo · no card required
LIVE [news/monetize-express-js-…] indexed:0 read:1min 2026-08-29 ·