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

> ## Agent Instructions
> Anchor Browser is cloud browser infrastructure for AI agents and automation: browser sessions you control over CDP or REST, natural-language web tasks, versioned automation tasks, managed authentication into third-party web apps (identities with MFA), persistent volumes and profiles, recordings, live view, batch sessions, webhooks, and network options including residential proxies, extra stealth, and captcha solving for sites that block standard browsers. AI agents should start at https://docs.anchorbrowser.io/for-agents, then create an API key at https://app.anchorbrowser.io/api-keys. Read the for-agents page before authentication or API calls.

# Embedded Browser Live UI

> Embed interactive browser sessions directly into your application

## Overview

Anchor Browser offers a live view feature that allows you to embed an interactive frame of a website as a web element. The `live_view_url` is received when creating a session.

## Headful Mode (Default)

Headful mode provides a single URL to view the full chrome view, including the address bar. This ensures the presented tab is always the active tab and provides the best user experience.

![Browser Live View in Headful Mode](https://mintcdn.com/anchor-b3ec2715/hJc2I0-WvjLCCXOl/images/vnc-live-view.png?fit=max\&auto=format\&n=hJc2I0-WvjLCCXOl\&q=85\&s=774f0fea0d9359730307c6a21e50ae9c)

To create a browser in headful mode, [create a session](https://docs.anchorbrowser.io/quickstart/create-session.md) with `browser.headless.active` set to `false` (the default):

```javascript node.js theme={null}
import { client, Sessions } from 'anchorbrowser';

// Initialize the client
client.setConfig({ auth: () => process.env.ANCHOR_API_KEY });

// For explicit headfull session configuration (optional, default to false)
const config = {
  browser: {
    headless: {
      active: false
    }
  }
};

const session = await Sessions.createSession({ body: config });
const liveViewUrl = session.data.live_view_url;
console.log(`Live view URL: ${liveViewUrl}`);
```

```python python theme={null}
from anchorbrowser import Anchorbrowser
import os

# Initialize the client
client = Anchorbrowser(api_key=os.getenv("ANCHOR_API_KEY"))

# For explicit headfull session configuration (optional, default to False)
config = {
    "headless": {
      "active": False
    }
}

session = client.sessions.create_session(browser=config)
print(f"Live view URL: {session.data.live_view_url}")
```

Then, use the `live_view_url` from the response to embed the live view directly into an iframe:

```html theme={null}
<iframe 
  src="{{live_view_url}}" 
  sandbox="allow-same-origin allow-scripts" 
  allow="clipboard-read; clipboard-write" 
  style="border: 0px; display: block; width: 100%; height: 100%; position: absolute; top: 0px; left: 0px;">
</iframe>
```

## Advanced Embedding Configuration

### Embed in Fullscreen View (Hide Navigation Bar)

To use the fullscreen view, replace the live view URL with the following:

```html theme={null}
<iframe src="{{live_view_url}}" ...></iframe>
```

### Disable Browser Interactivity

To prevent the end user from interacting with the browser, add the `style="pointer-events: none;"` attribute to the iframe:

```html theme={null}
<iframe 
  src="{{live_view_url}}" 
  sandbox="allow-same-origin allow-scripts" 
  allow="clipboard-read; clipboard-write" 
  style="border: 0px; display: block; width: 100%; height: 100%; position: absolute; top: 0px; left: 0px; pointer-events: none;">
</iframe>
```

> [!NOTE]
>
> This feature is available for both headful and headless modes.

### Single-Use Live View URL

To generate a live view URL that can only be used once, set `one_time_url` to `true`. After the first viewer connects and disconnects, the URL becomes permanently invalid.

```javascript node.js theme={null}
import { client, Sessions } from 'anchorbrowser';

client.setConfig({ auth: () => process.env.ANCHOR_API_KEY });

const session = await Sessions.createSession({
  body: {
    session: {
      live_view: {
        one_time_url: true
      }
    }
  }
});

const liveViewUrl = session.data.live_view_url;
console.log(`Single-use live view URL: ${liveViewUrl}`);
```

```python python theme={null}
from anchorbrowser import Anchorbrowser
import os

client = Anchorbrowser(api_key=os.getenv("ANCHOR_API_KEY"))

session = client.sessions.create_session(
    session={
        "live_view": {
            "one_time_url": True
        }
    }
)

print(f"Single-use live view URL: {session.data.live_view_url}")
```

> [!WARNING]
>
> `one_time_url` requires a headful browser. It cannot be used with headless mode.

### Scoped Access Tokens

To hand a session to an end user without sharing its session id, set `session.scoped_access.active` to `true`. The create response then carries three URLs, each with its own `token` and no session id:

| Field | The token holder can |
| - | - |
| `live_view_read_only_url` | Watch the browser. Mouse, keyboard and clipboard input is ignored. |
| `live_view_url` | Watch and interact with the browser. |
| `cdp_url` | Control the browser over CDP. |

A read-only viewer and an interactive viewer can watch the same session at the same time. A live view token only opens the live view: it cannot connect over CDP or call the browser's APIs.

On a scoped session the session id is no longer a credential on its own: connecting to CDP or the live view with only `?sessionId=` is refused. Connect with a token (`?token=`), or with the session id and a token (`?sessionId=...&token=...`). Any other session switches to tokens the same way as soon as you mint a token for it (see below); sessions that never use tokens keep working with the session id alone.

If the session also sets `live_view.read_only`, no live view can interact: `live_view_url` is the same read-only URL as `live_view_read_only_url`, and `cdp_url` keeps full control.

```javascript node.js theme={null}
import { client, Sessions } from 'anchorbrowser';

client.setConfig({ auth: () => process.env.ANCHOR_API_KEY });

const session = await Sessions.createSession({
  body: {
    session: {
      scoped_access: {
        active: true
      }
    }
  }
});

console.log(`Read-only live view: ${session.data.live_view_read_only_url}`);
console.log(`Interactive live view: ${session.data.live_view_url}`);
console.log(`CDP: ${session.data.cdp_url}`);
```

```python python theme={null}
from anchorbrowser import Anchorbrowser
import os

client = Anchorbrowser(api_key=os.getenv("ANCHOR_API_KEY"))

session = client.sessions.create_session(
    session={
        "scoped_access": {
            "active": True
        }
    }
)

print(f"Read-only live view: {session.data.live_view_read_only_url}")
```

To mint more token URLs for any running headful session, for example one per end user, call `POST /v1/sessions/{session_id}/tokens`. Pass `scopes` to choose which URLs to mint, or omit it for every URL the session can serve (no `live_view_url` on a `one_time_url` session). Every call returns new tokens:

```bash theme={null}
curl -X POST "https://api.anchorbrowser.io/v1/sessions/$SESSION_ID/tokens" \
  -H "anchor-api-key: $ANCHOR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"scopes": ["live_view_read_only"]}'
```

To revoke one, pass the `token` from its URL. The URL stops opening new connections; a connection that is already open stays until it closes:

```bash theme={null}
curl -X DELETE "https://api.anchorbrowser.io/v1/sessions/$SESSION_ID/tokens/$TOKEN" \
  -H "anchor-api-key: $ANCHOR_API_KEY"
```

> [!WARNING]
>
> Tokens stop working when the session ends. `scoped_access` requires a headful cloud browser, cannot be combined with `one_time_url`, and is not accepted by batch or async session creation: for those, mint tokens with `POST /v1/sessions/{session_id}/tokens` once the session is running.
>
> Minting a token on a session without `scoped_access` makes it token-only from then on: connections that are already open stay up, but new connections with only `?sessionId=` are refused, so include `cdp` in `scopes` if your own code still connects. Revoking the tokens does not restore session id access.

## Remote OS cursor

By default, live view draws a cursor at **your** mouse. To paint the remote OS pointer into the stream instead (needed to watch OS-level mouse APIs), append `show_cursor=1` to `live_view_url`:

```
https://live.anchorbrowser.io/inspector.html?sessionId=<id>&show_cursor=1
```

## Headless Mode

To obtain the browser live session URL in headless mode, start by [creating a session](https://docs.anchorbrowser.io/api-reference/browser-sessions/start-browser-session.md):

```javascript node.js theme={null}
import { client, Sessions } from 'anchorbrowser';

// Initialize the client
client.setConfig({ auth: () => process.env.ANCHOR_API_KEY });

const config = {
  browser: {
    headless: {
      active: true
    }
  }
};

const session = await Sessions.createSession({ body: config });
const liveViewUrl = session.data.live_view_url;
console.log(`Live view URL: ${liveViewUrl}`);
```

```python python theme={null}
from anchorbrowser import Anchorbrowser
import os

# Initialize the client
client = Anchorbrowser(api_key=os.getenv("ANCHOR_API_KEY"))

config = {
    "headless": {
      "active": True
    }
}

session = client.sessions.create_session(browser=config)
print(f"Live view URL: {session.data.live_view_url}")
```

![Browser Live View in Headless Mode](https://mintcdn.com/anchor-b3ec2715/hJc2I0-WvjLCCXOl/images/cdp-live-view.png?fit=max\&auto=format\&n=hJc2I0-WvjLCCXOl\&q=85\&s=dc51ac109c87e8f58ff04aefd508ebf5)

> [!WARNING]
>
> The live\_view\_url currently points to the browser default first page.

Then, use the **create-session** response to embed the live view URL directly into an iframe:

```html theme={null}
<iframe src="{{live_view_url}}" sandbox="allow-same-origin allow-scripts" allow="clipboard-read; clipboard-write" style="border: 0px; display: block; width: 100%; height: 100%; position: absolute; top: 0px; left: 0px;"></iframe>
```


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