API ReferenceWooCommerceSDKssoonWebhookssoon

Wallet

Connect a wallet

POST/api/v2/wallet/connect

Store an NWC credential the merchant just approved. Trevi verifies it against the live wallet before trusting it, so a credential that cannot actually issue invoices is refused at onboarding rather than mid-sale.

  • Dashboard-only (merchant JWT). Rate limited to 10 attempts per 5 minutes.
  • SECURITY: nwc_url is a bearer secret — anyone holding it can instruct the wallet up to the approved limit. Never log it, never put it in a query string, and do not paste a live credential into this page's Try-it form. Trevi stores it encrypted and never echoes it back; no response on this page ever contains it.
  • Any NWC-compatible wallet works — Alby Hub, Coinos, LNbits, Primal, Blink, Zeus, or a self-hosted node. Pasting the connection string is the wallet-agnostic path; the approval popup is a convenience for wallets that offer one.
  • 400 code: "missing_scopes" — the connection did not grant the four core methods Trevi must have. Reconnect and approve them.
  • 400 code: "invalid_credential" — the string is not a usable NWC URL.
  • 502 code: "unreachable" / "not_discoverable" — the wallet did not answer. Nothing was stored.
  • budget_readable: false means the wallet declined to report a limit — not that there is no limit. Trevi falls back to bounding cover by balance alone; the wallet still enforces its own limit.

Authentication

Requires a dashboard session JWT in the Authorization: Bearer … header.

Body parameters

nwc_urlstringrequired

a nostr+walletconnect://… connection string

POST/api/v2/wallet/connect
curl --request POST "https://api.trevi.cash/api/v2/wallet/connect" \
  --header "Content-Type: application/json" \
  --header "Authorization: Bearer $TREVI_JWT" \
  --data '{ "nwc_url": "nostr+walletconnect://<pubkey>?relay=…&secret=…" }'
200Sample response
{
  "success": true,
  "connection": {
    "wallet_pubkey": "9a1c…",
    "granted_methods": [
      "make_invoice",
      "pay_invoice",
      "get_balance",
      "lookup_invoice",
      "get_budget"
    ],
    "granted_notifications": [
      "payment_received"
    ],
    "budget_unlimited": false,
    "budget_readable": true,
    "budget_total_sats": 100000,
    "budget_renewal_period": "daily",
    "polling_fallback": false
  }
}