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.
@delegare/x402 package lets merchants monetize API endpoints using the x402 protocol while crucially implementing Google’s AP2 (Agentic Payment Protocol). This guarantees secure, autonomous transactions where the AI agent never holds private keys, credit card credentials, or raw funds. Instead, agents operate strictly via pre-authorized intent mandates (SD-JWT-VC).
Beyond security, it handles the 402 challenge, payment verification, and settlement across multiple payment rails, and automatically embeds discovery metadata. This makes your endpoint seamlessly indexable on Delegare Market, agentic.market (CDP Bazaar), and mppscan.com (MPP) — one middleware, zero exposed credentials, three directories.
🔒 Secured by Google’s AP2 Protocol
Traditional agentic payments force developers to provision wallets with live funds or inject raw credit card details into the LLM context window—a massive security vulnerability.@delegare/x402 natively implements Google’s AP2 (Agentic Payment Protocol):
- No Keys in Context: Agents are issued an Intent Mandate (SD-JWT-VC) rather than returning raw card details or wallet seeds.
- Bounded Authority: Mandates define strict, server-side enforced spending limits and permitted rails.
- Zero-Trust Validation: The middleware cryptographically verifies the mandate before settling the payment on-chain or via fiat fallbacks.
Installation
Quick Start
Dual-Rail Payments (Fiat Fallback)
Not all agent developers have a crypto wallet. Configure a Credit Bundle Fallback to add a Stripe-backed fiat path alongside the crypto path.X-Bundle-Token to bypass crypto.
Agent Discovery (Delegare Market, CDP Bazaar + MPPScan)
UsedeclareDiscoveryExtension to make your endpoint automatically discoverable on Delegare Market, agentic.market, and mppscan.com. Place it before requireX402Payment.
The metadata is embedded in both the PAYMENT-REQUIRED header (x402 v2, read by CDP Bazaar) and the WWW-Authenticate header (MPP/RFC 7235, read by MPPScan) on every 402 response.
output.schema is required (not just example) for CDP Bazaar to accept the index entry. Without it, the validator will report “schema is invalid” even if all other checks pass.How Bazaar Indexing Works
CDP Bazaar indexes your endpoint the first time aPAYMENT-SIGNATURE credential is settled through their facilitator. The middleware handles this automatically:
- An agent hits your endpoint with
PAYMENT-SIGNATURE(x402 v2 credential from@x402/fetch) - The middleware passes the full payment payload — including your
declareDiscoveryExtensionmetadata — directly to CDP’s/settleendpoint - CDP settles on-chain and writes the catalog entry
- Your endpoint appears on agentic.market within ~10 minutes
@x402/fetch client with your own wallet to make one test payment per endpoint. See the CDP Bazaar docs for details.
Required Environment Variables for Bazaar
What the 402 Response Emits
Every unauthenticated request receives three parallel discovery headers:| Header | Protocol | Read by |
|---|---|---|
PAYMENT-REQUIRED | x402 v2 | Delegare Market, CDP Bazaar, agentic.market, @x402/fetch |
WWW-Authenticate: Payment ... | MPP / RFC 7235 | Delegare Market, MPPScan, MPP-compatible wallets |
BAZAAR-EXTENSION | Delegare debug | Custom clients |
Payment Rails (Priority Order)
The middleware accepts five types of payment credentials in this order:| Client header | Rail | Settlement |
|---|---|---|
X-Bundle-Token | Fiat credit bundle | Your backend (Stripe) |
PAYMENT-SIGNATURE | x402 v2 USDC | CDP Facilitator → Base |
X-PAYMENT | x402 v1 USDC | Delegare Facilitator → Base |
X-DELEGARE-MANDATE | AP2 intent mandate | Delegare Vault |
Authorization: Payment | MPP/RFC 7235 | Delegare Facilitator |
Configuration
Accessing Payment Context
Testing with Sandbox
Related
- x402 Payments (concept) — How x402 works end-to-end
- TypeScript SDK — Agent-side
delegare.fetch()for auto-paying 402s - MCP Tools —
delegare_fetchtool for LLM agents - CDP Bazaar — Coinbase discovery catalog
- MPPScan Discovery — MPP discovery spec