Payments
How a Mailgent agent pays for paid HTTP endpoints and MCP tools in USDC on Base
Mailgent gives every project a wallet so your agent can pay for things — paid search APIs, paid MCP tools, anything that responds with HTTP 402. The agent hands Mailgent a URL; Mailgent runs the x402 handshake, settles USDC on Base, and returns the result. No API key juggling, no monthly subscriptions, no "talk to sales."
Why per-call payments?
AI agents now hit more services than humans do. They search, book, pull data, post on your behalf. More and more of those services price per request in USDC instead of gating behind a signup form and a credit card. Mailgent lets your agent pay them automatically — a few cents per call, billed in real time — without ever holding a private key.
How it works
- Your agent calls
mailgent.payments.pay({ url }). - Mailgent fetches the URL, reads the
HTTP 402challenge (the price and where to pay). - Mailgent checks the price against your mandate (per-call + daily caps).
- If it's within caps, Mailgent signs an EIP-3009 USDC transfer authorization on your project's smart account, retries the request with the
X-Paymentheader, and the endpoint returns its result. - You get back
{ ok, content, txHash, cost }.
Mailgent handles the money flow, settlement, and bookkeeping behind the scenes. See the Pay for tools guide.
Mandates — the spend policy
A mandate is the wallet's spend policy: maxPerCallUsdc and dailyCapUsdc. Mailgent enforces it server-side on every pay() call, so a runaway loop can't drain the wallet. The agent never holds a signing key; the mandate is the spend policy, and the chain is the source of truth.
Set one once (installing the on-chain session key takes 10–30s), then reuse it forever. Full reference: payments.mandates.
What you'll see in the dashboard
Every payment shows up in console.mailgent.dev → your project → Pay:
- Who you paid
- How much
- Which resource
- When
- Status (settled or failed)
- A clickable link to the on-chain transaction
Your wallet balance updates within seconds.
The currency
Payments are made in USDC — a digital dollar. One USDC always equals one US dollar, backed by Circle. It runs on a fast, low-fee network called Base.
Why this and not credit cards?
- Per-call works at any size. A tenth of a cent is fine. Card networks take a 30¢ minimum.
- No credit checks. Agents don't have credit scores. They have wallets.
- Funds settle in seconds, not days.
You don't need to know anything about crypto to use it — Mailgent handles wallet creation, signatures, and on-chain transfers. You just see a USD balance.
Where the proof lives
You don't need to store anything yourself. Every successful payment leaves three independent records:
- In the response —
txHash,cost,recipient,resource, plus how much is left in the daily cap. - On Base —
txHashis the on-chain USDC transfer. Anyone with the hash can verify amount, payer, and recipient on a block explorer. The chain is the canonical record. - In Mailgent —
mailgent.payments.activity()returns your project's full spend history as a bank-statement-style list, latest first.
Setup at a glance
- Open console.mailgent.dev → your project and toggle Settings → Pay → Spend on.
- Set per-call and daily caps (your mandate).
- Top up the wallet with a few dollars of USDC.
- Call
mailgent.payments.pay({ url }).
Common questions
Do I need to know anything about crypto? No. You set caps in dollars. Mailgent does the rest.
Can a runaway agent drain my wallet? No — the mandate caps every call and every day, enforced server-side.
Is this live for everyone? Payments is in beta. Each Mailgent instance has a feature toggle (Admin → Settings → Payments) that workspace owners flip when ready.
Want to accept x402 payments on your own endpoints / sell to agents? That's a separate product at loomal.ai.