Skip to content

Browser API ​

Use the browser surface when you need one of these three paths:

  • direct browser automation from your application code,
  • a recorded flow that replays a driven task without a model in the loop,
  • a Browser MCP server, published from the Console's MCP module, that exposes the Browser Use toolset.

The old standalone client.browserAgents API has been removed. If you want a Console-managed agent to browse the web, attach the Browser Use system tool in Console and invoke that agent through client.agents.

Durable targets ​

browser_snapshot and browserSessions.snapshot() return [ref=e4]-style markers — cheap, but valid only for the snapshot that produced them; the browser renumbers them on the next one. Every action result also carries resolvedTarget: the same element described by role+name, testId, label, placeholder, text or selector, which is what still resolves after a re-render and is safe to persist. client.browserFlows rejects a step whose target is a bare ref.

Browser Profiles ​

Browser profiles are reusable parent containers. They hold the default session config, artifact bucket, and metadata used by browser sessions and by a Browser MCP server that publishes the profile.

client.browsers.create(input) ​

Create a browser profile.

ts
const browser = await client.browsers.create({
  name: 'research-browser',
  defaultSessionConfig: {
    headless: true,
    viewport: { width: 1440, height: 900 },
    idleTimeoutMs: 120000,
  },
});

client.browsers.list(query?) ​

List browser profiles. Supports status filtering.

client.browsers.get(idOrKey) ​

Fetch one browser profile by id or key.

client.browsers.update(idOrKey, input) ​

Update browser profile metadata, defaults, or status.

client.browsers.delete(idOrKey) ​

Delete a browser profile.

client.browsers.setProfile(idOrKey, storageState, fileName?) ​

Attach a signed-in profile so every session starts authenticated, instead of replaying credentials through a login form on each run. Pass a Playwright storageState export — from context.storageState(), or from browserSessions.exportProfile() after driving a login once by hand. It is encrypted server-side and never readable back; only the summary returned here is.

ts
const state = JSON.parse(await fs.readFile('profile.json', 'utf8'));
const profile = await client.browsers.setProfile('research-browser', state, 'profile.json');
console.log(profile.cookieCount, profile.origins);

client.browsers.clearProfile(idOrKey) ​

Remove the attached signed-in profile.

Browser Sessions ​

Browser sessions are the direct automation surface. You create a session under a browser profile, drive it with discrete actions, and optionally persist screenshots or PDFs.

client.browserSessions.create(input) ​

ts
const session = await client.browserSessions.create({
  browserId: browser.id,
  name: 'akbank-research',
});

client.browserSessions.action(sessionKey, action) ​

ts
await client.browserSessions.action(session.sessionKey, {
  type: 'goto',
  url: 'https://www.akbank.com',
  waitUntil: 'networkidle',
});

Supported action shapes include:

  • goto, click, hover, type, press
  • select, check, upload, drag
  • scroll, wait (supports text and loadState conditions)
  • tab, back, forward, reload

client.browserSessions.snapshot(sessionKey) ​

Capture the current aria snapshot.

ts
const snapshot = await client.browserSessions.snapshot(session.sessionKey);
console.log(snapshot.ariaSnapshot);

client.browserSessions.extract(sessionKey, input) ​

Extract text, HTML, or attributes from the current page.

ts
const headings = await client.browserSessions.extract(session.sessionKey, {
  selector: 'h1',
  mode: 'text',
  multiple: true,
});

client.browserSessions.find(sessionKey, text, options?) ​

Locate visible text and get back a durable target for each hit — cheaper than another snapshot when you already know what you're looking for, and safe to save into a flow step.

ts
const hits = await client.browserSessions.find(session.sessionKey, 'Sign in', { limit: 5 });

client.browserSessions.diagnostics(sessionKey) ​

Console messages, failed requests and the last dialog this session saw — use it when an action succeeded but the page didn't do what you expected.

client.browserSessions.exportProfile(sessionKey) ​

Export this session's cookies and origin storage as a Playwright storageState, ready to hand to browsers.setProfile().

ts
const state = await client.browserSessions.exportProfile(session.sessionKey);
await client.browsers.setProfile(browser.id, state);

client.browserSessions.screenshot(sessionKey, input?) ​

Persist a screenshot artifact and get back its file reference. With { inline: true } the image also comes back as a base64 content block (BrowserScreenshotInlineResult: content and structured, plus artifact/eventId when it was saved); persist: false skips saving it.

ts
const shot = await client.browserSessions.screenshot(session.sessionKey, { inline: true, persist: false });
const image = shot.content.find((block) => block.type === 'image'); // { type: 'image', mimeType, data, width, height }

client.browserSessions.screenshotLive(sessionKey, query?) ​

Fetch raw image bytes without persistence.

client.browserSessions.pdf(sessionKey, input?) ​

Export the page as a persisted PDF artifact.

client.browserSessions.list(query?) ​

List browser sessions. Supports status and browserId filters.

client.browserSessions.get(sessionId) ​

Fetch one session by id.

client.browserSessions.listEvents(sessionId, query?) ​

Read the stored event trail for a session. Supports limit and skip.

client.browserSessions.close(sessionKey) ​

Close a live session.

client.browserSessions.delete(sessionId) ​

Delete a stored session record.

Browser Flows ​

Driving a browser with a model is discovery — it reads the page, guesses, backtracks, and bills tokens for every step. A flow records that discovery once and replays it deterministically, with no model in the loop.

ts
// 1. Drive a session however you like (agent, or by hand).
const session = await client.browserSessions.create({ browserId });
await client.browserSessions.action(session.sessionKey, { type: 'goto', url });
// …

// 2. Freeze it into a flow. Typed values become declared inputs —
//    the recorder cannot tell a search term from a password, so every
//    typed value is promoted rather than baked in as a literal.
const flow = await client.browserFlows.record({
  sessionId: session.id,
  name: 'Submit expense',
  status: 'active',
});

// 3. Replay it with different values, any number of times.
const run = await client.browserFlows.run(flow.key, {
  inputs: { reference: 'EXP-2002', amount: '999' },
});
console.log(run.status, run.outputs);

A failed run still resolves — inspect run.status, run.failedStepIndex and run.stepResults to see which step broke and why, rather than catching an exception.

client.browserFlows.create(input) / update(idOrKey, input) / delete(idOrKey) ​

Manage a flow's steps and metadata directly, without recording.

client.browserFlows.list(query?) / get(idOrKey) ​

List flows (filterable by status, browserId, search) or fetch one.

client.browserFlows.record(input) ​

Turn a driven session's action log into a replayable flow. Volatile ref targets are substituted for durable ones.

client.browserFlows.run(idOrKey, input?) ​

Run a flow and wait for the result.

client.browserFlows.listRuns(query?) / getRun(runId) ​

Run history, filterable by flowId and status.

Browser MCP ​

A browser is published to MCP clients from the Console's MCP module: MCP Servers → New MCP server → Internal service → Browser (see Browser over MCP). The server gets what every MCP server has (endpoints, tool toggles, guardrails, logs, hubs) except a public URL: a browser server is always called with an API token. Its tool list is derived from the same definitions the Browser Use system tool binds, plus browser_open_session. Talk to it with client.mcp.server(serverKey) (see MCP API):

ts
const browserMcp = client.mcp.server('research-browser-mcp');

const { sessionKey } = JSON.parse(
  (await browserMcp.callTool('browser_open_session', {})).content[0].text,
);
await browserMcp.callTool('browser_navigate', { sessionKey, url: 'https://example.com' });

browser_open_session returns a sessionKey; every page tool takes it. A session is driven only through the MCP server that opened it. The per-browser endpoint (/browser/:browserKey/mcp/*) and client.browserMcp were removed in 4.0.0.

Migration Note ​

If you previously depended on the removed browser agent management API:

  1. Use client.browserSessions for direct programmatic browser automation.
  2. Use client.browserFlows once a task has been driven once and should run unattended afterwards.
  3. Publish the browser as a Browser MCP server (Console MCP module) when another MCP-compatible runtime should drive it.
  4. Use Console-managed agents plus the Browser Use system tool when you want a hosted agent to browse autonomously.

Studio · Pulse · Console · Agent SDK and more — the Cognipeer documentation hub