Skip to main content
A Browser Session is a live browser instance that persists cookies, local storage, and page state between task or agent runs. Think of it as keeping a browser tab open. Use sessions when you need back-to-back tasks to share state, human-in-the-loop approval, or real-time agents.

Create a session

Start a session with optional configuration for timeout, proxy, browser type, and extensions.
Parameters: Example response:
Session statuses:
Sessions close automatically when the timeout expires, even if a task is still running. The timeout countdown begins when the browser launches. Set timeouts with enough margin for your longest expected task.

Run tasks with a session

Pass browser_session_id to run_task to execute tasks in an existing session. Each task continues from where the previous one left off: same page, same cookies, same form data.

Run agents with a session

Pass browser_session_id to run_workflow to execute an agent in an existing session. This is useful when you need to run a predefined agent but want it to continue from your current browser state.
You cannot use both browser_session_id and browser_profile_id in the same request. Choose one or the other.

Save a session’s profile

By default, a browser session does not save its browser profile when it ends. To capture the session’s state (cookies, localStorage, session files) for reuse, opt in with generate_browser_profile. Python and TypeScript SDK support for this flag is rolling out; until your SDK version includes it, call the REST API directly (the Python SDK can also pass it via request_options with additional_body_parameters={"generate_browser_profile": True}).
You can also toggle the flag on a live session. The value is read when the session ends, so the update takes effect as long as the session is still open. Updating a session that has already closed returns a 409 error.
To confirm the setting on an existing session, fetch it with GET /v1/browser_sessions/{browser_session_id} — the response includes generate_browser_profile. Once the session closes and its profile finishes uploading, turn it into a reusable profile with create_browser_profile.
Sessions started from a saved profile (browser_profile_id) always save their profile when they end, regardless of this flag. This does not update the original profile — to keep the refreshed login state, create a new profile from the closed session and use the new profile’s ID in future runs.
Behavior change: sessions previously saved their profile automatically. Creating a browser profile from a closed session now fails with a 400 error unless the session had generate_browser_profile enabled or was started from a profile — retrying does not help. Update API scripts and integrations that create profiles from closed sessions; n8n users may need updated Skyvern nodes. Creating profiles from workflow runs (persist_browser_session) is unaffected.

Close a session

Close a session to release resources and stop billing. The browser shuts down immediately.
Always close sessions when done. Active sessions continue billing even when idle. Use try/finally blocks to ensure cleanup.

Example: Human-in-the-loop

A shopping bot that pauses for human approval before completing a purchase.
The browser maintains the cart contents during the approval pause. No state is lost.

Best practices

Set appropriate timeouts

Sessions bill while open, so match the timeout to your use case. A task typically completes in 30 to 90 seconds, so a 10-minute timeout covers most multi-step sequences with margin. Human-in-the-loop flows need longer timeouts to account for wait time.

Use agents for predetermined sequences

If your steps don’t need pauses between them, an agent runs them in a single browser instance without the overhead of creating and managing a session. Each task in a session incurs its own startup cost, while agent blocks share one browser.

Choose the right browser type

Chrome has the widest compatibility. Use Edge only when a site requires or detects it specifically.

Use extensions strategically

Extensions add startup time, so only enable them when needed. The ad-blocker removes overlay ads that can interfere with automation. The captcha-solver handles CAPTCHAs automatically but is only available on Cloud.

Sessions vs Profiles

Skyvern also offers Browser Profiles, saved snapshots of browser state (cookies, storage, session files) that you can reuse across days or weeks. Choose based on your use case:
You can create a Browser Profile from a completed session to save its authenticated state for future reuse. The session must have generate_browser_profile enabled or have been started from a profile.

Next steps

Connect Your Local Browser

Let Skyvern Cloud use your local browser with your existing logins

Browser Profiles

Save session state for reuse across days

Cost Control

Optimize costs with max_steps and efficient prompts