Skip to main content
Every request to a gateway route goes through a two-step cycle: the gateway first challenges the agent for payment, then — once a valid signed payment is attached — verifies settlement on-chain and proxies the request to your upstream. The entire round-trip is transparent to the agent’s caller and typically completes in under a second. Understanding this flow helps you build agents that handle payment challenges gracefully and diagnose errors quickly.

Request lifecycle

Headers

HeaderDirectionPurpose
X-PAYMENTRequestBase64-encoded signed payment payload (ERC-3009 transferWithAuthorization)
X-Payment-RequirementsResponse (402)JSON object describing the amount in USDC, the payee address, and the target network
Idempotency-KeyManagement API requestsPrevents duplicate route creation or configuration changes on retry
The X-Payment-Requirements response tells the agent exactly what to sign. A typical requirements object looks like this:
{
  "scheme": "exact",
  "network": "eip155:84532",
  "payTo": "0xYourReceiverAddress",
  "maxAmountRequired": "10000",
  "asset": "0x...",
  "extra": {}
}
maxAmountRequired is denominated in the token’s smallest unit (USDC uses 6 decimals, so 10000 = $0.01).

Network selection

The gateway routes your payment to the correct network based on your route’s configuration.
NetworkChain IDWhen to use
Base Sepoliaeip155:84532Development and sandbox testing
Base mainneteip155:8453Production — live USDC payments
The public facilitator at https://x402.org/facilitator always targets Base Sepolia. To accept live USDC on Base mainnet, configure your route with "network": "eip155:8453" and use a production-mode facilitator.

Trying the demo route

You can inspect a real 402 response right now using curl. No account or API key required:
curl -i https://gateway.meterlane.app/gateway/demo/demo
The response will look similar to this:
HTTP/2 402
content-type: application/json
x-payment-requirements: {"scheme":"exact","network":"eip155:84532","payTo":"0x...","maxAmountRequired":"1000","asset":"0x..."}

{
  "error": "Payment required",
  "accepts": [
    {
      "scheme": "exact",
      "network": "eip155:84532",
      "payTo": "0x...",
      "maxAmountRequired": "1000"
    }
  ]
}

Nonce replay protection

The gateway tracks every payment nonce it has processed. Once a signed payment nonce has been used, any attempt to replay the same signed payload is rejected. This prevents double-spending on a single authorization.

Error codes

All error responses share the same shape:
{
  "code": "NONCE_REPLAY",
  "message": "This payment nonce has already been used.",
  "requestId": "3f2a1b4c-..."
}
CodeHTTP statusMeaning
NONCE_REPLAY402The signed payment nonce was already consumed — generate a fresh authorization
NOT_FOUND404No active route matches the requested path under this org slug
ORG_SUSPENDED403The organization’s account is suspended
PLAN_LIMIT_EXCEEDED402Monthly request limit for the organization’s plan has been reached
MISCONFIGURED503The organization has no receiver wallet configured
UPSTREAM_TIMEOUT504Your upstream did not respond within the allowed time window
UPSTREAM_UNAVAILABLE503No healthy upstream target could be reached
INTERNAL_ERROR500Unexpected gateway error — include requestId when contacting support
Always capture requestId from error responses. It is the fastest way for the Meterlane support team to trace a specific request through the system.