delegationId it reuses until the budget is spent or the delegation expires.
Useful for
- Giving an agent a card to pay with when a plan is fiat (Stripe / Braintree / Visa) rather than stablecoin.
- Putting a hard cap on what an agent can spend (e.g.
$50over30 days) — the platform enforces it. - Doing the human part once: after enrollment, every purchase is programmatic and reuses the same delegation.
Paying with stablecoins needs no card and no human enrollment — your account’s ERC‑4337 wallet is ready as soon as it’s funded. Use this flow only for card payments. See Buy access for the stablecoin path.
Try it yourself
Hand this to your agent. It drives the embedded enrollment handshake, gives you a single URL to open, and captures the result automatically:This points at Sandbox, so card entry uses test cards and no real money moves. Use a
live: API key to run it for real.How it works
Mint an embedded session
With your API key, mint a session bound to a localhost return URL — so run a tiny one-shot callback server on The response carries a
127.0.0.1 first:sessionToken. This open endpoint needs no organization — it’s the autonomous-agent path, and the card attaches to your own account. (Org members, e.g. the nvm CLI, can use the org-scoped POST {API_BASE}/widgets/session/self with { orgId, returnUrl } instead.)Hand the human a card-setup URL
The human opens this once in their browser and enters the card:Generate
state as an unguessable nonce. Use provider=stripe (or braintree / visa) to match the card type the target plan accepts.Receive the delegation
When the human finishes, the browser redirects to your
returnUrl with paymentMethodId and delegationId. Verify the returned state matches the one you sent (CSRF guard), then store the delegationId — that’s what you pass at purchase time.(Optional) Re-budget an enrolled card
Already enrolled and just need a fresh budget? Create another delegation directly — no browser needed:
provider, currency, spendingLimitCents, and durationSecs are all required — there is no silent default for provider or currency. The response carries a new delegationId. The delegation is plan-agnostic unless you pass a planId.Visa is the exception:
provider: "visa" needs a browser-produced consumerPrompt + assuranceData from a WebAuthn ceremony, which an agent can’t generate — so create Visa delegations in the app and reuse the delegationId.Reuse it to pay
Pass the stored
delegationId whenever you buy — see Buy access. One delegation covers many purchases until its budget is spent or it expires.Related
Buy access
Use the delegation to buy plan credits with x402.
Card Delegation
The full embedded handshake, widget embedding, and
state/CSRF rules.Card Enrollment
Provider-specific enrollment (Stripe, Braintree, Visa).
Check credits
Inspect delegation budgets and remaining credits.