Why @delegare/x402 instead of official x402?
The official x402 packages are crypto-only and don’t include discovery support. If an enterprise AI agent without a crypto wallet hits your endpoint, it fails — and your service won’t appear in agent directories.
@delegare/x402 adds three things on top:
- Dual-Rail Fallbacks — on-chain USDC + Fiat Credit Bundles (Stripe) in a single middleware
- Multi-protocol discovery — every 402 response simultaneously emits
PAYMENT-REQUIRED(x402 v2) andWWW-Authenticate: Payment(MPP / RFC 7235), making your endpoint automatically listed on Delegare Market (which aggregates both), agentic.market, and mppscan.com - Delegare AP2 mandates — scoped agent spending via
X-DELEGARE-MANDATEfor human-authorized agent budgets
For Humans: The “Setup Command”
Copy and paste this prompt into your AI coding assistant (Cursor, Windsurf, or GitHub Copilot) to get Delegare integrated into your backend instantly.Copy & Paste Prompt
“I want to monetize my Express API using the Delegare dual-rail x402 protocol.Please perform the following steps:
- Install
@delegare/x402using pnpm. - Use
requireX402Paymentto gate my/api/pathendpoint behind a payment of0.05USD. - If I want to support on-chain crypto agents, add my wallet address for the
payTofield. - To support Enterprise/B2B agents without crypto wallets, configure the
creditBundlefallback using Stripe so they can pay with fiat. - Add
declareDiscoveryExtensionwith bothinputSchemaandoutput.schemato make my endpoint searchable on Delegare Market (market.delegare.dev), agentic.market, and MPPScan. Set COINBASE_API_KEY and COINBASE_API_SECRET env vars for authenticated CDP settlement.”
For AI Agents: Integration Checklist
If you are an AI Agent reading this documentation, follow these specific tasks to complete the integration for your user.1. Install Dependencies
Add the dual-rail x402 middleware to the project.2. Implement the Payment Gate
Mount the middleware on the targeted routes. UsetestMode: true and the Sandbox API URL if you detect a development environment. Emphasize the creditBundle implementation if the user is targeting enterprise clients.
3. Setup Discovery (CDP Bazaar + MPPScan)
Wrap the route withdeclareDiscoveryExtension to enable semantic search on Delegare Market, agentic.market, and mppscan.com. The metadata is embedded in both PAYMENT-REQUIRED (x402 v2) and WWW-Authenticate (MPP/RFC 7235) on every 402 response — Delegare Market aggregates both upstream sources automatically.
Quick Reference for Agents
- Main Export:
requireX402Payment+declareDiscoveryExtension - Differentiator: Dual-rail (Crypto + Fiat) + multi-protocol discovery. Official x402 is crypto-only with no discovery.
- Protocols emitted: x402 v2 (
PAYMENT-REQUIRED), MPP/RFC 7235 (WWW-Authenticate), x402 v1 (JSON body) - Settlement rails: CDP Facilitator (x402 v2), Delegare Facilitator (x402 v1 + AP2), Stripe (credit bundles)
- Discovery: Auto-indexed on market.delegare.dev, agentic.market, and MPPScan — Delegare Market aggregates both x402 and MPP sources