browser_session
Maintain a live browser page with cookies and login across calls to open a URL, snapshot interactive refs, act stepwise, read content, and close.
Instructions
Use this to drive a browser across several calls, keeping the page, its cookies and its login in between. The loop is: open a session on a URL, snapshot it to list the interactive elements with stable refs (@e1, @e2 ..., including elements inside open shadow roots and iframes), act on those refs, read the content, close. Because the page stays open you can look before each step instead of committing to a whole chain up front, so a wrong selector costs one call rather than all of them. Operations: open (url, stealth, engine, ttl, activity_ttl, viewport), snapshot, act (the same action array as scrape_with_actions), read (formats; the whole page by default, onlyMainContent:true for the main article block alone), screenshot, close, list. Navigation invalidates refs, so snapshot again after one. robots.txt is respected on every navigation, and screenshots are stored as crawlforge://screenshot/{actionId} resources. A session expires 600s after it opens or 300s after its last use, whichever comes first, so close it when you are done. Not for a page that renders without interaction (scrape), and not for an interaction you can write out in advance - that is one scrape_with_actions call for 5. Cost: 3 credits to open; read 2; snapshot, act, screenshot, close and list 1 each. Example: browser_session({operation:"open", url:"https://app.com/login"}), then browser_session({operation:"snapshot", session_id:"..."})
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ttl | No | open: seconds the session may live at most (default 600) | |
| url | No | open: the URL to load the session on | |
| engine | No | open: stealth engine for the session, with stealth:true. "auto" (default) runs camoufox when it is installed and Chromium otherwise; every operation echoes the `engine` that actually ran. "camoufox" is Firefox-based with a higher anti-detect score; "chromium" (= "playwright") forces Chromium. Refused without stealth:true, where the browser is always Chromium. | auto |
| format | No | screenshot: image format | png |
| actions | No | act: the action array, same shape as scrape_with_actions. Target refs like "@e2" in `selector` | |
| formats | No | read: output formats | |
| quality | No | screenshot: JPEG quality | |
| stealth | No | open: run the session in the stealth browser | |
| timeout | No | Per-action timeout in ms | |
| selector | No | screenshot: capture just this element (a ref like "@e2" works) | |
| viewport | No | open: viewport size | |
| full_page | No | screenshot: capture the full scrollable page | |
| max_nodes | No | snapshot: cap on emitted nodes (default 200) | |
| operation | Yes | open a session, observe it, act on it, read it, or close it | |
| session_id | No | The id returned by operation:"open". Required by every operation except open and list | |
| activity_ttl | No | open: seconds the session may sit idle (default 300) | |
| respect_robots | No | Respect the target site's robots.txt (default: true). Setting this to false is honoured, returns a warning in the response, and is recorded against your API key — it is your decision, not a silent default. | |
| onlyMainContent | No | read: false (default) returns the whole page as markdown/text (markdown leaves out nav, footer and aside elements, as scrape's does; text leaves out nothing); true keeps only the main article block via Readability, which drops navigation and footers but can also drop list items on listing and app pages. The result's extractionMethod says which ran ("full_page" for the whole page) | |
| interactive_only | No | snapshot: only interactive elements get refs (false also emits headings and landmarks) | |
| max_inline_chars | No | Largest result to return inline, in characters of its JSON. Over it, the call returns a preview plus a result_handle for read_result instead of the whole result (default 40,000; env CRAWLFORGE_MAX_INLINE_CHARS) | |
| continue_on_error | No | act: keep going past a failed action |