Skip to content
Start here

Get a browser session ID.

client.browserRendering.devtools.browser.create(BrowserCreateParams { account_id, keep_alive, lab, 4 more } params, RequestOptionsoptions?): BrowserCreateResponse { sessionId, webSocketDebuggerUrl }
POST/accounts/{account_id}/browser-rendering/devtools/browser

Acquires a browser and returns its session ID and websocket URL. Optionally accepts a JSON body with session guardrails to restrict outbound HTTP/S traffic.

Security
API Token

The preferred authorization scheme for interacting with the Cloudflare API. Create a token.

Example:Authorization: Bearer Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY
API Email + API Key

The previous authorization scheme for interacting with the Cloudflare API, used in conjunction with a Global API key.

Example:X-Auth-Email: user@example.com

The previous authorization scheme for interacting with the Cloudflare API. When possible, use API tokens instead of Global API keys.

Example:X-Auth-Key: 144c9defac04969c7bfad8efaa8ea194
Accepted Permissions (at least one required)
Browser Rendering Write
ParametersExpand Collapse
params: BrowserCreateParams { account_id, keep_alive, lab, 4 more }
account_id: string

Path param: Account ID.

keep_alive?: number

Query param: Keep-alive time in milliseconds.

maximum1200000
minimum10000
lab?: boolean

Query param: Use experimental browser.

liveViewUrlExpiresInMs?: number

Query param: How long the live view URL remains valid, in milliseconds (max 60 minutes). Only used when targets is true.

maximum3600000
minimum60000
recording?: boolean

Query param

targets?: boolean

Query param: Include browser targets in response.

guardrails?: Guardrails

Body param

allowedDomains?: Array<string>

Hostname patterns, max 50. Supports exact hosts (example.com) or a single * wildcard anywhere. Prefer *.example.com (subdomain wildcard) over *example.com (prefix wildcard) to avoid matching overbroad lookalikes like evilexample.com.

allowedDomainSets?: Array<string>

Max 4 entries: curated preset names (common-cdns) and/or https URLs of newline-separated hostname lists.

ReturnsExpand Collapse
BrowserCreateResponse { sessionId, webSocketDebuggerUrl }
sessionId: string

Browser session ID.

webSocketDebuggerUrl?: string

WebSocket URL for the session.

Get a browser session ID.

import Cloudflare from 'cloudflare';

const client = new Cloudflare({
  apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted
});

const browser = await client.browserRendering.devtools.browser.create({ account_id: 'account_id' });

console.log(browser.sessionId);
{
  "sessionId": "sessionId",
  "webSocketDebuggerUrl": "webSocketDebuggerUrl"
}
Returns Examples
{
  "sessionId": "sessionId",
  "webSocketDebuggerUrl": "webSocketDebuggerUrl"
}