Open Protocol for Internet-Native Payments

Learn x402: Internet-Native Payments

Enable instant, automatic stablecoin payments directly over HTTP. Monetize APIs and digital content without accounts, sessions, or complex authentication.

2s
Settlement Time
0%
Protocol Fees
Micropayments
100%
Open Source

Built for Modern Internet Commerce

x402 enables new business models that were previously impossible or impractical with traditional payment systems.

Pay-Per-Use APIs
Monetize your APIs with per-request pricing. No subscriptions, no accounts—just instant payments for each API call.
$0.001 per weather API request
AI Agent Transactions
Enable autonomous AI agents to pay for services programmatically without human intervention or pre-configured accounts.
AI agents accessing data APIs
Content Paywalls
Monetize digital content with micropayments. Readers pay only for what they consume, no subscriptions required.
$0.05 per premium article
Microservices Monetization
Internal or external microservices can charge for compute, storage, or processing on a per-transaction basis.
Image processing at $0.002/image
AI Model Access
Provide access to AI models with pay-per-inference pricing. Perfect for specialized or fine-tuned models.
$0.01 per model inference
Proxy & Aggregation
Build proxy services that aggregate multiple APIs and resell access with transparent, automated payments.
Multi-API gateway with markup

How x402 Works

A simple request-response flow with programmatic payments built directly into HTTP.

1

Client Requests Resource

A client (human or AI agent) makes an HTTP request to access a protected API endpoint or content.

GET /api/weather HTTP/1.1
2

Server Returns 402

If payment is required, the server responds with HTTP 402 Payment Required with payment requirements in the response body.

HTTP/1.1 402 Payment Required
Content-Type: application/json

{"accepts": [{"paymentRequirements": {...}}]}
3

Client Sends Payment

The client constructs a payment payload (base64-encoded JSON) with blockchain transaction details and retries the request.

GET /api/weather
X-PAYMENT: eyJ4NDAyVmVyc2lvbiI6IjAuNy4wIi4uLg==
4

Server Verifies & Responds

The server verifies the payment via the facilitator. If valid, it returns the requested resource.

HTTP/1.1 200 OK
{"weather": "sunny"}

Try It Yourself

Experience the x402 payment flow in a safe sandbox environment. No real payments required.

Interactive Sandbox
Select an API endpoint and simulate the x402 payment flow

Implementation Examples

Get started quickly with these code examples for popular frameworks.

Quick Start Code
Copy and paste these examples to start accepting x402 payments
# Step 1: Initial request to protected endpoint
curl -i https://api.example.com/weather

# Response: HTTP 402 Payment Required
# {
#   "accepts": [{
#     "paymentRequirements": {
#       "scheme": "exact",
#       "network": "base-sepolia",
#       "amount": "0.001",
#       "asset": "0x036CbD53842c5426634e7929541eC2318f3dCF7e",
#       "destination": "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb"
#     }
#   }]
# }

# Step 2: Make payment on-chain and construct payload
# Payment payload (before base64 encoding):
# {
#   "x402Version": "0.7.0",
#   "scheme": "exact",
#   "network": "base-sepolia",
#   "payload": { "txHash": "0xabc123...", ... }
# }

# Step 3: Retry request with X-PAYMENT header (base64-encoded)
curl -i https://api.example.com/weather \
  -H "X-PAYMENT: eyJ4NDAyVmVyc2lvbiI6IjAuNy4wIiwic2NoZW1lIjoiZXhhY3QiLi4ufQ=="

# Response: HTTP 200 OK with X-PAYMENT-RESPONSE header
# {
#   "weather": "sunny",
#   "temperature": 72
# }

Protocol Details: The X402 protocol uses the X-PAYMENT header with base64-encoded JSON payloads for payment submission, and X-PAYMENT-RESPONSE for settlement confirmation. Payment requirements are sent in the 402 response body.

Middleware: The x402 middleware packages automatically handle base64 encoding, header formatting, and facilitator communication so you don't have to implement the low-level protocol details.

Note: These examples use the Base Sepolia testnet facilitator. For production, use the mainnet facilitator from Coinbase CDP.

Built with Security in Mind

x402 leverages blockchain security while maintaining simplicity and privacy.

Blockchain Security
All payments are secured by blockchain technology with cryptographic verification.
No Account Required
No personal information, passwords, or account creation needed. Privacy by design.
Transparent Verification
All transactions are verifiable on-chain. Complete transparency and auditability.
Instant Settlement
2-second settlement times with immediate payment confirmation.
Sandbox Environment
This demo uses a secure sandbox for educational purposes
  • Testnet-only transactions (Base Sepolia)
  • No real money involved in demo
  • Isolated sandbox environment
  • Rate limiting and abuse prevention
  • Educational purposes only

Resources & Documentation

Everything you need to start building with x402.

Official Documentation
Complete guides, API references, and tutorials
GitHub Repository
Open source code, examples, and contributions
Coinbase CDP Docs
Production facilitator and mainnet deployment
Community & Support
Join discussions and get help from the community
Ready to Build?
Start integrating x402 into your application today