MAILGENT
Protocol

x402

x402 is an open, HTTP-native payment protocol that lets any server charge any client per request using HTTP status code 402 (Payment Required).

Also calledx402 protocolHTTP 402 payments

What is x402?

x402 is an open, HTTP-native payment protocol that enables any server to charge any client per request without a billing system, API keys, or subscription management. It uses HTTP status code 402 (Payment Required) — reserved in the HTTP spec since 1999 but never standardized until now.

How x402 works

The x402 protocol uses a two-call exchange. On the first call, the client makes a standard HTTP request with no payment. The server responds with HTTP 402 and a payment requirement object containing the price, accepted currency, and payment address.

On the second call, the client signs the payment requirement using its wallet and retries the original request with a payment header. The server verifies the signature, settles the payment, and handles the request.

The entire exchange is synchronous from the client's perspective. For AI agents, the payment negotiation happens automatically — the agent pays and retries without interrupting its workflow.

x402 and MCP monetization

x402 is the payment protocol that powers MCP monetization. When an AI agent calls a paid MCP tool, the MCP server uses x402 to return the payment requirement. The agent's wallet handles the x402 negotiation and the tool runs once payment settles.

Mailgent implements x402 on the seller side via the requirePayment() middleware, and on the buyer side via agent wallets provisioned in each project. Tool authors never need to implement x402 directly — the middleware abstracts the full protocol.

Is x402 an open standard?

Yes. x402 is an open protocol. The payment requirement format is documented at mailgent.dev/.well-known/x402-discovery.json, and any facilitator can implement the same spec. Mailgent is one of the first production implementations of x402 for MCP servers.

x402 vs traditional payment protocols

A card payment integration needs a billing system, webhooks, and API keys; x402 needs a single HTTP response header. Card networks impose a roughly $0.30 plus 2.9% floor; x402 settles amounts as small as $0.01 in USDC. Card settlement takes two-to-seven business days and carries a chargeback window; x402 settles in about two seconds on Base and is final on-chain. Most importantly, card rails were never designed for machine-to-machine payments — x402 treats that as the native use case.

Build agents with their own identity.

Email, vault, and TOTP — provisioned in 30 seconds.

Get API Key — Free

Last updated: 2026-05-24