x402 protocol (an extension of the HTTP 402 Payment Required status) allows APIs to monetize individual endpoints by demanding a microtransaction before returning a resource.
While x402 is powerful for agent-to-agent (A2A) commerce, existing implementations have two critical gaps:
- The wallet popup — every time an agent hits a paywall, the human user must manually confirm a transaction.
- Invisible to agents — endpoints using the official
@x402packages don’t appear in any agent directory until a human manually registers them.
@delegare/x402 solves both. It combines x402 with Intent Mandates for set-and-forget payments, and simultaneously emits discovery headers that make your endpoint automatically appear on Delegare Market (which aggregates across protocols), agentic.market (CDP Bazaar), and mppscan.com.
How It Works
1
Agent requests data
The agent calls
POST /api/extract on the merchant’s server.2
Merchant returns 402 challenge
The middleware responds with
402 Payment Required containing three parallel discovery payloads:PAYMENT-REQUIREDheader (base64 JSON) — x402 v2, read by CDP Bazaar and@x402/fetchclientsWWW-Authenticate: Payment ...header — MPP/RFC 7235, read by MPPScan and MPP-compatible wallets- JSON body — x402 v1, backward-compatible with older clients
3
SDK auto-pays via Delegare
@delegare/sdk intercepts the 402, verifies the amount is within the agent’s budget, and forwards the intent mandate to Delegare’s settlement infrastructure.4
Settlement on Base
Delegare settles on Base L2 via the mandate’s session key and the DelegareRouter contract. USDC arrives directly in the merchant’s wallet. No popups.
5
Agent receives data
The agent retries with a payment credential. The middleware verifies it and returns the gated resource.
6
CDP Bazaar indexes the endpoint
On the first settlement via the CDP Facilitator (
PAYMENT-SIGNATURE credential), CDP writes a catalog entry. The endpoint appears on agentic.market within ~10 minutes.For Merchants: Monetizing APIs
Basic setup
Adding agent discovery
UsedeclareDiscoveryExtension before requireX402Payment to make your endpoint searchable on Delegare Market, agentic.market, and mppscan.com:
What the middleware handles
You never touch private keys or on-chain logic. USDC arrives directly in your wallet from the Base blockchain.
Required env vars for Bazaar indexing
Configuration reference
Accessing payment context
For Agents: Seamlessly Paying Paywalls
Replace standardfetch calls with delegare.fetch. When the API returns a 402, the SDK resolves it automatically using the user’s intent mandate.
How the SDK resolves x402
- Makes the initial request.
- On
402, sends the intent mandate viaX-DELEGARE-MANDATE. - Merchant middleware forwards to Delegare for settlement.
- Delegare settles on-chain via the mandate’s KMS-encrypted session key.
- SDK returns the final response with the gated data.
x402 v2 clients (@x402/fetch)
Agents using Coinbase’s @x402/fetch client send a PAYMENT-SIGNATURE credential. The middleware routes this to the CDP Facilitator, which also triggers Bazaar indexing on first settlement.
Model Context Protocol (MCP)
If your agent runs on MCP (Claude, ChatGPT, or any MCP-compatible client), thedelegare_fetch tool handles x402 automatically:
Discovery: How Agents Find Your API
declareDiscoveryExtension embeds metadata in every 402 response. Three directories index it:
Delegare Market is the primary destination — it aggregates x402 and MPP endpoints from both upstream sources. Agents using the Delegare SDK or searching via Claude/ChatGPT tools query it in one request.
All three read
inputSchema and outputSchema from the metadata to show agents what parameters your endpoint accepts and what it returns.