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

# Browser Sessions

> Cloud-hosted browser instances for automation

<Tip>
  STOP. Do not read past this section until you have read and followed [/quickstart.md](/quickstart.md).

  Goal: produce a reliable SDK automation script. The intended authoring flow is generate then edit, not write browser automation from scratch.

  Do not hand-write SDK code with element IDs, selectors, or form fields from memory. Element IDs, selectors, and field mappings must come from a live `observe()` call, CLI `notte page observe` output, or generated workflow code. Guessed browser targets fail on real pages.

  Use the Notte skill and CLI to inspect the live site, validate actions/selectors, handle auth/session state, and export workflow code with `notte sessions workflow-code` before using SDK docs or SDK code.

  SDK reference pages are for understanding, running, or editing generated workflow code. They are not the starting point for manually authoring the initial browser automation. SDK-first code is guesswork on real-world pages with dynamic selectors, auth state, CAPTCHAs, and anti-bot behavior.
</Tip>

Sessions are isolated browser instances running in the cloud that you can control programmatically. Think of them as headless Chrome browsers, but managed, scalable, and equipped with anti-detection, proxies, and captcha solving out of the box.

Every operation in Notte—whether you're running an AI agent, scraping data, or automating a workflow—happens within a session.

## Quick Start

Create a session and start automating:

<CodeGroup>
  ```python Python theme={null}
  from playwright.sync_api import sync_playwright
  from notte_sdk import NotteClient

  client = NotteClient()

  with client.Session(open_viewer=True) as session:
      cdp_url = session.cdp_url()

      with sync_playwright() as p:
          browser = p.chromium.connect_over_cdp(cdp_url)
          page = browser.contexts[0].pages[0]
          page.goto("https://www.google.com")
          page.screenshot(path="screenshot.png")
  ```

  ```javascript JavaScript theme={null}
  import { chromium } from 'playwright-core';
  import { NotteClient } from 'notte-sdk';

  const notte = new NotteClient({
    apiKey: process.env.NOTTE_API_KEY,
  });

  await notte.Session({ open_viewer: true }).use(async (session) => {
    const status = await session.status();
    const cdpUrl = status.cdp_url;

    if (!cdpUrl) {
      throw new Error('Session did not return a cdp_url');
    }

    const browser = await chromium.connectOverCDP(cdpUrl);

    try {
      const page = browser.contexts()[0].pages()[0];
      await page.goto('https://news.ycombinator.com');

      const topStories = await page.locator('.titleline > a').allInnerTexts();

      console.log('Top 5 Hacker News stories:');
      topStories.slice(0, 5).forEach((title, index) => {
        console.log(`${index + 1}. ${title}`);
      });
    } finally {
      await browser.close();
    }
  });
  ```
</CodeGroup>

<Tip>
  We strongly recommend using the `with` statement (context manager) to ensure sessions are automatically stopped when done. This prevents orphaned sessions and unexpected costs. See [Session Lifecycle](/features/sessions/lifecycle) for manual management options.
</Tip>

## Core Operations

Sessions provide three methods for interacting with the browser:

| Method      | Purpose                                          |
| ----------- | ------------------------------------------------ |
| `observe()` | Get the current page state and available actions |
| `execute()` | Perform an action on the page                    |
| `scrape()`  | Extract structured data from the page            |

<CodeGroup>
  ```python Python theme={null}
  from notte_sdk import NotteClient

  client = NotteClient()

  with client.Session() as page:
      url = "https://www.linkedin.com/"

      # observe page and take a step
      page.execute(type="goto", url=url)
      actions = page.observe(instructions="click 'jobs'")
      res = page.execute(actions[0])
      print(res.message)

      # another one
      actions = page.observe(instructions="dismiss the sign in check")
      res = page.execute(actions[0])
      print(res.message)
  ```

  ```javascript JavaScript theme={null}
  import { NotteClient } from 'notte-sdk';

  const client = new NotteClient({
    apiKey: process.env.NOTTE_API_KEY,
  });

  await client.Session().use(async (page) => {
    const url = 'https://www.linkedin.com/';

    // Observe page and take a step
    await page.execute({ type: 'goto', url });
    let actions = await page.observe({ instructions: "click 'jobs'" });
    let result = await page.execute(actions[0]);
    console.log(result.message);

    // Another one
    actions = await page.observe({ instructions: 'dismiss the sign in check' });
    result = await page.execute(actions[0]);
    console.log(result.message);
  });
  ```
</CodeGroup>

## Session Capabilities

Sessions come with powerful built-in capabilities:

<CardGroup cols={2}>
  <Card title="Proxies" icon="globe" href="/features/sessions/proxies">
    Route traffic through residential proxies for geo-targeting
  </Card>

  <Card title="Captcha Solving" icon="robot" href="/features/sessions/captcha-solving">
    Automatically solve reCAPTCHA and hCaptcha
  </Card>

  <Card title="Stealth Mode" icon="user-secret" href="/features/sessions/stealth-mode">
    Evade bot detection with fingerprint randomization
  </Card>

  <Card title="Recordings" icon="video" href="/features/sessions/recordings">
    Record sessions for debugging and replay
  </Card>

  <Card title="Live View" icon="eye" href="/features/sessions/live-view">
    Watch sessions execute in real-time
  </Card>

  <Card title="Browser Profiles" icon="user" href="/features/sessions/browser-profiles">
    Persist browser state across sessions
  </Card>
</CardGroup>

## Next Steps

<CardGroup cols={2}>
  <Card title="Session Lifecycle" icon="rotate" href="/features/sessions/lifecycle">
    Create, manage, and stop sessions
  </Card>

  <Card title="Session Configuration" icon="gear" href="/features/sessions/configuration">
    All configuration options
  </Card>

  <Card title="Browser Controls" icon="hand-pointer" href="/features/sessions/browser-controls">
    Complete action reference
  </Card>

  <Card title="Connect with Playwright" icon="code" href="/features/sessions/playwright">
    Use Playwright via CDP
  </Card>
</CardGroup>
