Skip to main content
web.browser manages persistent cloud browsers. Use it when you need deterministic code around a browser session, or when an agent workflow needs setup, teardown, downloads, recordings, or inspection.
const browser = await web.browser.create({
  recording: true,
  policy: { allowedDomains: ["vendor.example"] },
});

await browser.playwright.execute({
  code: `await page.goto("https://vendor.example"); return await page.title();`,
});

WebBrowserResource

interface WebBrowserResource {
  create(
    options?: BrowserCreateOptions,
    request?: { signal?: AbortSignal; idempotencyKey?: string; timeoutMs?: number }
  ): Promise<Browser>;

  get(id: BrowserId | string, request?: { signal?: AbortSignal }): Promise<Browser>;

  list(options?: BrowserListOptions): Promise<BrowserListResponse>;

  connect(id: BrowserId | string): Promise<Browser>;
}
MethodDescription
createCreate a new browser.
getFetch browser metadata and return a browser handle.
listList browsers with pagination and filters.
connectReturn a browser handle for an existing browser.

BrowserCreateOptions

FieldTypeDefaultDescription
proxystringNoneProxy URL for browser traffic, for example http://user:pass@proxy.example:8080. Blank values are omitted by the SDK.
maxDurationnumber86400000Maximum browser duration in milliseconds.
recordingbooleanfalseEnables recording for the browser.
policyBrowserNavigationPolicyClient-level policy, if configuredBrowser navigation and operation-control policy.

BrowserListOptions

FieldTypeDescription
statusBrowserStatus | BrowserStatus[]Filter by lifecycle status.
limitnumberResults per page.
cursorstringPagination cursor.
createdAfterstringISO timestamp lower bound.
createdBeforestringISO timestamp upper bound.
signalAbortSignalAbort the request.
BrowserListResponse contains items, limit, hasMore, and nextCursor.

Browser

interface Browser {
  readonly id: BrowserId;
  readonly lifecycleStatus?: BrowserStatus;
  readonly readiness?: unknown;
  readonly capabilities?: BrowserCapabilityAvailability;
  readonly metadata?: Record<string, string>;
  readonly createdAt?: string;
  readonly updatedAt?: string;
  readonly stoppedAt?: string;
  readonly retentionExpiresAt?: string;
  readonly recording?: unknown;
  readonly errorMessage?: string | null;

  playwright: BrowserPlaywright;
  files: BrowserFiles;
  downloads: BrowserDownloads;
  dialogs: BrowserDialogs;
  permissions: BrowserPermissions;
  recordings: BrowserRecordings;
  captcha: BrowserCaptcha;

  status(options?: BrowserStatusOptions): Promise<BrowserStatusResponse>;
  events(options?: BrowserEventsOptions): Promise<ListBrowserEventsResponse>;
  streamEvents(options?: BrowserEventStreamOptions): AsyncIterable<BrowserEvent>;
  pages(options?: { cursor?: string; limit?: number; signal?: AbortSignal }): Promise<BrowserPageSummary[]>;
  cdpUrl(): Promise<string>;
  debugUrl(): Promise<string>;
  stop(options?: { signal?: AbortSignal; idempotencyKey?: string }): Promise<BrowserLifecycleResponse>;
  resume(options?: { signal?: AbortSignal; idempotencyKey?: string }): Promise<BrowserLifecycleResponse>;
  close(options?: { signal?: AbortSignal; idempotencyKey?: string }): Promise<BrowserLifecycleResponse>;
}

Lifecycle methods

MethodDescription
browser.status()Fetch compact runtime status: active tab, tabs, cookies, last action, blockers, and next action metadata.
browser.pages()List page summaries with id, browserId, url, title, and active.
browser.stop()Stop the browser while retaining recoverable state.
browser.resume()Resume a stopped browser.
browser.close()Close the browser.
Lifecycle responses include browser metadata and may include _meta:
FieldDescription
_meta.poolHitWhether a warm-pool browser was used.
_meta.creationMsGateway-level creation time in milliseconds.

Signed capability URLs

MethodDescription
browser.cdpUrl()Mint a signed Chrome DevTools Protocol WebSocket URL.
browser.debugUrl()Mint a signed Debug UI URL.
CDP and Debug UI URLs are bearer capabilities. Treat them like credentials until they expire.

Playwright execution

const result = await browser.playwright.execute({
  code: `
    await page.goto("https://example.com");
    return await page.title();
  `,
  timeoutMs: 30_000,
  capture: {
    status: true,
    screenshot: "on_error",
    observation: {
      kind: "aria",
      depth: 5,
      maxChars: 20_000,
    },
  },
});
interface BrowserPlaywright {
  execute(
    request: BrowserPlaywrightExecuteRequest,
    options?: { signal?: AbortSignal }
  ): Promise<BrowserPlaywrightExecuteResponse>;
}
Important execution rules:
RuleReason
page is already in scope.Snippets should use the active page instead of creating ordinary extra pages.
Return values must be serializable.The response includes the returned value in result.
Omit pageId for active-page work.pageId is for a known non-active page returned by Webcompute metadata.
Use bounded timeouts.Long browser operations should be explicit and observable.
Common request fields:
FieldTypeDescription
codestringTop-level async Playwright code body. Required.
pageIdPageIdOptional target page ID.
timeoutMsnumberExecution timeout in milliseconds.
capturefalse | objectCapture controls.
Common response fields:
FieldDescription
executionIdExecution identifier.
successWhether the code completed successfully.
resultSerialized return value when present.
errorStructured error when execution failed.
logsConsole logs captured during execution.
pageCurrent page metadata.
statusCompact runtime status when requested.
observationBounded page observation when requested.
artifactsScreenshot, recording, or generated-file metadata when produced.
elapsedMsBrowser-side elapsed time.

Capture options

FieldTypeDescription
screenshot"never" | "on_error" | "always"Screenshot capture behavior.
statusbooleanInclude compact runtime status.
activityboolean | objectInclude passive page/navigation activity. Object fields include maxPages and maxNavigationsPerPage.
observationboolean | objectInclude bounded post-step observation.
Observation object fields:
FieldDescription
enabledEnable or disable observation.
kindObservation kind: aria, text, or none.
locatorOptional locator to scope observation.
depthARIA observation depth.
boxesInclude element boxes when supported.
timeoutMsObservation timeout.
maxCharsMaximum returned observation characters.
includeOnControls when observation is included.