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

🛡️ Security & Authentication

TunnelSats provides two primary ways to authenticate your requests. Understanding which one to use depends on whether you are building a centralized service or a privacy-first Nostr integration.

🔑 1. API Keys (Bearer Token)#

API Keys are the simplest way to authenticate and are recommended for most backend integrators.
Format: sk_live_[random_string]
Header: Authorization: Bearer sk_live_...

Best Practices#

Never expose your API key in client-side code (Frontend).
Store keys in environment variables (.env.local).
Rotate your keys immediately if you suspect a leak.

💜 2. Nostr Auth (NIP-98)#

For users who want to stay anonymous or integrate directly with the Nostr ecosystem, we support NIP-98 (HTTP Authentication for Nostr).

How it works#

1.
Create a "Kind 27235" event.
2.
Sign it with your Nostr Private Key (nsec).
3.
Base64-encode the signed event JSON.
4.
Pass it in the header as: Authorization: Nostr [base64_encoded_event]

Generation Script (Bash + nostr-tool)#


🔒 3. Rate Limiting Strategy#

Our API uses a two-layer rate-limiting system to protect the network.

Layer 1: Cloudflare WAF (Burst Limiter)#

A blanket rule across all /api/public/* paths:
Limit: 10 requests per 10 seconds per IP
Action: Block (with 10s mitigation timeout)
Purpose: Prevents rapid bursts and DDoS attacks

Layer 2: Application Rate Limits (Per-Endpoint)#

Each endpoint has its own limit enforced at the application layer:
EndpointLimitPer
GET /servers60/minIP
POST /create10/minIP
POST /claim10/minIP
GET /{paymentHash}60/minIP
POST /status30/minIP
POST /renew20/minIP
POST /bandwidth-reset10/minIP
POST /{paymentHash}/sync5/minSubscription
GET /list30/minAccount
POST /ping/lookup5/minIP
POST /ping/test3/minIP

Handling 429 Responses#

When you receive an ERR_RATE_LIMIT_EXCEEDED (429), your application MUST implement exponential backoff:
Modified at 2026-09-02 07:46:17
Previous
⚡ Bandwidth Top-Up ($1 for +100GB)
Next
🎁 Referral Program: Earn Bonus Months
Built with