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

> ## Agent Instructions
> Authenticate REST, SDK, and CLI requests with the `x-api-key` header using the `HYPERBROWSER_API_KEY` environment variable (create keys at https://app.hyperbrowser.ai).
> Always stop browser sessions (`sessions.stop(id)` / `PUT /api/session/{id}/stop`) and sandboxes (`sandboxes.stop(id)` / `PUT /api/sandbox/{id}/stop`) in `try`/`finally` blocks to avoid idle billing.
> Choose the right surface: use Web API (`/api/web/fetch`, `batch-fetch`, `crawl`, `search`) for stateless reading and extraction (prefer it over legacy `/api/scrape`); Browser Sessions (`/api/session`) for interactive, authenticated, or Playwright/Puppeteer workflows; Cloud Agents (`/api/task/*`) for autonomous browser tasks; and Sandboxes (`/api/sandbox`) for isolated Linux or macOS code execution.
> Use `@hyperbrowser/sdk` for Node.js/TypeScript, `hyperbrowser` 1.0+ typed-dict request params for Python (avoid legacy Pydantic request classes), the unified `hx` CLI for terminal workflows, and hosted OAuth MCP at `https://mcp.hyperbrowser.ai/mcp/web` (web tools; use `https://mcp.hyperbrowser.ai/mcp` only when browser, sandbox, admin, and usage tools are needed).

# Observability & Debugging

> Inspect session event logs and active session counts

Hyperbrowser provides structured telemetry endpoints alongside [Live View](https://hyperbrowser.ai/docs/sessions/live-view.md) and [Recordings](https://hyperbrowser.ai/docs/sessions/recordings.md) so you can monitor concurrency, audit session events, and debug failing browser runs programmatically.

***

## Active Sessions Count

Check how many sessions are currently active across your team using `GET /api/sessions/active-count` (requires `browser.sessions.read`):

```typescript TypeScript theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
import { Hyperbrowser } from "@hyperbrowser/sdk";

const client = new Hyperbrowser({
  apiKey: process.env.HYPERBROWSER_API_KEY,
});

const { activeSessionsCount } = await client.sessions.getActiveSessionsCount();
console.log("Active sessions:", activeSessionsCount);
```

```python Python theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
import os
from hyperbrowser import Hyperbrowser

client = Hyperbrowser(api_key=os.environ["HYPERBROWSER_API_KEY"])

resp = client.sessions.get_active_sessions_count()
print("Active sessions:", resp.active_sessions_count)
```

```bash cURL theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
curl https://api.hyperbrowser.ai/api/sessions/active-count \
  -H "x-api-key: $HYPERBROWSER_API_KEY"
```

***

## Session Event Logs

Session event logs record structured lifecycle and automation events for a session via `GET /api/session/{id}/event-logs` (requires `browser.sessions.logs.read`).

### Event Types

| Event `type` | Triggered when |
| - | - |
| `captcha_detected` | Automatic CAPTCHA detection encounters a challenge on a page. |
| `captcha_solved` | A CAPTCHA challenge is solved. |
| `captcha_error` | CAPTCHA solving fails or errors. |
| `file_downloaded` | The browser downloads a file (metadata includes `path`). |
| `tab_opened` | A new browser tab/target opens. |
| `credential_filled` | [Credential Fill](https://hyperbrowser.ai/docs/sessions/credentials.md) fills fields on an allowed origin (values are never logged). |
| `credential_fill_refused` | Credential Fill refuses a request (metadata includes `reason` and safe host/origin details). |

### Querying Event Logs

Filter by `types`, `targetId`, `startTimestamp`, `endTimestamp`, `page` (1-indexed, default `1`), and `limit` (1–100, default `10`):

```typescript TypeScript theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
const logs = await client.sessions.eventLogs.list(session.id, {
  types: ["captcha_detected", "captcha_solved", "file_downloaded"],
  page: 1,
  limit: 50,
});

for (const entry of logs.data) {
  console.log(entry.timestamp, entry.type, entry.pageUrl, entry.metadata);
}
```

```python Python theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
logs = client.sessions.event_logs.list(
    session.id,
    {
        "types": ["captcha_detected", "captcha_solved", "file_downloaded"],
        "page": 1,
        "limit": 50,
    },
)

for entry in logs.data:
    print(entry.timestamp, entry.type, entry.page_url, entry.metadata)
```

```bash cURL theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
curl "https://api.hyperbrowser.ai/api/session/${SESSION_ID}/event-logs?page=1&limit=50" \
  -H "x-api-key: $HYPERBROWSER_API_KEY"
```

***

## Debugging Runbook

When an automation run fails unexpectedly, work through this sequence:

1. **Check session status & exit state** — Call `sessions.get(id)` and inspect `status` (`active`, `closed`, `close-error`, `error`) and `launchState`.
2. **Watch or replay visually** — Open `liveUrl` while running ([Live View](https://hyperbrowser.ai/docs/sessions/live-view.md)), or retrieve the rrweb/MP4 replay after stop ([Recordings](https://hyperbrowser.ai/docs/sessions/recordings.md)).
3. **Inspect event logs** — Call `sessions.eventLogs.list(id)` to see whether a CAPTCHA triggered (`captcha_detected` / `captcha_error`), a download finished (`file_downloaded`), or credential fill was refused (`credential_fill_refused`).
4. **Verify concurrency headroom** — Call `sessions.getActiveSessionsCount()` before bursting new sessions so you stay below your plan's concurrent session limit.


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