# Desktop

> A full Linux desktop with Chrome, streamed to your browser — for people, and for computer-use agents.

Every running sandbox has a graphical desktop (XFCE with Google Chrome) that you can open in a browser tab. Use it to click through the app you're building, debug an Electron app, sign in to a website, or watch an agent work.

## Open it

```bash title="CLI"
sbx desktop sb_k3v9x2mq           # opens the stream in your browser
sbx desktop sb_k3v9x2mq --vnc     # ask for VNC explicitly
```

```bash title="curl"
curl -sS -X POST https://sandboxer.com/api/v1/sandboxes/sb_k3v9x2mq/desktop \
  -H "Authorization: Bearer $SANDBOXER_API_KEY"
```

```typescript title="TypeScript"
const { desktopUrl } = await sbx.desktop({ sandboxId: "sb_k3v9x2mq" });
```

The dashboard has an **Open desktop** button on each running sandbox. A stopped or provisioning sandbox has no desktop — resume it first. The first open on a sandbox takes a few seconds while the desktop starts; `provisioning: true` in the response means "ask again shortly".

## Streaming modes

Today every desktop streams over **VNC** (noVNC over plain HTTPS), which works through any firewall that allows HTTPS. The response's `mode` field says which transport you got.

**WebRTC** streaming (hardware-friendly video at a high frame rate) is coming. Until it ships, a request for the default mode is served over VNC, with a `message` explaining that.

## Browser-only view

```bash
sbx browser sb_k3v9x2mq
sbx browser sb_k3v9x2mq --profile /data/chrome-work
```

Streams only Chrome (tabs and address bar, no desktop around it) — useful to embed a "remote browser" in your own product. `--profile` picks a Chrome user-data directory, so one sandbox can hold several signed-in profiles. Profiles live on the disk and are kept by snapshots and forks. The path must be absolute and outside `/home/user`.

It's a separate Chrome on its own display (`:2`), served on port 6081 (`https://<subdomain>-6081.box.sandboxer.com`), so it doesn't share windows or tabs with the desktop's Chrome on `:1`.

## Desktop URLs and security

A desktop URL carries a secret token. Anyone with the URL can see and control the screen, so:

- each URL works for **ten minutes**: open it within that time, and that browser stays signed in to the desktop for the rest of its session (8 hours). After that, open the desktop again (dashboard or `sbx desktop`) for a fresh URL;
- `GET /sandboxes/{id}/host` lists the desktop's address but never a working URL;
- treat it like a password and redact it from logs (we do);
- for embedding, put it in an `<iframe>` served from your own authenticated page;
- `--public` returns a URL without a token — use it only for throwaway demos.

The desktop is served through the same proxy as [hosted ports](/docs/hosting), on the desktop's port 6080: `https://<subdomain>-6080.box.sandboxer.com/vnc.html?…`. `sbx desktop` and the dashboard give you the full URL with its token.

## Set your own background

Put a PNG at `~/.config/sandboxer/wallpaper.png` on the sandbox and the desktop shows it within a couple of seconds. Delete the file to go back to the default background. The image lives on the disk, so it stays after a stop, a resume and a fork.

```bash
sbx scp ./wallpaper.png sb_k3v9x2mq:/home/user/.config/sandboxer/wallpaper.png
```

The image fills the screen and keeps its aspect ratio. Limits: PNG only, 16 MiB or less, at most 8192 pixels wide or high and 16,777,216 pixels in all (for example 4096×4096). A file that is not a valid PNG leaves the default background.

## Agents on the desktop

[Integrated agents](/docs/agents) get `computer` tools — screenshot, move, click, type, scroll — that act on this same screen. Open the stream and watch a prompt fill in a form or test a checkout flow. Your own agents can drive it too, with `xdotool`, Playwright against the headed Chrome, or any VNC client library. The desktop is display `:1`, so run them with `DISPLAY=:1` (nothing sets it for you). The display starts the first time the desktop is opened, so open it once (`sbx desktop` or the dashboard) before a headed script, or it fails with "Missing X server or $DISPLAY".

## Record the screen

```bash
sbx exec sb_k3v9x2mq --detach "ffmpeg -y -f x11grab -framerate 30 -video_size 1920x1080 -i :1 ~/demo.mp4"
# … do the thing …
sbx exec sb_k3v9x2mq "pkill -INT ffmpeg"
sbx scp sb_k3v9x2mq:/home/user/demo.mp4 .
```

## Tips

- The screen is 1920×1080, which is also the largest size. To make it smaller, add the mode first, because a plain `xrandr -s` to a new size fails (`Size … not found in available modes`):

  ```bash
  export DISPLAY=:1
  xrandr --newmode 1280x720 0 1280 0 0 0 720 0 0 0
  xrandr --addmode screen 1280x720
  xrandr --output screen --mode 1280x720
  ```
- Copy and paste between your computer and the sandbox with the clipboard panel in the noVNC sidebar.
- Desktop sessions usually survive stop and resume: open windows are still there when memory is restored. If the sandbox boots from disk instead (see [resume](/docs/snapshots#resume)), files are kept but windows aren't, so open the desktop again.
