November 20, 2026 · Cloudflare
Browser Run - Run custom scripts in Browser Run with /script
Browser Run now runs custom browser automation written with Playwright, Puppeteer, or the raw Chrome DevTools Protocol (CDP) in a single API request, with the new /script endpoints. Submit a JavaScript function, and Browser Run executes it in an isolated Worker connected to a browser session, so you do not need to deploy a Worker.
curl -i -X POST "https://api.cloudflare.com/client/v4/accounts/<accountId>/browser-run/script" \
-H "Authorization: Bearer <apiToken>" \
-H "Content-Type: application/json" \
-d '{
"code": "async ({ page }) => { await page.goto(\"https://example.com\"); return { title: await page.title() }; }",
"library": "playwright"
}'
HTTP/2 200
content-type: application/json
cf-browser-session-id: 8f7c2e3a-1b4d-4c6e-9a0f-2d5b7e9c1a3f
cf-browser-target-id: A1B2C3D4E5F60718293A4B5C6D7E8F90
{
"success": true,
"result": {
"title": "Example Domain"
}
}
POST /scriptacquires a browser, runs your function, and returns its result as{ "success": true, "result": ... }. The session and page are returned in thecf-browser-session-idandcf-browser-target-idresponse headers (except Kitesurf runs).POST /script/<sessionId>runs follow-up scripts in a session you already hold, from/scriptor fromPOST /devtools/browser. PasstargetIdto attach to a specific page, or create extra pages to run scripts concurrently in one session.- Session launch options (
keep_alive,recording,lab) go in the/scriptquery string. Usebrowser=kitesurfto run a CDP script on Kitesurf. - From a Worker, call the same endpoints through the browser binding with
env.BROWSER.script(), without an API token. - From the Cloudflare dashboard, write and run scripts against a live browser in Script Studio, without an API token.
- Neither endpoint closes the session after your script runs. Close it with
DELETE /devtools/browser/<sessionId>orbrowser.close(). Otherwise, it ends at its idle timeout.
For more information, refer to Custom scripts.
Free. Unsubscribe any time.
Related updates
Browser Run - Playwright for Browser Rendering now available
Browser Run - Browser Rendering adds Chrome DevTools Protocol (CDP) and MCP client support
Browser Run - Run more headless browsers concurrently with Browser Run
Browser Run - Use Browser Run Quick Actions directly from Workers
Browser Run - Playwright MCP server is now compatible with Browser Rendering