INSPIRATION:
AI agents already do real work, but they can't borrow. An agent that finishes a \$400 job but needs \$10 now to deliver it has one option: a human's credit card. So we built the lender agents don't have.
WHAT IT DOES:
Mandate is a sandbox bank for AI agents, and every \$ moves on PayPal.
- Borrow: \$10-\$500 against a client invoice, paid out via PayPal Payouts.
- Lend: Agents fund loans via PayPal checkout and earn 80% of the fees.
- Repay: The client pays a PayPal link, webhooks fire, and the loan settles itself.
- Any agent: Claude Code, Codex, Cursor, Gemini, Copilot. Every op is a tool over MCP, REST and OpenAPI, and each reply says what to do next.
- Human control: The owner verifies with PayPal and signs a mandate capping the loan size, total owed, fee and term.
- Rules decide, AI explains: A deterministic score gives grades A-E, priced as
$$\text{fee} = P\,(r_{\text{funds}} + \text{EL} + c_{\text{ops}} + c_{\text{cap}})$$
e.g. \$10 for 7 days at grade D costs \$0.58, of which lenders get \$0.46 and the bank \$0.12.
- Collections: A late fee, then a penalty, a freeze and a charge-off. Losses are split pro-rata, $\text{loss}_i = L \cdot n_i / \sum_j n_j$, and the human gets a PayPal guarantee link.
- Risk desk: Elastic ES|QL fraud detectors, Jina semantic search and AI case files.
HOW WE BUILT IT:
- Stack: Next.js 16, TypeScript, Postgres, Drizzle and a double-entry ledger, on Render.
- PayPal: Orders v2, Payouts, webhooks and Verify-with-PayPal. Request IDs give exactly-once effects, and there are never PayPal calls inside DB transactions.
- Sponsor tools:
- APIMatic: Its PayPal context plugin led to 5 real fixes, and it generated our SDKs.
- Elastic + Jina: The risk desk.
- Bryntum: The repayment timeline.
- Postman: A public collection.
- Kernel: Cloud browsers for agent tests.
- AG Grid: The console's tables.
- Render: Hosting, with auto-deploys.
- Tests: About 1.1K unit and integration tests, E2E against the real PayPal sandbox, and real Claude Code agents running the full loop.
CHALLENGES WE RAN INTO:
- Exactly-once money: Webhooks, crons and agents all race each other. Reviews caught a double-redemption race and payouts mis-booked as failed, and we fixed and tested each one.
- Keeping the LLM out of decisions: A test feeds it prompt injections and checks that the decision stays the same.
- Sandbox quirks: Payouts to unconfirmed emails went UNCLAIMED, so we pay to PayPal account IDs instead.
ACCOMPLISHMENTS THAT WE'RE PROUD OF:
Real Claude agents given only a URL opened accounts, got claimed by their human, borrowed, and repaid on the PayPal sandbox. The ledger balanced to \$0 every time.
WHAT WE LEARNED:
Credit for agents is classic lending discipline plus one new rule: every response must tell the agent what to do next. AI belongs in explaining decisions, not making them.
WHAT'S NEXT FOR MANDATE:
Real-money pilots with a licensed partner, agent-to-agent invoice factoring, and mobile approvals for mandate changes. Huzaifa previously built AI for micro-lending at easypaisa digital bank, one of Pakistan's leading digital banks. Mandate brings that playbook to AI agents, launching first with capped loans in a regulatory sandbox.
Built With
- ag-grid
- apimatic
- bryntum
- claude-code
- drizzle-orm
- elastic
- esql
- jina-ai
- kernel
- mcp
- neon
- next.js
- node.js
- openai
- openapi
- paypal
- paypal-orders-v2
- paypal-payouts
- paypal-webhooks
- playwright
- postgresql
- postman
- react
- render
- typescript