A Browser Session is a live browser instance that persists cookies, local storage, and page state between task or workflow 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.
Browser is live and accepting tasks. This is the status returned on creation. The browser launches within seconds.
closed
Session was closed manually or by timeout. No further tasks can run.
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.
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.
Copy
Ask AI
import asynciofrom skyvern import Skyvernasync def main(): client = Skyvern(api_key="YOUR_API_KEY") # Create session session = await client.create_browser_session(timeout=30) session_id = session.browser_session_id try: # Task 1: Login (wait for completion before continuing) await client.run_task( prompt="Login with username 'support@company.com'", url="https://dashboard.example.com/login", browser_session_id=session_id, wait_for_completion=True, ) # Task 2: Search (already logged in from Task 1) result = await client.run_task( prompt="Find customer with email 'customer@example.com'", browser_session_id=session_id, wait_for_completion=True, ) print(f"Customer: {result.output}") finally: # Always close when done await client.close_browser_session(browser_session_id=session_id)asyncio.run(main())
Pass browser_session_id to run_workflow to execute a workflow in an existing session. This is useful when you need to run a predefined workflow but want it to continue from your current browser state.
Copy
Ask AI
import asynciofrom skyvern import Skyvernasync def main(): client = Skyvern(api_key="YOUR_API_KEY") # Create session session = await client.create_browser_session(timeout=60) session_id = session.browser_session_id try: # First, login manually via a task await client.run_task( prompt="Login with username 'admin@company.com'", url="https://app.example.com/login", browser_session_id=session_id, wait_for_completion=True, ) # Then run a workflow in the same session (already logged in) result = await client.run_workflow( workflow_id="wpid_export_monthly_report", browser_session_id=session_id, wait_for_completion=True, ) print(f"Workflow completed: {result.status}") finally: await client.close_browser_session(browser_session_id=session_id)asyncio.run(main())
You cannot use both browser_session_id and browser_profile_id in the same request. Choose one or the other.
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.
Copy
Ask AI
# Quick multi-step task (2-3 tasks back to back)session = await client.create_browser_session(timeout=10)# Human-in-the-loop with wait time for approvalsession = await client.create_browser_session(timeout=60)# Long-running agent that monitors a dashboardsession = await client.create_browser_session(timeout=480) # 8 hours
If your steps don’t need pauses between them, a workflow 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 workflow blocks share one browser.
Copy
Ask AI
# Less efficient: multiple tasks in a session (each task has startup overhead)session = await client.create_browser_session()await client.run_task(prompt="Step 1", browser_session_id=session.browser_session_id, wait_for_completion=True)await client.run_task(prompt="Step 2", browser_session_id=session.browser_session_id, wait_for_completion=True)# More efficient: single workflow (blocks share one browser, no inter-task overhead)await client.run_workflow(workflow_id="wpid_abc", wait_for_completion=True)
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.
Copy
Ask AI
# Block ads that overlay content and interfere with clickssession = await client.create_browser_session(extensions=["ad-blocker"])# Auto-solve captchas (Cloud only)session = await client.create_browser_session(extensions=["captcha-solver"])
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: