x402 Protocol
x402 Protocol
x402 is an open HTTP payment protocol. The name comes from HTTP status code 402 Payment Required — a status code that has existed in the HTTP specification since 1991 but was never widely used until x402 gave it a standard machine-readable format.Here is how it works in practice:
- Your agent calls a URL that is protected by a price.
- Instead of an authorization error, the server returns HTTP 402 with an
X-Payment-Requirementsheader. That header is a JSON object describing the amount required, the accepted currency (USDC), the network, and the facilitator address. - Your agent client reads the requirements, constructs a payment, and retries the same request with an
X-PAYMENTheader containing a signed authorization. - The server verifies the payment and returns the normal response.
X-Payment-Requirements Header
X-Payment-Requirements Header
X-Payment-Requirements is the response header your gateway sends alongside an HTTP 402. It is a JSON object that tells the agent client exactly what payment to make. Key fields include:| Field | What it means |
|---|---|
scheme | Always "exact" on Meterlane — the agent pays the stated amount exactly |
network | EIP-155 chain ID string, e.g. "eip155:84532" for Base Sepolia |
maxAmountRequired | USDC amount in the smallest unit (6 decimals), e.g. "1000000" = 1 USDC |
asset | The USDC contract address on the target network |
payTo | The wallet address that will receive the USDC |
maxTimeoutSeconds | How long the signed payment authorization remains valid |
@meterlane/x402 SDK handles it automatically. However, understanding it helps you set route prices and debug payment failures.X-PAYMENT Header
X-PAYMENT Header
X-PAYMENT is the request header an agent client adds when retrying a request after receiving a 402. It contains a Base64-encoded ERC-3009 signed authorization — essentially a cryptographic promise that the agent’s wallet will transfer the required USDC to the route’s payTo address. The facilitator verifies this authorization and settles the transfer on-chain before the gateway proxies the request upstream.ERC-3009 (Signed Authorization)
ERC-3009 (Signed Authorization)
Org
Org
An org is your tenant in Meterlane. When you sign up at meterlane.app and complete onboarding, you create an org. Everything in Meterlane belongs to an org:
- API keys — credentials you use to call the Gateway and Corridor REST APIs
- Routes — URL patterns you define and gate behind a USDC price
- Wallets — the addresses that receive USDC from agent payments or hold funds for corridor payouts
- Billing plan — the Meterlane subscription tier that determines your request limits and corridor access
https://gateway.meterlane.app/gateway/{your-org-slug}/{route-name}.API keys follow the format bp_live_… for production. Sandbox keys are clearly labeled in the dashboard.API Key
API Key
API keys authenticate your server-side calls to the Meterlane REST APIs (dashboard management, corridor quote/settle). They are not used by agent clients making x402 payments — agents authenticate via signed ERC-3009 authorizations, not API keys.Production API keys use the format
bp_live_…. Keep them in environment variables and never expose them in client-side code or public repositories.Route
Route
A route is a URL pattern you register in the Meterlane dashboard under your org. Each route has a price per request denominated in USDC and points to an upstream URL — the actual API endpoint you want to protect.When an agent calls
https://gateway.meterlane.app/gateway/{org-slug}/{route-name}, the gateway checks whether a valid x402 payment was made for that route’s price. If yes, it proxies the request to your upstream and returns the response. If no, it returns HTTP 402.Routes are scoped to your org, so only your org’s pricing and upstream configuration are applied.Facilitator
Facilitator
The facilitator is the service that verifies and settles x402 payments on-chain. When the gateway receives a request with an
X-PAYMENT header, it forwards the signed ERC-3009 authorization to the facilitator. The facilitator validates the signature, checks for replay attacks, submits the transferWithAuthorization transaction to the USDC contract, and confirms settlement.In the Meterlane sandbox, the public facilitator at x402.org handles verification on Base Sepolia. For production mainnet traffic, Meterlane uses a private mainnet-capable facilitator — you do not configure this yourself; it is managed as part of your plan.Corridor
Corridor
A corridor is a USDC-to-local-fiat payout rail. You call the Corridor API to request a quote for a destination currency, then send USDC from your org wallet to initiate settlement. Circle CPN handles the fiat leg and delivers local currency to your beneficiary’s bank account.Meterlane currently supports the following corridors:
Corridor transaction fees range from 0.25% to 0.65% depending on your plan. Settlement typically completes in minutes rather than the 3–5 business days typical of correspondent-bank wire transfers.
| Destination currency | Country/Region |
|---|---|
| BRL | Brazil |
| MXN | Mexico |
| NGN | Nigeria |
| KES | Kenya |
| ZAR | South Africa |
USDC
USDC
USDC is a fully-reserved US dollar stablecoin issued by Circle. One USDC is always worth one US dollar. Meterlane uses USDC as the payment currency for all Agent Gateway transactions and as the source currency for all Stablecoin Corridor payouts.On-chain, USDC uses 6 decimal places. An amount of
1000000 in the X-Payment-Requirements header equals exactly 1.00 USDC.In the sandbox, you use test USDC on Base Sepolia — available for free from the Circle faucet. Test USDC has no real-world value and can be used freely during development.Base Sepolia vs Base Mainnet
Base Sepolia vs Base Mainnet
Meterlane runs on Base, a Layer 2 network built on Ethereum by Coinbase. Base offers fast, low-cost transactions suitable for per-request micropayments.
All documentation examples use Base Sepolia. When you are ready to accept real payments, request production access from your Meterlane dashboard.
| Base Sepolia | Base Mainnet | |
|---|---|---|
| EIP-155 chain ID | eip155:84532 | eip155:8453 |
| Purpose | Sandbox / development | Production |
| USDC | Test USDC (no value) | Real USDC |
| Facilitator | Public x402.org | Private (Meterlane-managed) |
| Access | Available immediately | Requires go-live review |
Quickstart
See these concepts in action — make your first paid API call in under five minutes.
Agent Gateway Overview
Configure routes, set prices, and connect your upstream API.