Accept your first AI agent payment with Prism in minutes.
This guide takes you from zero to accepting AI agent payments. You’ll set up a server endpoint that requires stablecoin payment via the x402 protocol — any AI agent with a compatible wallet can pay and access it.
Protect an endpoint with x402 payment verification. When an agent hits this endpoint without paying, it gets a 402 Payment Required response with payment instructions. After paying, the request goes through.
Express.js
FastAPI
Flask
import express from "express";import { prismPaymentMiddleware } from "@1stdigital/prism-express";const app = express();app.use( prismPaymentMiddleware( { apiKey: process.env.PRISM_API_KEY, baseUrl: "https://prism-gw.fd.xyz", }, { "/api/premium": { price: "$0.01", description: "Premium API access", }, } ));app.get("/api/premium", (req, res) => { res.json({ message: "Premium content", payer: req.payer, // wallet address that paid });});app.listen(3000, () => console.log("Server running on port 3000"));
This confirms the middleware is working. Any AI agent with a compatible wallet (including Agent Wallet) can now pay and access the endpoint automatically.
To test the full payment flow, use the Agent Wallet
CLI or connect an Agent Wallet via
MCP and ask the agent to access
your endpoint.