Skip to main content
A browser session is a persistent browser instance that stays alive between API calls. Use sessions to chain multiple tasks in the same browser without losing cookies, local storage, or login state. For conceptual background, see Browser Sessions.

createBrowserSession

Spin up a new cloud browser session.
const session = await skyvern.createBrowserSession({ timeout: 60 });
console.log(session.browser_session_id); // pbs_abc123

Parameters

ParameterTypeRequiredDefaultDescription
timeoutnumberNo60Session timeout in minutes (5–1440). Timer starts after the session is ready.
proxy_locationProxyLocationNoundefinedRoute browser traffic through a geographic proxy.
extensionsExtensions[]NoundefinedBrowser extensions to install. Options: "ad-blocker", "captcha-solver".
browser_typePersistentBrowserTypeNoundefinedBrowser type. Options: "chrome", "msedge".

Returns BrowserSessionResponse

FieldTypeDescription
browser_session_idstringUnique ID. Starts with pbs_.
statusstring | undefinedCurrent session status.
browser_addressstring | undefinedCDP address for connecting to the browser.
app_urlstring | undefinedLink to the live browser view in the Cloud UI.
timeoutnumber | undefinedConfigured timeout in minutes.
started_atstring | undefinedWhen the session became ready.
created_atstringWhen the session was requested.

Example: Chain multiple tasks in one session

const session = await skyvern.createBrowserSession({});

// Step 1: Log in
await skyvern.runTask({
  body: {
    prompt: "Log in with username demo@example.com",
    url: "https://app.example.com/login",
    browser_session_id: session.browser_session_id,
  },
  waitForCompletion: true,
});

// Step 2: Extract data (same browser, already logged in)
const result = await skyvern.runTask({
  body: {
    prompt: "Go to the invoices page and extract all invoice numbers",
    browser_session_id: session.browser_session_id,
  },
  waitForCompletion: true,
});
console.log(result.output);

// Clean up
await skyvern.closeBrowserSession(session.browser_session_id);

getBrowserSession

Get the status and details of a session.
const session = await skyvern.getBrowserSession("pbs_abc123");
console.log(session.status, session.browser_address);

Parameters

ParameterTypeRequiredDescription
browserSessionIdstringYesThe session ID.

Returns BrowserSessionResponse


getBrowserSessions

List all active browser sessions.
const sessions = await skyvern.getBrowserSessions();
for (const s of sessions) {
  console.log(`${s.browser_session_id}${s.status}`);
}

Returns BrowserSessionResponse[]


closeBrowserSession

Close a browser session and release its resources.
await skyvern.closeBrowserSession("pbs_abc123");

Parameters

ParameterTypeRequiredDescription
browserSessionIdstringYesThe session ID to close.
Closing a session is irreversible. Any unsaved state (cookies, local storage) is lost unless you created a browser profile from it.