← Back to Articles
Payments

What is the x402 protocol?

x402 is not an agentic protocol per se, but rather an open, application-level protocol that revives the HTTP 402 status code. In the HTTP protocol, a status code refers to how an HTTP request ends. A 200 status code indicates that the server responded successfully, 500 suggests that the server could not handle the request correctly, whereas 404 suggests that the request itself was not fulfilled as the target of the request was not found. As the HTTP protocol was developed, its designers showed the foresight to reserve status code 402 — which we have rarely, if ever, seen implemented [1]. But not anymore.

Status 402 indicates that the server can handle the request, but the requester needs to pay for the resource. However, during the evolution of the internet there was no easy payment mechanism that could pay for a single HTTP request. The problem with paying for a single request is that the payment is likely going to be extremely small, perhaps a fraction of a cent. These could be called "micro-payments". Modern payment methods such as credit cards have very high transaction costs and are simply not viable for making these micro-payments.

With the popularization of cryptocurrencies, however, this changed. Coinbase, a leading cryptocurrency company, led the development of the x402 protocol in 2025 [2] — a payment protocol designed to utilize the 402 status code to make micropayments using on-chain stablecoins like USDC. The x402 Foundation, operating under the Linux Foundation (similar to how the Linux Foundation stewards other open standards), now oversees the development of this protocol, and companies like Visa, Mastercard, Stripe, Google, and AWS are among its 40 founding members [3].

This protocol uses low-fee chains like Base or Solana to allow clients to make micro-payments and settle them using USDC [4].

Architecturally, the x402 payment protocol is designed as a stateless, transport-layer economic handshake between an HTTP client and a web server. It standardizes how a machine reads a payment requirement, generates a cryptographic authorization, and proves settlement — all natively inside the standard HTTP lifecycle [2, 5].

There are three actors in a successful x402 request:

HTTP Handshake Mechanism

Step 1: The Server Challenge (HTTP 402)

When an unauthenticated or unpaid request hits a restricted endpoint, the server responds with an HTTP 402 Payment Required status. It attaches a PAYMENT-REQUIRED header containing the required payment details [5]:

HTTP/1.1 402 Payment Required
Content-Type: application/json
PAYMENT-REQUIRED: {
  "version": "2",
  "network": "eip155:8453",
  "token": "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",
  "amount": "50000",
  "recipient": "0x9876...5432",
  "nonce": "f8a29b4c0e",
  "expiresAt": 1782345600
}

Step 2: The Client Retries

The client reads the header in the 402 response, signs the exact billing parameters using its private key, and immediately retries the exact same HTTP request, this time attaching a PAYMENT-SIGNATURE header [5]:

POST /v1/generate-image HTTP/1.1
Host: ai-service.com
PAYMENT-SIGNATURE: {
  "signature": "0x4a8c9b...",
  "signer": "0x1234...abcd",
  "facilitator": "https://coinbase.com"
}

The signature, signer, and facilitator are sufficient for the server to securely pull money via the facilitator.

For the actual settlement, there are generally two alternatives: the EVM approach or the Solana approach to quick settlement [4].

Agentic Payments

x402 works seamlessly with agentic payments. LLM harnesses using MCP for tool interfacing can use the LLM to parse the 402 header and then use other tools to generate the signature and make new requests seamlessly with MCP. Production-ready middleware is available for nearly all major server frameworks, allowing this to be done transparently with little developer effort [6].

AgenticProtocols.dev is a one-stop place for all the various agentic protocols, and we wish to release toolkits to better understand, learn, and simulate x402 payments using agentic AI.


References

  1. [1] MDN Web Docs — 402 Payment Required: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/402
  2. [2] Coinbase — Introducing x402: a new standard for internet-native payments: https://www.coinbase.com/developer-platform/discover/launches/x402
  3. [3] Linux Foundation — Operational Launch of x402 Foundation (July 14, 2026): https://www.linuxfoundation.org/press/linux-foundation-announces-operational-launch-of-x402-foundation-to-standardize-internet-native-payments-for-ai-agents-and-applications
  4. [4] Solana — What is x402?: https://solana.com/x402/what-is-x402
  5. [5] x402 Protocol Specification (GitHub): https://github.com/coinbase/x402
  6. [6] Coinbase Developer Platform — x402 Documentation: https://docs.cdp.coinbase.com/x402/core-concepts/http-402