$0.0001 to $5.00 per call) and get paid in real USD via PayPal by AI agents that pay automatically within spending policies their owners control.
Quickstart: Sell (5 min)
Gate any Hono or Express route behind HTTP 402 in 2 lines of middleware and receive PayPal Payouts.
Quickstart: Buy (5 min)
Fund a prepaid wallet via PayPal Orders v2, issue a policy-capped agent key, and call paid APIs with
createHaggles.Double-Entry Ledger
Explore how integer micro-dollars (
$1.00 = 1,000,000 micros) and 6 ledger account kinds guarantee zero drift.Wire Protocol & Test Vectors
Inspect the
WWW-Authenticate: Haggles, Haggles-Challenge, Haggles-Payment, and Haggles-Receipt headers.End-to-End Architecture & Protocol Flow
Why HTTP 402 + Prepaid PayPal Rails?
- Two-Line Seller Integration: Protect any Hono or Express route with
@haggles/server. Unpaid callers receive a standard402 Payment Requiredresponse with a machine-readableHaggles-Challenge. - Zero-Prompt Agent Payments:
@haggles/clientwrapsfetch, verifies the challenge against the caller’s client-side ceiling (maxPricePerCall), obtains a short-lived Ed25519 JWS payment token (hgp_...), and retries once. - Hard Server-Side Guardrails: Every agent key (
hgk_test_...) enforces per-call, daily, and monthly USD caps, plus optional seller and hostname allowlists, inside the same serializable database transaction that locks wallet funds. - Real PayPal Settlement: Buyers fund wallets via PayPal Orders v2, and sellers receive earnings via PayPal Payouts v1 (or on-demand in the Seller Studio). See Assumptions & Limitations for the full economic and regulatory design notes.