AI & DevelopmentDeveloper ToolsInfrastructure

Stripe MPP and x402: How to Bill AI Agents for Your API

AI agent connecting to API endpoints via HTTP 402 payment protocol - x402 and Stripe MPP illustrated
x402 and Stripe MPP: agent payment protocols for API monetization

Your API is already being called by AI agents. Claude Code sessions, agentic Copilot workflows, and autonomous Codex tasks are hitting developer APIs right now — and when they encounter a paywall, they either fail silently or bounce a human back into the loop. HTTP 402 “Payment Required” was reserved in the original RFC back in 1995 for exactly this scenario. It took AI agents to make it useful. Two protocols launched this year finally implement it: x402 (Coinbase/Linux Foundation) and Stripe’s Machine Payments Protocol (MPP), released March 18, 2026. One takes 20 minutes to add to any Express app. The other plugs into Stripe if you already use it. Here is how to choose and implement both.

Why Agent Payments Break Without These Protocols

Traditional payment flows require a human: a browser redirect, a card entry form, a 3DS verification, a manual approval. AI agents have none of those. When an autonomous agent hits a paywalled endpoint, it has three bad options — fail with a 402 it cannot handle, escalate back to the human who launched it, or skip the call entirely. None are acceptable if you are building a monetized API.

The underlying issue is structural. The internet had no native settlement layer in 1995, so HTTP 402 sat unused for thirty years. Stablecoins and programmable payment APIs changed that. x402 and MPP are the first production implementations of what 402 was always supposed to enable.

x402: The Open Protocol Path

x402 is an open HTTP payment standard co-created by Coinbase and Cloudflare, now governed by the Linux Foundation. Stripe, AWS, Google, Shopify, Visa, and Mastercard all back the Foundation. The protocol settles in USDC on Base by default — under $0.001 per call, confirmed in under two seconds, no account required on either side.

The protocol flow is straightforward:

  1. Agent requests a paid resource
  2. Server returns HTTP 402 with payment requirements in headers (price, chain, wallet address)
  3. Agent pays from its pre-authorized wallet — no human needed
  4. Agent retries with payment proof in the request header
  5. Server verifies and returns the resource

For an Express app, adding x402 takes about ten lines:

import { x402Express } from '@x402/express';
import { facilitator } from '@x402/evm';

app.use('/api/data', x402Express({
  price: 0.01,        // $0.01 per call
  network: 'base',
  address: process.env.WALLET_ADDRESS,
  facilitator
}));

That is the entire paywall. Any agent with a funded Base wallet can now pay for your API autonomously. FastAPI and Next.js have equivalent packages (openlibx402-fastapi and Vercel’s x402-mcp template). In production, x402 has processed over 75 million transactions and $24 million in monthly volume as of May 2026. Neynar (social data), Hyperbolic (GPU inference), and Token Metrics (crypto analytics) are all x402-native.

Stripe MPP: The Fiat-First Path

Stripe’s Machine Payments Protocol, co-authored with Tempo and released on March 18, 2026, solves the same problem from the other direction. It uses the same HTTP 402 handshake, but accepts fiat payments — credit cards and BNPL — alongside stablecoins. If your users are enterprises paying with corporate cards, x402 alone does not work. MPP does.

The key innovation is the Shared Payment Token (SPT). When an agent needs to pay a fiat-accepting endpoint, it creates an SPT using the customer’s Stripe customer ID. The SPT is a scoped, expiring grant to use that payment method — the agent never sees the card number. The server receives the SPT, verifies it via Stripe’s API, and the funds settle to your existing Stripe balance on your standard payout schedule. All of Stripe’s compliance infrastructure — tax, fraud detection, reporting, refunds — applies automatically.

MPP integration requires a Stripe account and the 2026-03-04.preview API version. The full spec is open source at mpp.dev. Stripe Sessions 2026 added streaming-payments support, meaning agents can now pay per token of inference output rather than per API call. In production: Browserbase uses MPP for per-session headless browser access; Postalform lets agents pay to mail physical letters.

MCP Integration: Monetize Your Tools

MCP (Model Context Protocol) handles how agents discover and call tools. It does not handle payment for those tools. That gap is exactly what x402 and MPP fill. Vercel’s x402-mcp library wraps MCP tool definitions with x402 payment gates. The pattern:

  1. Agent discovers your MCP server and lists available tools
  2. Agent calls a paidTool — receives an x402 challenge instead of a result
  3. Agent pays from its wallet and retries the call
  4. Tool executes and returns the result

If you expose any functionality through an MCP server today, you can start charging for it this week. The agent runtime handles the payment loop; you just wrap the tool definition.

Which Protocol to Use

Start with x402. Add MPP when your customers pay with credit cards.

More specifically: choose x402 if you are building a new API with a crypto-native or developer audience, want zero protocol fees, or want the fastest path to first agent revenue. Choose MPP if you already use Stripe for billing, need to serve enterprise customers paying with fiat, need subscription or streaming payment cadences, or need Stripe’s compliance and reporting infrastructure.

Many production services support both. An agent using Claude Code with a corporate card pays via MPP; the same endpoint handles x402 for wallet-funded agents. The 402 handshake is identical — only the payment credential differs.

What to Do This Week

  • Express API: install @x402/express and @x402/evm, set your wallet address, wrap one endpoint. Under an hour.
  • Stripe users: upgrade to 2026-03-04.preview API version, review the MPP quickstart, add MPP middleware to one endpoint.
  • MCP server owners: try Vercel’s x402-mcp package — it is a one-click deploy template with Next.js and the AI SDK.
  • Audit first: check your server logs for non-human User-Agent strings. Those are your agents. Those endpoints are your first payment targets.

HTTP 402 waited thirty years for a use case. Agent-driven API traffic is it. Both protocols are production-ready, open-source, and backed by the largest payment and cloud infrastructure companies in the world. The infrastructure exists. The question is whether your API is ready to use it.

ByteBot
I am a playful and cute mascot inspired by computer programming. I have a rectangular body with a smiling face and buttons for eyes. My mission is to cover latest tech news, controversies, and summarizing them into byte-sized and easily digestible information.

    You may also like

    Leave a reply

    Your email address will not be published. Required fields are marked *