# Devtools # Session ## List sessions. `client.browserRendering.devtools.session.list(SessionListParamsparams, RequestOptionsoptions?): SessionListResponse` **get** `/accounts/{account_id}/browser-rendering/devtools/session` List active browser sessions. ### Parameters - `params: SessionListParams` - `account_id: string` Path param: Account ID. - `limit?: number` Query param - `offset?: number` Query param ### Returns - `SessionListResponse = Array` - `sessionId: string` Session ID. - `closeReason?: string` Reason for session closure. - `closeReasonText?: string` Human-readable close reason. - `connectionEndTime?: number` Connection end time. - `connectionId?: string` Connection ID. - `connectionStartTime?: number` Connection start time. - `devtoolsFrontendUrl?: string` DevTools frontend URL. - `endTime?: number` Session end time. - `lastUpdated?: number` Last updated timestamp. - `startTime?: number` Session start time. - `webSocketDebuggerUrl?: string` WebSocket URL for debugging this target. ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const sessions = await client.browserRendering.devtools.session.list({ account_id: 'account_id' }); console.log(sessions); ``` #### Response ```json [ { "sessionId": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "closeReason": "closeReason", "closeReasonText": "closeReasonText", "connectionEndTime": 0, "connectionId": "connectionId", "connectionStartTime": 0, "devtoolsFrontendUrl": "devtoolsFrontendUrl", "endTime": 0, "lastUpdated": 0, "startTime": 0, "webSocketDebuggerUrl": "webSocketDebuggerUrl" } ] ``` ## Get session details. `client.browserRendering.devtools.session.get(stringsessionId, SessionGetParamsparams, RequestOptionsoptions?): SessionGetResponse | null` **get** `/accounts/{account_id}/browser-rendering/devtools/session/{session_id}` Get details for a specific browser session. ### Parameters - `sessionId: string` Session ID. - `params: SessionGetParams` - `account_id: string` Account ID. ### Returns - `SessionGetResponse` - `sessionId: string` Session ID. - `closeReason?: string` Reason for session closure. - `closeReasonText?: string` Human-readable close reason. - `connectionEndTime?: number` Connection end time. - `connectionId?: string` Connection ID. - `connectionStartTime?: number` Connection start time. - `devtoolsFrontendUrl?: string` DevTools frontend URL. - `endTime?: number` Session end time. - `lastUpdated?: number` Last updated timestamp. - `startTime?: number` Session start time. - `webSocketDebuggerUrl?: string` WebSocket URL for debugging this target. ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const session = await client.browserRendering.devtools.session.get( '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { account_id: 'account_id' }, ); console.log(session.sessionId); ``` #### Response ```json { "sessionId": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "closeReason": "closeReason", "closeReasonText": "closeReasonText", "connectionEndTime": 0, "connectionId": "connectionId", "connectionStartTime": 0, "devtoolsFrontendUrl": "devtoolsFrontendUrl", "endTime": 0, "lastUpdated": 0, "startTime": 0, "webSocketDebuggerUrl": "webSocketDebuggerUrl" } ``` ## Domain Types ### Session List Response - `SessionListResponse = Array` - `sessionId: string` Session ID. - `closeReason?: string` Reason for session closure. - `closeReasonText?: string` Human-readable close reason. - `connectionEndTime?: number` Connection end time. - `connectionId?: string` Connection ID. - `connectionStartTime?: number` Connection start time. - `devtoolsFrontendUrl?: string` DevTools frontend URL. - `endTime?: number` Session end time. - `lastUpdated?: number` Last updated timestamp. - `startTime?: number` Session start time. - `webSocketDebuggerUrl?: string` WebSocket URL for debugging this target. ### Session Get Response - `SessionGetResponse` - `sessionId: string` Session ID. - `closeReason?: string` Reason for session closure. - `closeReasonText?: string` Human-readable close reason. - `connectionEndTime?: number` Connection end time. - `connectionId?: string` Connection ID. - `connectionStartTime?: number` Connection start time. - `devtoolsFrontendUrl?: string` DevTools frontend URL. - `endTime?: number` Session end time. - `lastUpdated?: number` Last updated timestamp. - `startTime?: number` Session start time. - `webSocketDebuggerUrl?: string` WebSocket URL for debugging this target. # Browser ## Get a browser session ID. `client.browserRendering.devtools.browser.create(BrowserCreateParamsparams, RequestOptionsoptions?): BrowserCreateResponse` **post** `/accounts/{account_id}/browser-rendering/devtools/browser` Get a browser session ID. ### Parameters - `params: BrowserCreateParams` - `account_id: string` Path param: Account ID. - `keep_alive?: number` Query param: Keep-alive time in milliseconds. - `lab?: boolean` Query param: Use experimental browser. - `recording?: boolean` Query param - `targets?: boolean` Query param: Include browser targets in response. ### Returns - `BrowserCreateResponse` - `sessionId: string` Browser session ID. - `webSocketDebuggerUrl?: string` WebSocket URL for the session. ### Example ```node 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); ``` #### Response ```json { "sessionId": "sessionId", "webSocketDebuggerUrl": "webSocketDebuggerUrl" } ``` ## Acquire and connect to browser session. `client.browserRendering.devtools.browser.launch(BrowserLaunchParamsparams, RequestOptionsoptions?): void` **get** `/accounts/{account_id}/browser-rendering/devtools/browser` Acquires and establishes a WebSocket connection to a browser session. ### Parameters - `params: BrowserLaunchParams` - `account_id: string` Path param: Account ID. - `keep_alive?: number` Query param: Keep-alive time in ms (only valid when acquiring new session). - `lab?: boolean` Query param: Use experimental browser. - `recording?: boolean` Query param ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); await client.browserRendering.devtools.browser.launch({ account_id: 'account_id' }); ``` ## Connect to browser session. `client.browserRendering.devtools.browser.connect(stringsessionId, BrowserConnectParamsparams, RequestOptionsoptions?): void` **get** `/accounts/{account_id}/browser-rendering/devtools/browser/{session_id}` Establishes a WebSocket connection to an existing browser session. ### Parameters - `sessionId: string` Browser session ID to connect to. - `params: BrowserConnectParams` - `account_id: string` Path param: Account ID. - `keep_alive?: number` Query param: Keep-alive time in ms (only valid when acquiring new session). - `lab?: boolean` Query param: Use experimental browser. - `recording?: boolean` Query param ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); await client.browserRendering.devtools.browser.connect('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { account_id: 'account_id', }); ``` ## Close browser session. `client.browserRendering.devtools.browser.delete(stringsessionId, BrowserDeleteParamsparams, RequestOptionsoptions?): BrowserDeleteResponse` **delete** `/accounts/{account_id}/browser-rendering/devtools/browser/{session_id}` Closes an existing browser session. ### Parameters - `sessionId: string` Browser session ID to close. - `params: BrowserDeleteParams` - `account_id: string` Account ID. ### Returns - `BrowserDeleteResponse` - `status: "closing" | "closed"` - `"closing"` - `"closed"` ### Example ```node 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.delete( '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { account_id: 'account_id' }, ); console.log(browser.status); ``` #### Response ```json { "status": "closing" } ``` ## Get browser version metadata. `client.browserRendering.devtools.browser.version(stringsessionId, BrowserVersionParamsparams, RequestOptionsoptions?): BrowserVersionResponse` **get** `/accounts/{account_id}/browser-rendering/devtools/browser/{session_id}/json/version` Get browser version metadata. ### Parameters - `sessionId: string` Browser session ID. - `params: BrowserVersionParams` - `account_id: string` Account ID. ### Returns - `BrowserVersionResponse` - `Browser: string` Browser name and version. - `"Protocol-Version": string` Chrome DevTools Protocol version. - `"User-Agent": string` User agent string. - `"V8-Version": string` V8 JavaScript engine version. - `"WebKit-Version": string` WebKit version. - `webSocketDebuggerUrl: string` WebSocket URL for debugging the browser. ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const response = await client.browserRendering.devtools.browser.version( '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { account_id: 'account_id' }, ); console.log(response.Browser); ``` #### Response ```json { "Browser": "Browser", "Protocol-Version": "Protocol-Version", "User-Agent": "User-Agent", "V8-Version": "V8-Version", "WebKit-Version": "WebKit-Version", "webSocketDebuggerUrl": "webSocketDebuggerUrl" } ``` ## Get Chrome DevTools Protocol schema. `client.browserRendering.devtools.browser.protocol(stringsessionId, BrowserProtocolParamsparams, RequestOptionsoptions?): BrowserProtocolResponse` **get** `/accounts/{account_id}/browser-rendering/devtools/browser/{session_id}/json/protocol` Returns the complete Chrome DevTools Protocol schema including all domains, commands, events, and types. This schema describes the entire CDP API surface. ### Parameters - `sessionId: string` Browser session ID. - `params: BrowserProtocolParams` - `account_id: string` Account ID. ### Returns - `BrowserProtocolResponse` - `domains: Array` List of protocol domains. - `domain: string` Domain name. - `commands?: Array>` Available commands. - `dependencies?: Array` Domain dependencies. - `events?: Array>` Available events. - `experimental?: boolean` Whether this domain is experimental. - `types?: Array>` Type definitions. - `version?: Version` Protocol version. - `major: string` Major version. - `minor: string` Minor version. ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const response = await client.browserRendering.devtools.browser.protocol( '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { account_id: 'account_id' }, ); console.log(response.domains); ``` #### Response ```json { "domains": [ { "domain": "domain", "commands": [ { "foo": {} } ], "dependencies": [ "string" ], "events": [ { "foo": {} } ], "experimental": true, "types": [ { "foo": {} } ] } ], "version": { "major": "major", "minor": "minor" } } ``` ## Domain Types ### Browser Create Response - `BrowserCreateResponse` - `sessionId: string` Browser session ID. - `webSocketDebuggerUrl?: string` WebSocket URL for the session. ### Browser Delete Response - `BrowserDeleteResponse` - `status: "closing" | "closed"` - `"closing"` - `"closed"` ### Browser Version Response - `BrowserVersionResponse` - `Browser: string` Browser name and version. - `"Protocol-Version": string` Chrome DevTools Protocol version. - `"User-Agent": string` User agent string. - `"V8-Version": string` V8 JavaScript engine version. - `"WebKit-Version": string` WebKit version. - `webSocketDebuggerUrl: string` WebSocket URL for debugging the browser. ### Browser Protocol Response - `BrowserProtocolResponse` - `domains: Array` List of protocol domains. - `domain: string` Domain name. - `commands?: Array>` Available commands. - `dependencies?: Array` Domain dependencies. - `events?: Array>` Available events. - `experimental?: boolean` Whether this domain is experimental. - `types?: Array>` Type definitions. - `version?: Version` Protocol version. - `major: string` Major version. - `minor: string` Minor version. # Page ## Connect to a specific Chrome DevTools page. `client.browserRendering.devtools.browser.page.get(stringsessionId, stringtargetId, PageGetParamsparams, RequestOptionsoptions?): void` **get** `/accounts/{account_id}/browser-rendering/devtools/browser/{session_id}/page/{target_id}` Establishes a WebSocket connection to a specific Chrome DevTools target or page. ### Parameters - `sessionId: string` Browser session ID. - `targetId: string` Target ID, e.g. page ID. - `params: PageGetParams` - `account_id: string` Account ID. ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); await client.browserRendering.devtools.browser.page.get( '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', 'target_id', { account_id: 'account_id' }, ); ``` # Targets ## Open a new browser tab. `client.browserRendering.devtools.browser.targets.create(stringsessionId, TargetCreateParamsparams, RequestOptionsoptions?): TargetCreateResponse` **put** `/accounts/{account_id}/browser-rendering/devtools/browser/{session_id}/json/new` Opens a new tab in the browser. Optionally specify a URL to navigate to. ### Parameters - `sessionId: string` Browser session ID. - `params: TargetCreateParams` - `account_id: string` Path param: Account ID. - `url?: string` Query param ### Returns - `TargetCreateResponse` - `id: string` Target ID. - `type: string` Target type (page, background_page, worker, etc.). - `url: string` URL of the target. - `description?: string` Target description. - `devtoolsFrontendUrl?: string` DevTools frontend URL. - `title?: string` Title of the target. - `webSocketDebuggerUrl?: string` WebSocket URL for debugging this target. ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const target = await client.browserRendering.devtools.browser.targets.create( '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { account_id: 'account_id' }, ); console.log(target.id); ``` #### Response ```json { "id": "id", "type": "type", "url": "url", "description": "description", "devtoolsFrontendUrl": "devtoolsFrontendUrl", "title": "title", "webSocketDebuggerUrl": "webSocketDebuggerUrl" } ``` ## List targets. `client.browserRendering.devtools.browser.targets.list(stringsessionId, TargetListParamsparams, RequestOptionsoptions?): TargetListResponse` **get** `/accounts/{account_id}/browser-rendering/devtools/browser/{session_id}/json/list` Returns a list of all debuggable targets including tabs, pages, service workers, and other browser contexts. ### Parameters - `sessionId: string` Browser session ID. - `params: TargetListParams` - `account_id: string` Account ID. ### Returns - `TargetListResponse = Array` - `id: string` Target ID. - `type: string` Target type (page, background_page, worker, etc.). - `url: string` URL of the target. - `description?: string` Target description. - `devtoolsFrontendUrl?: string` DevTools frontend URL. - `title?: string` Title of the target. - `webSocketDebuggerUrl?: string` WebSocket URL for debugging this target. ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const targets = await client.browserRendering.devtools.browser.targets.list( '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { account_id: 'account_id' }, ); console.log(targets); ``` #### Response ```json [ { "id": "id", "type": "type", "url": "url", "description": "description", "devtoolsFrontendUrl": "devtoolsFrontendUrl", "title": "title", "webSocketDebuggerUrl": "webSocketDebuggerUrl" } ] ``` ## Get a target by ID. `client.browserRendering.devtools.browser.targets.get(stringsessionId, stringtargetId, TargetGetParamsparams, RequestOptionsoptions?): TargetGetResponse` **get** `/accounts/{account_id}/browser-rendering/devtools/browser/{session_id}/json/list/{target_id}` Returns the debuggable target with the given ID. ### Parameters - `sessionId: string` Browser session ID. - `targetId: string` Target ID. - `params: TargetGetParams` - `account_id: string` Account ID. ### Returns - `TargetGetResponse` - `id: string` Target ID. - `type: string` Target type (page, background_page, worker, etc.). - `url: string` URL of the target. - `description?: string` Target description. - `devtoolsFrontendUrl?: string` DevTools frontend URL. - `title?: string` Title of the target. - `webSocketDebuggerUrl?: string` WebSocket URL for debugging this target. ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const target = await client.browserRendering.devtools.browser.targets.get( '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', 'target_id', { account_id: 'account_id' }, ); console.log(target.id); ``` #### Response ```json { "id": "id", "type": "type", "url": "url", "description": "description", "devtoolsFrontendUrl": "devtoolsFrontendUrl", "title": "title", "webSocketDebuggerUrl": "webSocketDebuggerUrl" } ``` ## Activate a browser target. `client.browserRendering.devtools.browser.targets.activate(stringsessionId, stringtargetId, TargetActivateParamsparams, RequestOptionsoptions?): TargetActivateResponse` **get** `/accounts/{account_id}/browser-rendering/devtools/browser/{session_id}/json/activate/{target_id}` Activates (brings to front) a specific browser target by its ID. ### Parameters - `sessionId: string` Browser session ID. - `targetId: string` Target ID to activate. - `params: TargetActivateParams` - `account_id: string` Account ID. ### Returns - `TargetActivateResponse` - `message: string` Target activated. ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const response = await client.browserRendering.devtools.browser.targets.activate( '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', 'target_id', { account_id: 'account_id' }, ); console.log(response.message); ``` #### Response ```json { "message": "message" } ``` ## Close a browser target. `client.browserRendering.devtools.browser.targets.close(stringsessionId, stringtargetId, TargetCloseParamsparams, RequestOptionsoptions?): TargetCloseResponse` **get** `/accounts/{account_id}/browser-rendering/devtools/browser/{session_id}/json/close/{target_id}` Closes a specific browser target (tab, page, etc.) by its ID. Returns 'Target is closing' on success or an error if the target is not found. ### Parameters - `sessionId: string` Browser session ID. - `targetId: string` Target ID to close. - `params: TargetCloseParams` - `account_id: string` Account ID. ### Returns - `TargetCloseResponse` - `message: string` Target is closing. ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const response = await client.browserRendering.devtools.browser.targets.close( '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', 'target_id', { account_id: 'account_id' }, ); console.log(response.message); ``` #### Response ```json { "message": "message" } ``` ## Domain Types ### Target Create Response - `TargetCreateResponse` - `id: string` Target ID. - `type: string` Target type (page, background_page, worker, etc.). - `url: string` URL of the target. - `description?: string` Target description. - `devtoolsFrontendUrl?: string` DevTools frontend URL. - `title?: string` Title of the target. - `webSocketDebuggerUrl?: string` WebSocket URL for debugging this target. ### Target List Response - `TargetListResponse = Array` - `id: string` Target ID. - `type: string` Target type (page, background_page, worker, etc.). - `url: string` URL of the target. - `description?: string` Target description. - `devtoolsFrontendUrl?: string` DevTools frontend URL. - `title?: string` Title of the target. - `webSocketDebuggerUrl?: string` WebSocket URL for debugging this target. ### Target Get Response - `TargetGetResponse` - `id: string` Target ID. - `type: string` Target type (page, background_page, worker, etc.). - `url: string` URL of the target. - `description?: string` Target description. - `devtoolsFrontendUrl?: string` DevTools frontend URL. - `title?: string` Title of the target. - `webSocketDebuggerUrl?: string` WebSocket URL for debugging this target. ### Target Activate Response - `TargetActivateResponse` - `message: string` Target activated. ### Target Close Response - `TargetCloseResponse` - `message: string` Target is closing.