1. Cookbook
TunnelSats Public Wireguard API
  • About our team
  • 📢 Public
    • List Available WireGuard Servers & Regions
      GET
    • Create a New WireGuard Subscription (Invoice Generation)
      POST
    • Claim WireGuard Configuration After Payment Settlement
      POST
    • Check subscription status via payment hash
      GET
    • Renew an Existing VPN Subscription (Anonymous)
      POST
    • Get Subscription & Bandwidth Status by WireGuard Public Key
      POST
    • Request Bandwidth Top-Up ($1 for +100GB)
      POST
  • 🔐 Authenticated
    • List Account Subscriptions (Authenticated)
      GET
    • Sync Subscription
      POST
    • Create Referral Code
      POST
    • Referral History
      GET
  • 🔧 Tools
    • Lightning Node Network Address Discovery
      POST
    • Universal Connectivity & Latency Probe
      POST
  • Announcements
    • 💫 What is TunnelSats?
    • 🚀 Introducing the TunnelSats Public API v1
    • How TunnelSats Leverages Public APIs for Confined VPN Management
  • Cookbook
    • 🛑 Error Codes & Troubleshooting
    • 🎁 Referral Program: Earn Bonus Months
    • 🚑 Node Health & Upkeep
    • 🛡️ Security & Authentication
    • 🛠️ Automation & Code Examples
    • ⚡ Bandwidth Top-Up ($1 for +100GB)
    • 🐚 Bash One-Liners
  • Schemas
    • Server
    • InvoiceOrder
    • SubscriptionStatus
    • WireGuardConfig
    • ReferralCode
    • ReferralHistory
    • NodeLookup
    • ConnectivityResult
    • ApiError
    • RenewalOrder
    • BandwidthResetResponse
    • PublicKeyStatusResponse
    • ClaimResult
    • SubscriptionListItem
  1. Cookbook

⚡ Bandwidth Top-Up ($1 for +100GB)

This guide provides complete instructions and production-ready code examples to programmatically purchase and trigger an instant bandwidth reset (+100GB allowance) for your active WireGuard tunnel.

🎯 Overview#

Each TunnelSats subscription includes 100 GB of high-speed bandwidth. When your node exceeds 70% bandwidth utilization (or runs out entirely and gets disabled), you can purchase a $1 USD Bandwidth Top-Up in Bitcoin Lightning (sats) without waiting for your monthly subscription renewal.
Node management packages (e.g., RaspiBlitz, Umbrel, Start9, Baremetal, LNDg) and automation daemons can monitor usage via /api/public/v1/subscription/status and automatically top up bandwidth when thresholds are reached.

📡 Endpoint Specification#

POST /api/public/v1/subscription/bandwidth-reset#

Authentication: None (Anonymous / Public API)
Rate Limit: 10 requests / minute per IP

Request Headers#

Request Payload#

{
  "wgPublicKey": "pWyZTQx8C4gzzgMVJHiN1ptI46wDtyJSMRa+wxtkXOM=",
  "serverId": "us-east"
}
FieldTypeRequiredDescription
wgPublicKeystringYes44-character Base64 WireGuard public key of your node.
serverIdstringYesServer identifier, group domain (eu-de, us-east), or domain (us3.tunnelsats.com).

Response (200 OK)#

{
  "invoice": "lnbc30000n1p...",
  "paymentHash": "a1b2c3d4e5f6...",
  "resetId": "d7b2277f-5990-4721-a565-6816babadc59",
  "amountSats": 3000,
  "amountUsd": "1.00",
  "currentUsagePercent": "85.4",
  "resetsThisMonth": 0,
  "maxResetsPerMonth": 2
}
FieldTypeDescription
invoicestringBOLT11 Lightning invoice for $1 USD equivalent in sats.
paymentHashstringSHA256 payment hash for tracking invoice settlement.
resetIdstringUnique UUID tracking this bandwidth reset request.
amountSatsnumberInvoice amount in satoshis calculated dynamically from real-time BTC price.
amountUsdstringFixed price ("1.00").
currentUsagePercentstringCurrent bandwidth consumption percentage on the VPN manager.
resetsThisMonthnumberNumber of confirmed resets applied to this key in the current calendar month.
maxResetsPerMonthnumberMaximum allowed resets per month (2).

🛑 Business Rules & Validation#

RuleConstraintError CodeHTTP Status
Usage ThresholdMust exceed 70% bandwidth usage (BANDWIDTH_WARNING_THRESHOLD_PERCENT)ERR_INVALID_INPUT400
Active SubscriptionSubscription must not be expiredERR_INVALID_INPUT400
Monthly LimitMaximum 2 confirmed resets per calendar month per keyERR_RATE_LIMIT_EXCEEDED429
Server & KeyKey must exist on target serverERR_RESOURCE_NOT_FOUND404
Public Key FormatMust be a valid 44-character Base64 stringERR_INVALID_INPUT400

⚡ Settlement & Auto-Reenablement#

Once the Lightning invoice is settled:
1.
LNBits Webhook fires automatically to /api/webhooks/bandwidth-reset.
2.
The backend contacts the respective WireGuard server manager and resets the bandwidth counter (bwReset: true).
3.
If the peer key was disabled due to bandwidth exhaustion, it is automatically re-enabled immediately.

💻 Code Examples#

Bash (cURL + jq + lncli)
Python (Requests)
Prerequisites
Requires curl, jq, and an active Lightning CLI (e.g. lncli, cln, alby-cli, or WebLN).
Modified at 2026-08-31 20:24:41
Previous
🛠️ Automation & Code Examples
Next
🐚 Bash One-Liners
Built with