1. Cookbook
TunnelSats Public Wireguard API
  • About our team
  • 📢 Public
    • List available VPN servers
      GET
    • Create a new VPN subscription
      POST
    • Claim a WireGuard configuration after payment
      POST
    • Check subscription status via payment hash
      GET
    • Renew an existing VPN subscription
      POST
    • Get Subscription Status
      POST
  • 🔐 Authenticated
    • Sync Subscription
      POST
    • Create Referral Code
      POST
    • Referral History
      GET
    • List all active/paid subscriptions for the account
      GET
  • Announcements
    • 💫 What is TunnelSats?
    • 🚀 Introducing the TunnelSats Public API v1
    • How TunnelSats Leverages Public APIs for Confined VPN Management
  • Cookbook
    • 🛠️ Automation & Code Examples
    • 🐚 Bash One-Liners
    • 🛑 Error Codes & Troubleshooting
    • 🎁 Referral Program: Earn Bonus Months
    • 🚑 Node Health & Upkeep
    • 🛡️ Security & Authentication
  • Schemas
    • Server
    • InvoiceOrder
    • SubscriptionStatus
    • WireGuardConfig
    • ReferralCode
    • ReferralHistory
    • NodeLookup
    • ConnectivityResult
    • RenewalOrder
    • ClaimResult
    • ApiError
    • SubscriptionListItem
  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 tiered rate-limiting system to protect the network.
Bearer Auth: Higher limits (linked to your account status).
NIP-98 Auth: Standard public limits.
Unauthenticated: Low limits (per IP).

Handling 429 Responses#

When you receive an ERR_RATE_LIMIT_EXCEEDED (429), your application MUST stop polling for at least the number of seconds specified in the Retry-After header.
Modified at 2026-04-12 13:23:50
Previous
🚑 Node Health & Upkeep
Next
Server
Built with