← Back to Blog
Education Jan 14, 2026

What is x402?

Understanding the protocol that lets machines pay for services using HTTP and cryptocurrency.

If you've ever seen "402 Payment Required" in a browser, you've encountered a rarely-used HTTP status code. x402 gives this code new life in the age of AI agents.

HTTP 402: A Brief History

When HTTP status codes were defined in the 1990s, code 402 was reserved for "Payment Required." The idea was that websites could require payment before serving content. But without a standard way to make payments over HTTP, the code was never widely adopted.

Until now.

Enter x402

x402 is a protocol that finally makes HTTP 402 useful. It defines a standard way for:

  • Services to request payment via HTTP headers
  • Clients to pay using cryptocurrency
  • Services to verify payment and grant access

How It Works

Here's the flow when an AI agent uses MailerAstro with x402:

Step 1: Request

The agent makes a request to send an email:

POST /api/v1/email/send
Content-Type: application/json

{"to": "user@company.com", "subject": "Hello"}

Step 2: Payment Required

The server responds with HTTP 402 and payment details:

{
  "x402Version": 1,
  "error": "Payment required",
  "minimumPurchase": 1.00,
  "accepts": [{
    "network": "base",
    "asset": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
    "payTo": "0xe6fBa7a54aF0975b80d3b26c14dDf64fb0c6a186"
  }]
}

Step 3: Payment

The agent sends USDC to the specified wallet on Base and gets a transaction hash.

Step 4: Retry with Proof

The agent retries the original request with the transaction hash:

POST /api/v1/email/send
X-Payment: 0x123...abc
Content-Type: application/json

{"to": "user@company.com", "subject": "Hello"}

Step 5: Success

The server verifies the payment on-chain and processes the request. The agent's wallet is credited with a balance for future requests.

Why This Matters

x402 enables a new paradigm: machines paying machines. This is crucial for:

  • Autonomous AI agents that need services without human setup
  • Microtransactions too small for credit card fees
  • Global access without banking restrictions
  • Programmable payments that can be automated

Why Base and USDC?

We chose Base (Coinbase's L2) and USDC because:

  • Low fees: Under $0.01 per transaction
  • Fast: Confirmations in seconds
  • Stable: USDC is pegged to USD, so $1 = $1
  • Accessible: No bank account needed

The Future

x402 is still early, but we believe it's the foundation for how AI agents will pay for services. As more APIs adopt x402, agents will be able to:

  • Send emails (MailerAstro)
  • Make API calls
  • Access compute resources
  • Store data
  • And much more...

Welcome to the future of machine-to-machine commerce. ⭐

The MailerAstro Team

Building email infrastructure for AI agents