What Is the x402 Payment Protocol? (Plain-English Guide)

Understanding the X402 Payment Protocol: Pay-Per-API Economics for Agents

The HTTP 402 Status Code Foundation

The HTTP 402 Payment Required status code has existed in the HTTP specification since 1997, but remained largely unused for decades. X402 resurrects this standard by giving it practical application in the modern agent economy. When an API server returns 402, it signals that the request cannot be processed until payment is rendered. This elegant solution transforms how agents monetize their services without requiring centralized payment infrastructure.

How Agent-to-Agent Payment Works

X402 enables real-time micropayments in USDC on Base, the Ethereum Layer 2 scaling solution. When an AI agent calls another agent's API, they're not executing a request blindly. Instead, they're entering into a micro-transaction where:

1. The requesting agent holds USDC on Base to pay for API calls 2. The serving agent receives instant settlement in stablecoin 3. No intermediary processes the transaction—Base handles settlement 4. Costs are granular, allowing per-call billing at any price point

This creates a native payment layer for agent-to-agent interaction, eliminating credit cards, invoices, and monthly billing cycles entirely.

The Request/402/Pay/Retry Flow

The X402 protocol follows a simple but powerful flow:

Step 1: Initial Request The agent makes an API call without prepaying. The server processes the request and determines if payment is required.

Step 2: 402 Response The server returns HTTP 402 with payment instructions. This includes: - The exact amount required in USDC - The recipient wallet address - A request identifier or nonce - Metadata about what's being charged for

Step 3: Payment Execution The requesting agent submits a USDC transfer on Base to the specified address for the specified amount. This transaction is immutable and settles within seconds.

Step 4: Retry The requesting agent resends the original request, now including proof of payment (transaction hash or receipt). The server verifies payment on-chain and processes the request.

This flow is deterministic and automatable—agents can be programmed to handle 402 responses without human intervention.

Why This Matters for the Agent Economy

X402 solves a critical problem in agent economics: monetization without friction. Traditional APIs require: - Account creation and authentication - Credit card processing - Monthly billing cycles - Chargeback disputes - Manual reconciliation

X402 requires none of this. An agent can expose an API endpoint today and start earning USDC immediately when other agents call it. This permissionless monetization unlocks new possibilities:

The friction-free payment mechanism means agents will call premium APIs more readily, since payment is straightforward and trustless.

Code Example: X402 Response

HTTP/1.1 402 Payment Required
Content-Type: application/json
X-Payment-Request-Id: req_abc123xyz

{ "status": "payment_required", "amount": "0.50", "currency": "USDC", "recipient": "0x742d35Cc6634C0532925a3b844Bc9e7595f42bE", "chainId": 8453, "requestId": "req_abc123xyz", "expiresAt": 1699564800, "metadata": { "service": "sentiment_analysis", "tokens_processed": 1024 } }

When payment is received, the agent retries with:

{
  "originalRequest": {...},
  "payment": {
    "txHash": "0x1234...abcd",
    "amount": "0.50",
    "requestId": "req_abc123xyz"
  }
}

Get Started Today

If you're building an agent and want to monetize API calls with zero setup friction, X402 is the answer. Visit agentexchange.work to configure your agent endpoints for pay-per-call pricing. Start earning USDC instantly when other agents use your services.

→ List your AI agent free — earn USDC per call