Skip to main content
A SaaS or data company already serves a paying customer base through API keys and contracts. Agent buyers are a new segment that does not sign contracts, does not register, and does not fit a seat or seat-overage plan. With x402 middleware in front of the routes you want priced, an agent making a fresh request sees 402 Payment Required, signs a payment, and gets the response back. Each settled call lands USDC in a wallet you control. The motion is additive. Your existing customers see no change. Agent traffic becomes a measurable line item without a procurement cycle. Who this is for:
  • SaaS platforms looking to open an agent-buyer channel without disrupting enterprise contracts
  • Data and API companies that want a per-call self-serve tier alongside their existing plans
  • Product and revenue leaders evaluating whether agentic commerce fits their API surface

How it works

Per-call monetization
1AgentAPICalls a priced route without a payment header
2APIAgent402 Payment Required with price and accepts block
3AgentAPIRetries with PAYMENT-SIGNATURE header
4APIFacilitatorVerifies signature, settles USDC on Polygon
5FacilitatorSeller walletUSDC settles to payout address
6APIAgent200 OK with response body and PAYMENT-RESPONSE receipt
Middleware runs after your existing auth. Calls with a valid API key flow through the existing path unchanged. Unauthenticated calls fall through to the x402 path. The Polygon-hosted facilitator (x402.polygon.technology for mainnet, x402-amoy.polygon.technology for Amoy) handles verification and settlement, so you do not run that infrastructure.

Get started

Add x402 v2 middleware in front of the routes you want priced. The Polygon-hosted facilitator handles verification and settlement, so you do not run that infrastructure. Existing API-key traffic flows through your existing path unchanged.

Install

bun install @x402/express @x402/core @x402/evm express
Full middleware setup, including configuration and the facilitator client, is in the x402 Quickstart for Sellers.

Price a route

Each priced route declares an accepts block. Amounts are in the smallest unit of the currency (USDC has six decimals, so 1000 = $0.001).
{
  "x402Version": 2,
  "accepts": [
    {
      "scheme": "exact",
      "network": "eip155:137",
      "maxAmountRequired": "1000",
      "description": "Single call to /v1/lookups/company"
    }
  ]
}

Test as a buyer

Verify the loop end-to-end with the Polygon Agent CLI:
polygon-agent x402-pay --url https://your-api.example.com/v1/lookups/company

Implementation

x402 Quickstart for Sellers

Add x402 v2 middleware to Express, Next.js, or Hono.

x402 How It Works

Protocol mechanics, accepts block shape, receipts.

Polygon Agent CLI

Test the loop end-to-end as an agent buyer.

Using the Polygon facilitator

Configure middleware against the Polygon-hosted facilitator.