# Public URLs

Start a web app, API or dev server in the sandbox and open it from a browser or another service – each port gets its own HTTPS address protected by a token.

## Start the app and get its address

The app must listen on `0.0.0.0` (not only `127.0.0.1`) and keep running – start it in the background:

**Python**

```
sb.run("nohup python3 -m http.server 8000 >/tmp/srv.log 2>&1 &")
u = sb.get_url(8000)
print(u["url_with_token"])                       # open in a browser
```

**curl**

```
curl -s -X POST https://sandbox.wbx.cz/v1/sandboxes/SB_ID/exec -H "X-API-Key: $WBX_API_KEY" \
  -d '{"cmd": "nohup python3 -m http.server 8000 >/tmp/srv.log 2>&1 &"}'

curl -s "https://sandbox.wbx.cz/v1/sandboxes/SB_ID/url?port=8000" -H "X-API-Key: $WBX_API_KEY"
```

```
{
  "url": "https://8000-…/",
  "url_with_token": "https://8000-…/?wbx_token=…",
  "token": "…"
}
```

## The token

Every sandbox has its own token. Open `url_with_token` in a browser – the token moves to a cookie for that address and disappears from the URL. From code, call `url` with the header `X-WBX-Token: <token>`.

> **Share it carefully.** Anyone who has the token can use the app until the sandbox ends, so share it only with people who should.

## Details

- HTTP and WebSockets work; your app gets the client address in `X-Forwarded-For` and its own `Authorization` and cookies (cookies are limited to that one address).
- Addresses are available while the sandbox runs; a paused or ended sandbox returns an error page. A sleeping sandbox is not woken up by its URL (`409 sandbox_sleeping`).
- They work over IPv4 and IPv6, whatever IP version the sandbox itself uses.

Source: https://sandbox.wbx.cz/docs/sandboxes/urls
