Skip to content

X402 Payment Protocol

Agentis implements the X402 HTTP payment protocol, the emerging standard for AI agent payments.

The X402 protocol enables:

  • Standardized Payments - Consistent payment flow across all APIs
  • Agent Compatibility - AI agents can automatically handle payments
  • Micro-transactions - Support for very small payments per API call
  • Global Accessibility - No KYC or traditional banking required
  1. Initial Request - Client makes request to API endpoint
  2. Payment Required - Server responds with 402 status and payment details
  3. Payment Processing - Client processes payment using specified method
  4. Authenticated Request - Client retries request with payment proof
  5. Response Delivery - Server validates payment and returns data

When payment is required, APIs return a 402 status with payment details:

HTTP/1.1 402 Payment Required
Content-Type: application/json
{
"x402Version": 1,
"error": "Payment required",
"accepts": [{
"scheme": "eip712",
"network": "base",
"maxAmountRequired": "1000000",
"resource": "/api/protected",
"payTo": "0x742d35Cc6634C0532925a3b8D71E432BD78FE7",
"asset": "USDC"
}]
}

The primary payment method uses EIP-712 typed signatures:

{
"scheme": "eip712",
"network": "base",
"maxAmountRequired": "1000000",
"payTo": "0x742d35Cc6634C0532925a3b8D71E432BD78FE7",
"asset": "USDC"
}

Some APIs may use the legacy header-based format:

HTTP/1.1 402 Payment Required
X-Payment-Requirements: {"amount":"0.01","token":"USDC","recipient":"0x...","chain":1}

When implementing X402 in your API:

  1. Detect payment requirement - Check if user has valid payment session
  2. Return 402 response - Include payment details in response body
  3. Validate payment proof - Verify payment signature on retry
  4. Process request - Handle the original request after payment validation
  • Automatic discovery - Agents can detect payment requirements
  • Standardized flow - Consistent payment process across services
  • Micro-payment support - Enable small, frequent payments
  • No human intervention - Fully autonomous payment processing