# How do I publish a web app?

Run a web server in a sandbox and put it on a permanent HTTPS address that anyone can open, like `https://hello-app-demo.box.wbxbox.net/`. The sandbox sleeps when nobody visits and wakes up on the next visit.

> **Paid plans.** Published apps are available on paid plans and to accounts that have topped up at least US$15 in total (or the same in EUR or CZK). Until then the API answers `403 feature_disabled`.

## Steps

1. **Create a named sandbox** that sleeps instead of being deleted.
2. **Put your app into it** and start the web server on a port, for example `8000`.
3. **Publish it** with a name and the command that starts the server, so the app starts again after a restart.
4. **Open the address** in any browser.

**Ask your assistant**

No code: copy this into Claude or ChatGPT with [WBX Sandbox connected](https://sandbox.wbx.cz/docs/connect.md) and change it to fit.

```
In a WBX sandbox named hello-app, make a small web page that says "Hello from my sandbox", serve it on port 8000 and publish it as an app named hello-app-demo so it stays online. Give me the address.
```

**Python**

`pip install wbxsandbox`, your key in `WBXSANDBOX_API_KEY`.

```
from wbxsandbox import Sandbox

sb = Sandbox.create(name="hello-app", on_timeout="pause")
sb.files.write("/home/user/app/index.html", "<h1>Hello from my sandbox</h1>")
sb.run("cd /home/user/app && nohup python3 -m http.server 8000 >/tmp/srv.log 2>&1 &")
app = sb.publish("hello-app-demo", 8000, start_command="python3 -m http.server 8000", cwd="/home/user/app")
print(app.url)                       # https://hello-app-demo.box.wbxbox.net/ – no token
```

**TypeScript**

`npm install wbxsandbox` (Node.js 20+); save as `.mts` for top-level `await`.

```
import { WBX } from "wbxsandbox";

const wbx = new WBX();
const sandbox = await wbx.sandboxes.create({ name: "hello-app", onTimeout: "pause" });
await sandbox.files.write("/home/user/app/index.html", "<h1>Hello from my sandbox</h1>");
await sandbox.commands.run("cd /home/user/app && nohup python3 -m http.server 8000 >/tmp/srv.log 2>&1 &");
const app = await sandbox.publish({ name: "hello-app-demo", port: 8000,
  startCommand: "python3 -m http.server 8000", cwd: "/home/user/app" });
console.log(app.url);                // https://hello-app-demo.box.wbxbox.net/ – no token
```

**curl**

Just `curl` and `jq`; your key in `WBXSANDBOX_API_KEY`.

```
H="Authorization: Bearer $WBXSANDBOX_API_KEY"
SB=$(curl -s -X POST https://sandbox.wbx.cz/v1/sandboxes -H "$H" -d '{"name": "hello-app", "on_timeout": "pause"}' | jq -r .id)
curl -s -X POST https://sandbox.wbx.cz/v1/sandboxes/$SB/exec -H "$H" -d '{"cmd": "mkdir -p /home/user/app && echo Hello > /home/user/app/index.html && cd /home/user/app && (nohup python3 -m http.server 8000 >/tmp/srv.log 2>&1 &)"}'
curl -s -X POST https://sandbox.wbx.cz/v1/apps -H "$H" -d "{\"sandbox_id\": \"$SB\", \"port\": 8000, \"name\": \"hello-app-demo\",
  \"start_command\": \"python3 -m http.server 8000\", \"cwd\": \"/home/user/app\"}" | jq -r .url
```

## How to tell it worked

- The address opens in a browser – also on your phone, with no login.
- In the portal, *Published apps* lists the app with its sandbox.

## If it doesn't work

| What you see | What to do |
| --- | --- |
| `403 feature_disabled` | Published apps are not enabled for your account yet – see the box at the top. |
| The page shows an error instead of your app | Nothing listens on the port. Check that the server runs (`/tmp/srv.log` in the example) and that the port number is the same. |
| The name is taken | Names are shared by all users. Choose another one. |
| You need more than 10 apps | An account can publish up to 10 apps. |

## What it costs

A small monthly fee for each app above the number included in your plan, plus the sandbox's compute while someone uses the app and storage while it sleeps. [Pricing](https://sandbox.wbx.cz/pricing#apps).

## Next steps

- [Published apps](https://sandbox.wbx.cz/docs/sandboxes/apps.md): Your own domain, unpublishing, limits.
- [A web app with a public URL](https://sandbox.wbx.cz/docs/guides/web-app.md): Short-lived addresses for testing.
- [Keep a workspace](https://sandbox.wbx.cz/docs/howto/workspace.md): How a named, sleeping sandbox works.

Source: https://sandbox.wbx.cz/docs/howto/web-app
