# List your previews with the SDK

**In short:** `previews_list` returns every preview your machines offer: its name, address, port, machine, who may open it and
how many browsers are signed in. `preview_open` gives you a one-time link to open a private preview in your own browser.

Both are server tools: they need no machine to be selected, and work with SDK 3.9.1 or later. The token needs the
`http` permission, which the owner turns on as "Open your previews" for the agent; without it the call is refused
with `denied`. To offer an app as a preview in the first place, see [previews](https://docs.cmdop.ai/guides/previews.md).

```ts
const previews = await client.previews_list({});
for (const p of previews) {
  console.log(p.name, p.port, p.machine.name, p.visibility, p.signed_in);
}
```

```python
for p in client.previews_list():
    print(p.name, p.port, p.machine.name, p.visibility, p.signed_in)
```

`p.url` is the preview's address. Share links are listed with their note, expiry and state, never their address.

## Open a private preview

`preview_open` takes the preview's `name` and returns `url` and `expires`. The link signs the browser that opens it
in to that preview as you; it works up to 3 times within 10 minutes. Treat it as a secret: open it, do not print,
log or send it. A public preview returns its own address with no `expires`.

```python
import webbrowser

link = client.preview_open(name="storybook")
webbrowser.open(link.url)
```

## Runnable source

The pair is `previews` in the [source catalog](https://docs.cmdop.ai/reference/sdk/examples/catalog.md). It is not run by default; select it
with a token that has `http`:

```bash
ONLY=previews bash examples/run.sh
```

[SDK examples](https://docs.cmdop.ai/reference/sdk/examples.md) · [Previews](https://docs.cmdop.ai/guides/previews.md)
