DEV Community

Edison Flores
Edison Flores

Posted on

What is x402? HTTP 402 Payment Required for AI agents

x402 revives the unused HTTP 402 status code for native HTTP-level payments. Governed by the Linux Foundation with Coinbase, Cloudflare, Stripe, Google, and Visa as founders.

The problem

AI agents need to pay for things. Today, every payment integration is custom. No standard means no interoperability.

What x402 does

x402 brings back HTTP 402 ("Payment Required"), a status code reserved since 1991 but never used.

The flow

  1. Agent sends a request to a server
  2. Server responds with HTTP 402 + payment instructions
  3. Agent pays on-chain (USDC on Base)
  4. Agent retries with payment proof
  5. Server verifies on-chain and returns content

Example response

HTTP/2 402
www-authenticate: x402 realm="marketnow", chain="base", token="USDC"
x-payment-amount: 1990000
x-payment-chain: base
x-payment-contract: 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913
x-payment-to: 0x39Dddf5aEdb58A559CF195fB8bdF23F0604Bf5Ee
x-payment-token: USDC
Enter fullscreen mode Exit fullscreen mode

Why it matters

  • Standard: any agent that speaks x402 can pay any x402-enabled server
  • Auditable: payments are on-chain
  • Governed: Linux Foundation, not a single company
  • Real adoption: Stripe, Coinbase, Cloudflare, Google, Visa

MarketNow's implementation

MarketNow returns HTTP 402 on /api/agent-purchase when payment is required. Try it:

curl -X POST https://marketnow.site/api/agent-purchase \
  -H "Content-Type: application/json" \
  -d '{"skillId":"mn-gen-00003","mandateId":"mand_xxx"}'
Enter fullscreen mode Exit fullscreen mode

Links

— Edison Flores, AliceLabs LLC

Top comments (0)