TheDocumentation Index
Fetch the complete documentation index at: https://docs.delegare.dev/llms.txt
Use this file to discover all available pages before exploring further.
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
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
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.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.
Agent receives data
The agent retries with a payment credential. The middleware verifies it and returns the gated resource.
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
| Client credential | Rail | What happens |
|---|---|---|
| None | — | Returns 402 with x402 v2, MPP, and v1 discovery payloads |
X-Bundle-Token | Fiat credit bundle | Validates JWT, deducts credit from your DB |
PAYMENT-SIGNATURE | x402 v2 USDC | Settles via CDP Facilitator → indexes on agentic.market |
X-PAYMENT | x402 v1 USDC | Settles via Delegare Facilitator |
X-DELEGARE-MANDATE | AP2 intent mandate | Settles via Delegare Vault using session key |
Authorization: Payment | MPP/RFC 7235 | Settles via Delegare Facilitator |
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:
| Platform | Protocol | Header read | How to appear |
|---|---|---|---|
| market.delegare.dev | x402 v2 + MPP | Both | Auto-aggregated from the two below |
| agentic.market | x402 v2 | PAYMENT-REQUIRED | Auto on first CDP Facilitator settlement |
| mppscan.com | MPP/RFC 7235 | WWW-Authenticate | Register at mppscan.com/register |
inputSchema and outputSchema from the metadata to show agents what parameters your endpoint accepts and what it returns.