> ## Documentation Index
> Fetch the complete documentation index at: https://docs.boat.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Embed the desktop and secure its URL

> What a desktop URL contains, how long it works, how to embed the stream in your app in an iframe, and how boat protects the desktop.

This page covers desktop URLs. For every URL that carries a token, read [Security and isolation](https://docs.boat.dev/security.md#urls-that-carry-a-token).

## Embed the stream in your app

**1. Ask for a URL on your server**

On each page load, your server calls the desktop endpoint with your API key. Do not put the API key in the browser.

```bash curl theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
curl -sS -X POST "$BOAT_API_BASE/sandboxes/bx_f7k2q9hd/desktop?theme=light" \
  -H "Authorization: Bearer $BOAT_API_KEY"
```

`BOAT_API_BASE` is `https://boat.dev/api/v1`. The response has `desktopUrl`.

**2. Hide the viewer overlay (optional)**

Add `overlay=0` to the query string, before the `#`. The side panel and the stats text then never show. The token stays in the fragment.

```text theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
https://<sandbox-desktop-host>/stream.html?hostId=<host>&appId=<app>&theme=light&overlay=0#token=<token>
```

**3. Put the URL in an iframe**

```html theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
<iframe src="DESKTOP_URL" allow="autoplay; fullscreen; clipboard-read; clipboard-write" style="width:100%;aspect-ratio:16/9;border:0"></iframe>
```

## How long a desktop URL works

| Case | What happens |
| - | - |
| You open the URL within 10 minutes | The stream starts. |
| You open the URL after 10 minutes | The viewer cannot sign in. Ask for a new URL. |
| A stream is already open | It keeps playing after the 10 minutes. |
| The page reloads, or the viewer reconnects after 10 minutes | It needs a new URL. Ask for one on each page load. |
| The sandbox stops | The stream ends. After a resume, ask for a new URL. |

## What happens when you open the desktop

1. The CLI or the dashboard asks boat for a new signed-in desktop URL for your sandbox.
2. If the desktop stream is not ready, boat prepares it.
3. boat opens the browser viewer.

The URL opens a browser page. It looks like this:

```text theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
https://<sandbox-desktop-host>/stream.html?hostId=<host>&appId=<app>&theme=light#token=<token>
```

boat generates the host, the IDs and the token for the running sandbox.

`boat desktop` also prints a `viewerUrl`. It carries the same token, so treat it the same way.

## How the Moonlight viewer handles the token

* The viewer removes the fragment from the URL at once.
* The viewer sends the token in authenticated request headers and in the first WebSocket frame.
* The viewer never puts the token in an HTTP or WebSocket request URL.

## Security model

| Topic | Rule |
| - | - |
| How boat makes a URL | Only through the authenticated boat API. The API key needs the `desktop` action. |
| URL lifetime | Open it within 10 minutes. See the table above. |
| List and info responses | They do not cache or return a desktop URL. Call the desktop endpoint each time you open a stream. |
| Clipboard | Reads and writes work only with the credentials of the active desktop Moonlight stream. |
| Browser-only view | It has no clipboard routes. |

Anyone who has the full URL can attach to that desktop session. Treat the URL as sensitive:

* Do not paste the full URL into shared chats or logs.
* To give another person lasting access to a sandbox, use an [organization](https://docs.boat.dev/organizations.md). Do not share a desktop URL.

## After a stop, resume or fork

* When you stop a sandbox, the desktop is not available. Resume the sandbox to use it again.
* Desktop programs do not survive a resume or a fork. Open Chrome again and restart your app or dev server.
* The `computer` tools come back by themselves. boat restarts the desktop daemon behind them with the sandbox.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.