# Open the desktop

> A short-lived URL streaming the machine's screen, or Chrome alone, with mouse and keyboard. Use it to watch or drive a browser running in the sandbox. The stream is prepared on first use, which can take a few seconds; while it is, this answers 409 sandbox_not_ready. Not available with test-mode keys.

`POST https://api.zavu.dev/v1/sandboxes/{sandboxId}/desktop`

A short-lived URL streaming the machine's screen, or Chrome alone, with mouse and keyboard. Use it to watch or drive a browser running in the sandbox. The stream is prepared on first use, which can take a few seconds; while it is, this answers `409 sandbox_not_ready`. Not available with test-mode keys.

## Parameters

- `sandboxId` (path, string, required): Sandbox ID.

## Body

- `view` (string): `desktop` streams the whole screen; `browser` streams Chrome alone. One of: `desktop`, `browser`.

## Responses

### 200

The URL.

- `desktop` (object, required)
  - `view` (string, required) One of: `desktop`, `browser`.
  - `url` (string<uri>, required): A short-lived URL that streams the machine's screen, mouse and keyboard included. Open it within a few minutes; anyone holding it can use the machine until the sandbox stops, so treat it as a secret. Ask for a new one after a resume.

### 400

Invalid body, or a test-mode key.

- `code` (string, required)
- `message` (string, required)
- `details` (object)

### 401

Unauthorized.

- `code` (string, required)
- `message` (string, required)
- `details` (object)

### 404

Sandbox not found, or it belongs to another project.

- `code` (string, required)
- `message` (string, required)
- `details` (object)

### 409

`sandbox_not_running`: resume it first. `sandbox_not_ready`: the stream is still being prepared; retry in a few seconds.

- `code` (string, required)
- `message` (string, required)
- `details` (object)

### 503

`sandbox_unavailable`: the desktop is not available right now.

- `code` (string, required)
- `message` (string, required)
- `details` (object)

## Example

```bash
curl -X POST "https://api.zavu.dev/v1/sandboxes/sandbox_abc123/desktop" \
  -H "Authorization: Bearer $ZAVUDEV_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "view": "desktop"
}'
```

```typescript
import Zavudev from "@zavudev/sdk";

const zavu = new Zavudev({ apiKey: process.env.ZAVUDEV_API_KEY });

const result = await zavu.sandboxes.desktop.open("sandbox_abc123", {
  view: "desktop",
});

console.log(result);
```
