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
  • šŸ”§ Tools
    • Lightning Node Network Address Discovery
      POST
    • Universal Connectivity Probe
      POST
  • 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

šŸ› ļø 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.

šŸ’” 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-04-13 06:11:52
Previous
How TunnelSats Leverages Public APIs for Confined VPN Management
Next
🐚 Bash One-Liners
Built with