What happened
POST /script acquires a browser, runs the function, and returns a JSON object with success and result. Response headers identify the session and page, except on Kitesurf runs. (developers.cloudflare.com)
For follow-up work, POST /script/<sessionId> runs another script in a held session; pass targetId to select a page, or create extra pages for concurrent scripts. (developers.cloudflare.com) Set keep_alive, recording, and lab as query-string launch options. (developers.cloudflare.com)
A Worker can call the endpoints through its browser binding with env.BROWSER.script() and no API token. (developers.cloudflare.com) Script Studio in the Cloudflare dashboard also lets you write and run scripts against a live browser without a token. (developers.cloudflare.com)
Why it matters
This makes Browser Run useful for both one-off automation and multi-step workflows: callers can start a run and submit follow-up scripts against its held session without deploying their own Worker.
Limits and uncertainty
Neither /script endpoint closes the browser session automatically. (developers.cloudflare.com) Kitesurf runs are the exception to the session and page response headers, so do not depend on those headers to identify the run there. (developers.cloudflare.com) A session left open ends only at its idle timeout. (developers.cloudflare.com)
Skill to build now
Start with the documented POST request to your account’s /browser-run/script endpoint: send a bearer API token, a JavaScript function in code, and set library to playwright. To run a CDP script on Kitesurf, add browser=kitesurf. (developers.cloudflare.com) Close the session when done with DELETE /devtools/browser/<sessionId> or browser.close(). (developers.cloudflare.com)
Reader takeaway
Use POST /script to send a Playwright, Puppeteer, or CDP function and get its result in one request. For multi-step work, reuse the returned session and target a page as needed—but close the session yourself or account for its idle timeout.