ZapAPI Docs
Get StartedConceptsAI GatewayGuidesPayment GatewaySDKAPI ReferenceResources
AI Gateway

Auto-topup (NWC)

Auto-refill AI credits from your Nostr-connected wallet when your balance runs low — with thresholds and daily caps.

Auto-topup keeps you from ever hitting a 402 mid-task. Connect an NWC (Nostr Wallet Connect) wallet once, set a threshold and limits, and the platform refills your AI credits automatically when the balance drops below it.

How it works

  1. You connect an NWC-compatible wallet (Alby Hub, LNBits NWC, Primal, Umbrel…) in Payments → Wallet, producing a connection with a scoped, revocable pay_invoice capability.
  2. You enable auto-topup with a threshold, a topup amount, and a daily cap.
  3. A sweep runs every ~15 minutes. If your AI balance is below the threshold, it creates a normal topup invoice and pays it from your NWC wallet — crediting your balance through the standard path (with the +5% Lightning bonus).

Configure it

Dashboard: AI → Billing → Auto-topup (NWC). Or the API:

Enable auto-topup
curl -X POST https://api.zapapi.com/api/v1/ai/auto-topup \
  -H "Authorization: Bearer zap_live_your_key" \
  -H "Content-Type: application/json" \
  -d '{
    "nwcConnectionId": "your-nwc-connection-uuid",
    "thresholdSats": 500,
    "topupSats": 5000,
    "dailyCapSats": 20000
  }'
SettingMeaning
nwcConnectionIdWhich of your NWC connections pays
thresholdSatsTrigger when balance falls below this (min 100)
topupSatsAmount to refill per trigger (min 100)
dailyCapSatsMax auto-spend per UTC day (must be ≥ topup amount)
Read settings / disable / remove
curl https://api.zapapi.com/api/v1/ai/auto-topup \
  -H "Authorization: Bearer zap_live_your_key"

curl -X POST https://api.zapapi.com/api/v1/ai/auto-topup/toggle \
  -H "Authorization: Bearer zap_live_your_key" \
  -H "Content-Type: application/json" \
  -d '{ "enabled": false }'

curl -X DELETE https://api.zapapi.com/api/v1/ai/auto-topup \
  -H "Authorization: Bearer zap_live_your_key"

Safety rails

  • Daily cap — hard ceiling on auto-spend per UTC day.
  • Cool-down — minimum interval between consecutive auto-topups per user, so a hovering balance can't fire invoices repeatedly.
  • Scoped secret — the NWC connection string is stored AES-encrypted and can only pay_invoice; revoke it in your wallet anytime to stop all auto-topups instantly.
  • Last error surfaced — if a payment fails (wallet offline, insufficient funds), the error is visible on the settings card.

Your wallet stays in control

The NWC standard means your wallet enforces its own budget too — most NWC wallets let you set a max per-payment or daily limit. Auto-topup can never exceed what your wallet allows.

On this page