---
# @generated by sylphx-gen 0.1.0 from contracts@e145cc7cf1bc9605f2b27439e5e17ed76a1a2fd7e7021906a013f7565e4a0cd5. Do not edit.
title: "Open stream on a lease"
description: "`sandboxes.leases.open_stream` (POST /v1/{name}:openStream): Opens a read-only live view of a lease's display: a short-lived viewer token bound to the lease and its generation, an embeddable URL, and the WebRTC signaling endpoint with ICE…"
type: reference
product: sandboxes
summary: "Opens a read-only live view of a lease's display: a short-lived viewer token bound to the lease and its generation, an embeddable URL, and…"
updated: 2026-09-28
nav: false
---

Opens a read-only live view of a lease's display: a short-lived viewer token bound to the lease and its generation, an embeddable URL, and the WebRTC signaling endpoint with ICE servers. Input needs control (AcquireLeaseControl).

- **Path** `POST https://api.sylphx.com/v1/orgs/acme/projects/shop/envs/production/leases/lease:openStream`
- **Scope** `sandboxes:exec`
- **Effect** `write` — a successful call changes state.
- **Collection** [leases](/docs/api/leases)

## Request

| Field | Type | What it is |
| --- | --- | --- |
| `name` | `string` | The name of the lease. Required. |
| `ttl` | `duration` | How long the token admits a new connection; at most and default 5 minutes. A connected stream ends when the lease generation changes or the token is revoked. |

## Response

| Field | Type | What it is |
| --- | --- | --- |
| `role` | `StreamRole` | VIEWER (frames) or CONTROLLER (frames and input). One of `viewer`, `controller`. |
| `token` | `string` | The stream token. Never returned again. |
| `viewer_uri` | `string` | An embeddable page (web, Telegram Mini App webview) that connects on load; the token rides in the URL fragment and never reaches a server log. Never returned again. |
| `signaling_uri` | `string` | The WebRTC signaling WebSocket; send the token as the first message. |
| `ice_servers` | `IceServer[]` | ICE servers, TURN credentials included, valid until `expire_time`. |
| `vnc_uri` | `string` | The noVNC/websockify fallback WebSocket for networks that block WebRTC. |
| `expire_time` | `timestamp` | When the token stops admitting new connections. |
| `lease_generation` | `int64` | The lease generation the token is bound to. |
| `control_epoch` | `int64` | For CONTROLLER: the control epoch the token is bound to. |
| `revoke_uri` | `string` | Revokes the token early: `POST` it with the token as bearer. |

### IceServer

| Field | Type | What it is |
| --- | --- | --- |
| `urls` | `string[]` | `stun:`, `turn:`, or `turns:` URLs. |
| `username` | `string` | The TURN username. |
| `credential` | `string` | The TURN credential. Never returned again. |

## Errors

- [`UNAUTHENTICATED`](/docs/api/errors/UNAUTHENTICATED) — No valid key or token was presented.
- [`PERMISSION_DENIED`](/docs/api/errors/PERMISSION_DENIED) — The key lacks the method's permission.
- [`RESOURCE_NOT_FOUND`](/docs/api/errors/RESOURCE_NOT_FOUND) — The named Resource does not exist or is not visible.
- [`INVALID_STATE`](/docs/api/errors/INVALID_STATE) — The Resource is in a state that forbids the call.

Every error arrives in the body [Errors](/docs/platform/errors) describes.

## Examples

**cURL**

```curl
curl -X POST "https://api.sylphx.com/v1/orgs/acme/projects/shop/envs/production/leases/lease:openStream" \
  -H "Authorization: Bearer $SYLPHX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{}'
```

**TypeScript**

```ts
const response = await sylphx.sandboxes.leases.openStream({ name: 'orgs/acme/projects/shop/envs/production/leases/lease' })
```

**Rust**

```rust
let mut req = sylphx::sandboxes::OpenLeaseStreamRequest::default();
req.name = "orgs/acme/projects/shop/envs/production/leases/lease".to_string();
let response = sx.sandboxes().leases().open_stream(req).await?;
```

**CLI**

```bash
sylphx sandboxes leases open-stream orgs/acme/projects/shop/envs/production/leases/lease
```

**MCP**

```json
{ "method_id": "sandboxes.leases.open_stream", "args": {"name":"orgs/acme/projects/shop/envs/production/leases/lease"} }
```
