TunnelSats Public Wireguard API
    Cookbook
    • Announcements
    • 📡 Discovery
    • ⚡ Purchase
    • 🔄 Lifecycle
    • 🔑 Account
    • 🔧 Tools
    • 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
    Tunnelsats Github
    Tunnelsats Telegram

    🛡️ 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