Skip to main content
A box running a web app, a dev server, or an API is only useful once something outside can reach it. Ask the box for a tunnel to the port your server listens on, and the tunnel hands you a public URL.

Prerequisites

  • An API key from the console, exported as BOXLITE_API_KEY. See API keys.
  • pip install boxlite, and the REST URL exported as BOXLITE_REST_URL. See Quickstart.
  • A box you can start, and a service inside it that listens on a TCP port.
Every example reads both values from the environment, so nothing hard-codes a credential. This script creates a box, starts an HTTP server inside it, prints the tunnel’s public URL, makes a request over the tunnel, and removes the box in finally.
Expected output:
uri() returns the public URL of a tunnel served remotely, which is what a Cloud tunnel is. On a local runtime the same call returns None, because a local tunnel is already a live connection with no address to publish. Reading uri() leaves the tunnel usable — only connect() and forward() spend it. The snippet starts the server with python3. If the server log says python3: not found, install an interpreter into the box first, or start a service the image already ships.

Next steps

Network

How tunnels work, the full parameter reference, and the outbound boundary.

Network policy

Control what the box itself is allowed to reach.