# Browser Sessions — Interactive, Stateful Browser Automation

> Markdown version of https://capture.page/browser-sessions
> Part of Capture, the web automation platform for humans and agents.
> Docs: https://docs.capture.page/docs/browser-sessions-overview
> Pricing: https://capture.page/pricing.md

Drive a real browser step by step over a simple REST API. When a single
screenshot isn't enough, open a persistent, stateful browser — log in, fill
forms, click through pages, and read dynamic content across as many steps as
your task needs.

## Why Browser Sessions

- **Persistent browser** — a real Chrome page that stays alive across requests; cookies, login state, and navigation history all persist between actions.
- **A full action set** — navigate, click, type, scroll, select, hover, wait, query the DOM, capture screenshots, and read page content.
- **Batch actions** — send navigate + click + type + screenshot in a single request to cut round-trips and keep multi-step flows fast.
- **Stealth & proxy** — bypass bot detection or route the session through your own proxy when a site needs it.

## How it works

Three endpoints — create, act, close.

1. **Create** — `POST /v1/sessions` to spin up a dedicated browser. You get back a `sessionId` and an expiry. Set a short TTL to keep costs tight.
2. **Act** — `POST /v1/sessions/{id}/actions` with actions like `goto`, `click`, `type`, `query`, `screenshot`. State carries over between every call.
3. **Close** — `DELETE /v1/sessions/{id}` as soon as you're done. Sessions are billed by duration, so closing promptly stops the meter.

## API example

Base URL: `https://api.capture.page/`
Authentication: `Authorization: Bearer YOUR_TOKEN`

```bash
# 1. Start a session
curl -X POST https://api.capture.page/v1/sessions \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ "maxTtlSeconds": 120 }'
# → { "session": { "id": "sess_abc", "expiresAt": "..." } }

# 2. Drive the browser
curl -X POST https://api.capture.page/v1/sessions/sess_abc/actions \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ "type": "goto", "payload": { "url": "https://example.com" } }'

# 3. Close when done — billing stops
curl -X DELETE https://api.capture.page/v1/sessions/sess_abc \
  -H "Authorization: Bearer YOUR_TOKEN"
```

## Action types

`goto`, `click`, `type`, `scroll`, `select`, `hover`, `wait`, `query`,
`screenshot`, `content`. Multiple actions can be batched in one request.

## Use cases

- **Authenticated scraping** — log in, navigate behind the auth wall, and extract data a single stateless request could never reach.
- **Form & checkout flows** — fill multi-step forms, select options, submit, and verify the result within one persistent context.
- **AI agents that browse** — give an LLM a live browser via MCP. It can read the page, decide the next action, and click through tasks on its own.
- **End-to-end checks** — script real user journeys, screenshot each step, and confirm the page behaves after every interaction.
- **Dynamic content** — wait for selectors, trigger lazy-loaded content, and scroll through infinite feeds before capturing the final state.
- **Interactive workflows** — anything that needs more than one shot at a page: chaining clicks, inputs, and reads into a single coherent flow.

## Pricing

Sessions are billed by duration — 1 credit per minute the session stays open
(rounded up), charged when it closes or expires (not per action). A session can
stay open for up to 15 minutes, and you can run up to 5 at once. Full pricing:
https://capture.page/pricing.md
