browser_session
Drive a browser across multiple calls while keeping the page, cookies, and login alive; snapshot interactive elements, act on stable refs, read content, then 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 ...), 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, ttl, activity_ttl, viewport), snapshot, act (the same action array as scrape_with_actions), read (formats), 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 | |
| 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. | |
| 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 |