Skip to main content
A delegation is what lets an agent spend on your behalf without asking every time: a payment method plus a hard spending limit and an expiry. This flow enrolls a card once (the human enters card details in a browser — PCI requires it) and hands the agent a 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. $50 over 30 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

1

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 127.0.0.1 first:
The response carries a 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 nevermined CLI, can use the org-scoped POST {API_BASE}/widgets/session/self with { orgId, returnUrl } instead.)
2

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.
3

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.
paymentMethodId and delegationId arrive in the callback query string. Don’t log the request line, and keep secrets in a secret store, not on disk in the clear.
4

(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.
5

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.

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.