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

šŸ› ļø Automation & Code Examples

This guide provides production-ready scripts to purchase, pay for, and provision a VPN tunnel programmatically using TunnelSats.

⚔ Quick Start Scripts#

Choose your preferred environment to automate the VPN lifecycle.
Python (Requests)
Bash (cURL + jq)
Recommended for Integrators
Use this script if you are building a dashboard, an auto-renewal bot, or integrating TunnelSats into node management software.

Prerequisites#

The "Full Lifecycle" Script#

This script automates the Create -> Pay -> Claim flow and handles the current "Production Reality" of dual-key configurations.

⚔ Bandwidth Top-Up Flow#

For dedicated documentation on automated bandwidth resets, threshold validation, and payment settlement, see ⚔ Bandwidth Top-Up.

šŸ’” Important Considerations#

Invoice Expiry
Lightning invoices and their associated paymentHash typically expire within 10 minutes. If payment is not detected within this window, the polling script will timeout, and you must generate a new subscription request.
WireGuard Keys
In the examples above, we leave wgPublicKey empty in the /claim request. This tells the TunnelSats server to generate a fresh keypair for you. If you prefer to use your own keys, include your Public Key (Base64) in the request body.
Case Sensitivity Reality
Status/Create/Renew: Use camelCase (e.g., paymentHash, subscriptionEnd).
Subscription List: Uses snake_case (e.g., payment_hash, subscription_end).
Always verify your JSON keys against the endpoint documentation.
Modified atĀ 2026-08-31 20:25:04
Previous
šŸ›”ļø Security & Authentication
Next
⚔ Bandwidth Top-Up ($1 for +100GB)
Built with