Inspiration
AI agents are starting to pay for things. Today the choice is to give an agent a payment credential and hope, or not to let it pay at all. A prompt-injected agent can spend real money, and afterwards nobody can prove what the user actually agreed to — not the user, not the merchant, not PayPal in a dispute. Google's AP2 and Mastercard's Verifiable Intent describe signed user intent for agent payments. We wanted that idea working end to end on PayPal now, with the enforcement and the evidence, not just the format.
What it does
AgentGuard is a spend gateway between an AI agent and PayPal.
- The user signs a mandate with a passkey. Allowed payees, SKUs and categories, per-payment cap, total budget, number of payments, time window, and an amount above which the user must approve. An LLM can draft it from plain language; nothing is active until the user passkey-signs the exact rules.
- The agent can only propose a PayPal order ID. AgentGuard reads payee, amount and items from PayPal's Orders API, not from the agent, and a deterministic policy engine checks them against the signed mandate. AI risk scoring can only escalate a payment to a human, never approve one.
- Held payments need the user's passkey. The approval is bound to that exact payment and single-use; the admin token alone is refused.
- Reserve → authorize → re-verify → capture, or void on any mismatch or revocation, with idempotency, rate limits, crash recovery and a kill-switch.
- Every capture gets a Proof-of-Intent receipt: signed, independently timestamped (RFC 3161), included in a published Merkle-anchored audit log, linked to the PayPal capture via
invoice_id = AGPOI-<receipt_id>, and expressed as AP2 mandates. - Merchants verify receipts offline with
@agentguard-dev/intent-verifier(zero dependencies) and turn them into PayPal dispute evidence with one command. - Agent builders wrap PayPal's Agent Toolkit (Vercel AI SDK, OpenAI, MCP) with
@agentguard-dev/paypal-toolkitso money only moves through AgentGuard.
How we built it
- TypeScript on Node 22; PayPal Orders v2 (authorize-then-capture against a vaulted wallet), Disputes API for evidence.
- WebAuthn passkeys for mandate signing, approvals, revocation and time-locked recovery; Ed25519 issuer keys with rotation and compromise handling, published at
/.well-known/agentguard-keys. - RFC 3161 timestamps (FreeTSA, Sectigo); Merkle anchoring of the audit log every 15 minutes.
- Supabase Postgres (row-level security, append-only audit, pg_cron jobs) and Vercel; SQLite for local dev.
- PayPal Agent Toolkit, Vercel AI SDK 5, OpenAI and MCP (tools carry read-only/destructive/idempotent annotations); LLM for mandate drafting and advisory risk only.
Open-source packages published from GitHub Actions with npm provenance.
Sponsor tools: AG Grid Community for the console's payment, receipt and audit tables; Channel3 for real product discovery within the mandate; APIMatic for TypeScript, Python and C# SDKs and the API portal.
Sponsor tools
- AG Grid (Community): the owner console's Payments, Receipts and Audit ledger are AG Grid tables in the AgentGuard theme. The console re-verifies every receipt in the browser (issuer signature, passkey over the mandate, order digest) and recomputes every audit-log hash link. Each grid has filtering by status, payee, amount, mandate and PayPal ids, a quick filter, a row detail drawer and CSV export for dispute evidence.
- Channel3: agents find real products through Channel3's product search (search_products MCP tool / API). Results are capped at the mandate's currency and remaining budget, and each one shows whether it fits the mandate or needs the user's approval. Channel3 is only for discovery: payment still goes through a PayPal order that AgentGuard reads from PayPal and checks. For Channel3 items, the cheapest market offer is a reference price, so an overpriced order is held for the user's passkey. That check can never approve a payment.
- APIMatic: from our OpenAPI 3.1 spec, APIMatic generated TypeScript, Python and C# SDKs (committed in apimatic/sdk/) and a branded API portal, live at https://agentguard-api-portal.vercel.app. The portal has an interactive API reference, code samples in four languages, SDK downloads and a context plugin for AI coding assistants. The TypeScript and Python SDKs were smoke-tested against the live API.
Challenges we ran into
- Making the agent unable to lie about what it's buying: we switched to PayPal's order as the only source of truth and reject agent-declared payees or items alongside an order ID.
- Concurrency: reserving budget atomically so parallel proposals can't double-spend (write locks on SQLite and Postgres advisory locks).
- Making "the admin can't spend" true, not just stated: mandates and approvals verify the user's passkey signature on every step, and passkey replacement goes through a 72-hour time lock the current passkey can cancel.
- PayPal disputes only accept the evidence type they requested, so the CLI reads the dispute and picks the type automatically.
Accomplishments that we're proud of
- Real PayPal dispute proof: a receipt submitted as seller evidence on sandbox dispute
PP-R-QXA-10194904was accepted by PayPal asPROOF_OF_FULFILLMENT, and the case moved toUNDER_REVIEW. (No dispute outcome is claimed.) - Tested: 87 gateway tests (threat model, receipts, AP2, anchoring, passkeys, limits, security regressions), run on both SQLite and Postgres in CI, plus 7 toolkit tests; documented commands are executed in CI.
- Published:
@agentguard-dev/intent-verifierand@agentguard-dev/paypal-toolkit0.1.2 on npm with signed SLSA provenance; a fresh install verifies a production receipt as VALID. - Live product with docs (21 pages), OpenAPI spec, owner console, in-browser receipt verifier and brand kit.
What we learned
- The hard part of agent payments isn't the payment — it's proving afterwards who authorized what. Signed intent is only useful if the money path actually enforces it.
- Keep AI out of the decision path: let it draft and flag, and let deterministic code and the user's passkey decide.
What's next
- Pilot with a few agent builders and merchants on PayPal live.
- Interop testing with AP2 implementations; publishing anchors to outside witnesses.
- More rails behind the same mandate model.
Known limits
Honest limits: receipts prove authorization, not delivery; history before the first anchor is attested by the server alone; detecting a forked log needs outside copies of anchors; an admin who blocks recovery notifications and waits out the 72-hour lock can still take over (flagged, not prevented); demos use PayPal sandbox.
Built With
- ag-grid
- ap2
- apimatic
- channel3
- ed25519
- github-actions
- mcp
- merkle-trees
- node.js
- npm
- openai
- passkeys
- paypal
- paypal-agent-toolkit
- paypal-disputes-api
- paypal-orders-api
- postgresql
- rfc3161
- sqlite
- supabase
- typescript
- vercel
- vercel-ai-sdk
- webauthn