Skip to main content
Customer wallets are prepaid balances that Monigo can debit at billing time (see Prepaid Billing) or that you can charge programmatically for any purpose. Every wallet operation is recorded with double-entry ledger entries for full auditability.

Core concepts


Creating a wallet

Use getOrCreate to ensure a wallet exists for a customer + currency pair. If one already exists, it is returned; otherwise a new wallet with zero balance is created.

Listing wallets

All wallets

The org is inferred from your API key.

Filter by customer

You can pass an optional customer_id query parameter to filter wallets:
Or use the dedicated customer wallets endpoint:

Getting a wallet

Fetching a single wallet also returns its virtual accounts.

Crediting a wallet

Credit adds funds to the wallet. Every credit creates two ledger entries (debit provider, credit wallet) and fires a customer.wallet.topped_up webhook.
Always provide an idempotency_key when crediting wallets. This prevents double-credits if the request is retried. Use a stable reference from your own system (payment ID, transfer reference, etc.).

Entry types for credits


Debiting a wallet

Debit removes funds from the wallet. Returns a 402 Payment Required error if the balance is insufficient.

Entry types for debits


Transaction history

List paginated ledger entries for a wallet.

Virtual accounts

Virtual accounts are dedicated bank accounts (via Paystack, Flutterwave, or Monnify) that automatically credit the wallet when a customer deposits funds. This enables self-service top-ups without requiring API calls from your backend.

Create a virtual account

List virtual accounts


Prepaid billing integration

Wallets are the foundation of Prepaid Billing. When a customer subscribes to a prepaid plan:
  1. Monigo auto-creates a wallet in the plan’s currency
  2. At period-end, Monigo debits the wallet atomically and creates a paid invoice
  3. If the balance is insufficient, the subscription is paused and a subscription.prepaid_balance_insufficient webhook fires
  4. When you credit the wallet and the balance covers the outstanding invoice, Monigo auto-resumes the subscription
This means you only need to handle wallet top-ups — Monigo takes care of billing, pausing, and resuming automatically.

Real-time billing

A plan with billing_mode: "realtime" debits the wallet in near-real-time (within ~5 seconds) as usage accrues, rather than once at the end of the period. It supports every pricing model (per_unit, tiered, volume, package, cap): as events arrive, Monigo recomputes the cumulative charge for the period and debits the wallet for the marginal difference.
  • Continuous metering — each new batch of usage triggers a reconcile that charges only the incremental amount, so the wallet always reflects what the customer owes so far.
  • Pause on empty — when the wallet can no longer cover the next marginal charge, the subscription is paused, metering stops, and a subscription.prepaid_balance_insufficient webhook fires.
  • Auto-resume on top-up — crediting the wallet reactivates the subscription, reconciles any usage that accrued while paused, and resumes metering automatically.
  • One paid summary invoice per period — at period-end Monigo emits a single paid invoice that itemizes the period’s usage per metric, with the total equal to what was already debited in real time. No additional debit happens at close — the invoice is purely a reporting artifact.
Realtime plans must be collection plans (a realtime payout plan is rejected). As with prepaid, you only need to handle wallet top-ups — metering, pausing, resuming, and the period-end invoice are all automatic.

Inline funding session

When a customer wants to top up their own wallet directly in your portal UI (without a server-side redirect), set "inline": true in the funding request. Monigo returns a WalletFundingSession containing only publishable credentials — no secret keys are ever exposed.
The provider webhook remains the source of truth for crediting the wallet. Do not credit the wallet client-side after the payment completes — Monigo handles that automatically when the provider sends its payment notification.

Request

Response — WalletFundingSession

Using the session in the browser

Pass the session fields directly to your provider’s inline SDK. Only the fields relevant to the active provider will be populated.
Only publishable keys are returned in the inline session. Secret keys live exclusively on the Monigo backend and are never forwarded to the portal.

Drop-in wallet widget (inline funding + live balance)

The <WalletWidget> component is a self-contained UI that shows the customer’s live balance and opens the configured payment provider’s inline checkout when they click Fund wallet. Drop it anywhere inside a <MonigoProvider> — no extra state management required.

Installation

Usage

Minting a portal token (server-side)

MonigoProvider expects the raw token string (PortalToken.token) — not the full object returned by the SDK. Mint it on the server so your secret API key is never exposed to the browser.
TypeScript (SvelteKit server load)
portalTokens.create() accepts a customer_external_id (the external_id you set when creating the customer) — not the internal Monigo UUID. The SDK infers the organisation from your API key.

Props

What the widget does

  • Live balance — polls /portal/wallets/{walletId} every pollIntervalMs milliseconds and formats the balance with Intl.NumberFormat.
  • Inline checkout — calls the portal funding endpoint to get a WalletFundingSession and launches Paystack, Stripe, Flutterwave, or Monnify inline. Only the relevant provider fields are populated (see Inline funding session).
  • Auto-refresh — after a successful payment, the widget immediately polls for the updated balance, so the customer sees the new total without a page reload.
  • Usage debits — as your backend debits the wallet for metered usage (via wallets.debit()), the polling loop picks up the reduced balance automatically.
Never credit the wallet client-side after a payment completes. The provider webhook is the source of truth — Monigo credits the wallet automatically when the provider sends its payment notification.

Full working example

See platform/samples/ai-agent-wallet for a complete SvelteKit app that mints a portal token on the server, renders the widget, and includes a form action that debits the wallet to simulate agent token usage.

Webhook events