402HTTP Payment Protocol

The settlement layer
for agentic commerce

AI agents pay for web resources with stablecoins via standard HTTP. You add one middleware. We handle signature verification, gas, and on-chain settlement.

How it works

One HTTP request. One stablecoin payment. Zero gas for the buyer.

01Request

Agent hits your API endpoint

GET /api/weather?city=london
02402 Response

Server responds with pricing

402 + PaymentRequirements{}
03Sign

Agent signs ERC-3009 off-chain

X-PAYMENT: <base64 payload>
04Verify + Settle

PayZap verifies sig, submits tx

transferWithAuthorization()
05Deliver

Resource served, merchant paid

200 OK + { data: ... }

Buyer never pays gas

The agent signs an off-chain authorization. PayZap submits the transaction and covers all network fees.

EIP-712 verified

Every payment is cryptographically verified off-chain before on-chain settlement. No trust required.

Async settlement

API responds immediately after verification. On-chain settlement happens in the background via per-chain queues.

Use cases

Any API can become a paid resource

If it has a URL and returns data, it can accept payments through x402.

AI agent access control

Monetize APIs that AI agents consume

Your API returns a 402 status code with pricing info. The agent's wallet signs an ERC-3009 authorization. Our facilitator submits the transaction — the agent never touches gas.

Who: LLM tool providers, AI API marketplaces, autonomous agent platforms

Pay-per-call data feeds

No subscriptions, no API keys — just pay per request

Price data, market intelligence, weather, geolocation — any data endpoint. Agents pay the exact cost of each call in stablecoins. No rate limits, no plans to manage.

Who: Data providers, oracle services, real-time feed aggregators

Compute & inference

GPU time, model inference, serverless compute

Sell compute on demand. An agent sends one HTTP request, pays $0.003 for a GPU inference call, and gets the result. Settlement happens in the background — you get the stablecoin.

Who: GPU cloud providers, model hosting platforms, serverless compute

Premium content & SaaS

Gated content, premium features, metered SaaS access

Protect any URL with a paywall. Human users get redirected to a payment page. AI agents negotiate and pay programmatically via the x402 handshake — same endpoint, both work.

Who: Content platforms, SaaS with metered tiers, research databases

Integration

Five lines of code to monetize your API

server.ts
import express from 'express';
import { createPaywall } from '@payzap/x402-middleware';

const app = express();

const paywall = createPaywall({
  facilitatorUrl: 'https://api.payzap.cc',
  payTo:          '0xYourWallet...',
  network:        'eip155:8453',  // Base
  asset:          '0x833589...USDC',
  amountUsd:      0.01,
});

app.get('/api/weather', paywall, (req, res) => {
  // This only runs after verified payment
  res.json({
    city: 'London',
    temp: 18,
    receipt: req.x402Receipt,
  });
});
npmnpm i @payzap/x402-middleware

What happens under the hood

  1. 1Request without X-PAYMENT header → middleware returns 402 with PaymentRequirements
  2. 2Agent decodes requirements, signs ERC-3009 TransferWithAuthorization
  3. 3Agent retries with base64 payload in X-PAYMENT header
  4. 4Middleware forwards to PayZap facilitator → EIP-712 verification → settlement enqueued
  5. 5Your handler runs. Stablecoin lands in your wallet. Receipt attached to req.x402Receipt

Framework support

ExpressreadyFastifysoonNext.jssoonHonosoonKoasoon

No dependency on PayZap types

The middleware is a standalone npm package with zero monorepo dependencies. Self-contained types, 6 KB gzipped. Works with any Express-compatible server.

Networks

Multi-chain from day one

Base
eip155:8453gas <$0.001
Arbitrum
eip155:42161gas <$0.01
Polygon
eip155:137gas <$0.01
TACTelegram access
eip155:2390gas <$0.001
Base Sepoliatestnet
eip155:84532gas free

Stablecoins

ERC-3009 gasless transfers

U
USDCUSD Coin
ERC-3009
E
EURCEuro Coin
ERC-3009
P
PYUSDPayPal USD
ERC-3009
D
DAIMakerDAO
ERC-2612

ERC-3009 allows the payer to sign a transfer authorization off-chain. The facilitator submits the transaction and pays gas. The payer never needs ETH or a wallet provider that supports transaction signing — only message signing.

Pricing

0.1% per settlement

No subscriptions, no monthly fees. You only pay when a payment settles on-chain. Minimum fee: $0.001 per transaction.

PaymentFeeMerchant receives
$0.01$0.001$0.009
$1.00$0.001$0.999
$10.00$0.01$9.99
$100.00$0.10$99.90

Gas fees covered by the facilitator. Included in the settlement fee.

Your API is already the product. Now let machines pay for it.

One npm package. One facilitator URL. Every AI agent with a wallet becomes a customer.