{"type":"post","id":"run-custom-scripts-in-browser-run-with-script-ed03b3","slug":"run-custom-scripts-in-browser-run-with-script-ed03b3","title":"Run custom scripts in Browser Run with /script","description":"Send a JavaScript function using Playwright, Puppeteer, or the Chrome DevTools Protocol in a single API request; Browser Run executes it in an isolated Worker connected to a browser session.","retrieval_nugget":"Send a JavaScript function using Playwright, Puppeteer, or the Chrome DevTools Protocol in a single API request; Browser Run executes it in an isolated Worker connected to a browser session.","published_at":"2026-11-27","updated_at":"2026-11-27","record_date":"2026-11-27","date_kind":"published_at","topics":["automation","developer-tools","sandbox"],"entities":["Cloudflare","Browser Run","Kitesurf","Playwright","Puppeteer"],"related_patterns":["agent-protocols-become-interoperability-layer"],"novelty_label":"new_fact","what_changed":"Cloudflare adds a /script API to Browser Run, letting developers execute Playwright, Puppeteer, or CDP automation in an isolated Worker and optionally run CDP scripts on Kitesurf.","prior_refs":[],"source_url":"https://developers.cloudflare.com/changelog/post/2026-11-20-script-endpoint","source_urls":["https://developers.cloudflare.com/changelog/post/2026-11-20-script-endpoint"],"production":{"schema":"newruntime-production-v1","desk":"newsroom","first_seen_at":"2026-11-27T19:21:52.129Z","independent_sources":1,"notes_synthesized":null,"writer_model":"gpt-6-luna","critic":null,"checks":["primary_source_verified","source_fresh","one_story","copy_contract"],"novelty":{"label":"new_fact","confidence":"medium"},"editorial_value":"high","human_review":"selective"},"citations":[{"claim":"","quotes":["View RSS feeds Subscribe to … the new /script endpoints .","Cloudflare added Browser Run endpoints that execute a JavaScript function in an isolated Worker connected to a browser session, without requiring users to deploy their own Worker."],"cite_url":"https://developers.cloudflare.com/changelog/post/2026-11-20-script-endpoint#:~:text=View%20RSS%20feeds%20Subscribe%20to,the%20new%20%2Fscript%20endpoints%20.&text=Cloudflare%20added%20Browser%20Run%20endpoints%20that%20execute%20a%20JavaScript%20function%20in%20an%20isolated%20Worker%20connected%20to%20a%20browser%20session%2C%20without%20requiring%20users%20to%20deploy%20their%20own%20Worker.","source_url":"https://developers.cloudflare.com/changelog/post/2026-11-20-script-endpoint","publisher":"developers.cloudflare.com"},{"claim":"","quotes":["The session and page are returned in the cf-browser-session-id and cf-browser-target-id response headers (except Kitesurf runs)."],"cite_url":"https://developers.cloudflare.com/changelog/post/2026-11-20-script-endpoint#:~:text=The%20session%20and%20page%20are%20returned%20in%20the%20cf%2Dbrowser%2Dsession%2Did%20and%20cf%2Dbrowser%2Dtarget%2Did%20response%20headers%20%28except%20Kitesurf%20runs%29.","source_url":"https://developers.cloudflare.com/changelog/post/2026-11-20-script-endpoint","publisher":"developers.cloudflare.com"},{"claim":"Set keepalive, recording, and lab as query-string launch options.","quotes":["POST /script/ runs follow-up scripts in a session you already hold, from /script or from POST /devtools/browser .","Pass targetId to attach to a specific page, or create extra pages to run scripts concurrently in one session."],"cite_url":"https://developers.cloudflare.com/changelog/post/2026-11-20-script-endpoint#:~:text=POST%20%2Fscript%2F%20runs%20follow%2Dup%20scripts%20in%20a%20session%20you%20already%20hold%2C%20from%20%2Fscript%20or%20from%20POST%20%2Fdevtools%2Fbrowser%20.&text=Pass%20targetId%20to%20attach%20to%20a%20specific%20page%2C%20or%20create%20extra%20pages%20to%20run%20scripts%20concurrently%20in%20one%20session.","source_url":"https://developers.cloudflare.com/changelog/post/2026-11-20-script-endpoint","publisher":"developers.cloudflare.com"},{"claim":"","quotes":["Session launch options ( keep_alive , recording , lab ) go in the /script query string."],"cite_url":"https://developers.cloudflare.com/changelog/post/2026-11-20-script-endpoint#:~:text=Session%20launch%20options%20%28%20keep_alive%20%2C%20recording%20%2C%20lab%20%29%20go%20in%20the%20%2Fscript%20query%20string.","source_url":"https://developers.cloudflare.com/changelog/post/2026-11-20-script-endpoint","publisher":"developers.cloudflare.com"},{"claim":"Script Studio in the Cloudflare dashboard also lets you write and run scripts against a live browser without a token.","quotes":["From a Worker, call the same endpoints through the browser binding with env.BROWSER.script() , without an API token."],"cite_url":"https://developers.cloudflare.com/changelog/post/2026-11-20-script-endpoint#:~:text=From%20a%20Worker%2C%20call%20the%20same%20endpoints%20through%20the%20browser%20binding%20with%20env.BROWSER.script%28%29%20%2C%20without%20an%20API%20token.","source_url":"https://developers.cloudflare.com/changelog/post/2026-11-20-script-endpoint","publisher":"developers.cloudflare.com"},{"claim":"","quotes":["From the Cloudflare dashboard, write and run scripts against a live browser in Script Studio , without an API token."],"cite_url":"https://developers.cloudflare.com/changelog/post/2026-11-20-script-endpoint#:~:text=From%20the%20Cloudflare%20dashboard%2C%20write%20and%20run%20scripts%20against%20a%20live%20browser%20in%20Script%20Studio%20%2C%20without%20an%20API%20token.","source_url":"https://developers.cloudflare.com/changelog/post/2026-11-20-script-endpoint","publisher":"developers.cloudflare.com"},{"claim":"Kitesurf runs are the exception to the session and page response headers, so do not depend on those headers to identify the run there.","quotes":["Neither endpoint closes the session after your script runs."],"cite_url":"https://developers.cloudflare.com/changelog/post/2026-11-20-script-endpoint#:~:text=Neither%20endpoint%20closes%20the%20session%20after%20your%20script%20runs.","source_url":"https://developers.cloudflare.com/changelog/post/2026-11-20-script-endpoint","publisher":"developers.cloudflare.com"},{"claim":"A session left open ends only at its idle timeout.","quotes":["The session and page are returned in the cf-browser-session-id and cf-browser-target-id response headers (except Kitesurf runs)."],"cite_url":"https://developers.cloudflare.com/changelog/post/2026-11-20-script-endpoint#:~:text=The%20session%20and%20page%20are%20returned%20in%20the%20cf%2Dbrowser%2Dsession%2Did%20and%20cf%2Dbrowser%2Dtarget%2Did%20response%20headers%20%28except%20Kitesurf%20runs%29.","source_url":"https://developers.cloudflare.com/changelog/post/2026-11-20-script-endpoint","publisher":"developers.cloudflare.com"},{"claim":"","quotes":["Otherwise, it ends at its idle timeout."],"cite_url":"https://developers.cloudflare.com/changelog/post/2026-11-20-script-endpoint#:~:text=Otherwise%2C%20it%20ends%20at%20its%20idle%20timeout.","source_url":"https://developers.cloudflare.com/changelog/post/2026-11-20-script-endpoint","publisher":"developers.cloudflare.com"},{"claim":"Close the session when done with DELETE /devtools/browser/<sessionId> or browser.close().","quotes":["Session launch options ( keep_alive , recording , lab ) go in the /script query string. Use browser=kitesurf to run a CDP script on Kitesurf ."],"cite_url":"https://developers.cloudflare.com/changelog/post/2026-11-20-script-endpoint#:~:text=Session%20launch%20options%20%28%20keep_alive%20%2C%20recording%20%2C%20lab%20%29%20go%20in%20the%20%2Fscript%20query%20string.%20Use%20browser%3Dkitesurf%20to%20run%20a%20CDP%20script%20on%20Kitesurf%20.","source_url":"https://developers.cloudflare.com/changelog/post/2026-11-20-script-endpoint","publisher":"developers.cloudflare.com"},{"claim":"","quotes":["Neither endpoint closes the session after your script runs. Close it with DELETE /devtools/browser/ or browser.close() ."],"cite_url":"https://developers.cloudflare.com/changelog/post/2026-11-20-script-endpoint#:~:text=Neither%20endpoint%20closes%20the%20session%20after%20your%20script%20runs.%20Close%20it%20with%20DELETE%20%2Fdevtools%2Fbrowser%2F%20or%20browser.close%28%29%20.","source_url":"https://developers.cloudflare.com/changelog/post/2026-11-20-script-endpoint","publisher":"developers.cloudflare.com"}],"schema_version":"newruntime-agent-readable-v0.2","stable_id":"post:run-custom-scripts-in-browser-run-with-script-ed03b3","status":"published","visuals":[],"editor":{"role":"editor","name":"Andrey Reshetnikov","profile":"https://newruntime.com/owner-profile.md","profile_json":"https://newruntime.com/owner-profile.json","same_as":["https://www.linkedin.com/in/reshetnikov1/","https://t.me/lapetuse"]},"routes":{"html":"https://newruntime.com/posts/run-custom-scripts-in-browser-run-with-script-ed03b3/","markdown":"https://newruntime.com/posts/run-custom-scripts-in-browser-run-with-script-ed03b3.md","json":"https://newruntime.com/posts/run-custom-scripts-in-browser-run-with-script-ed03b3.json"},"markdown_url":"https://newruntime.com/posts/run-custom-scripts-in-browser-run-with-script-ed03b3.md","next_reads":[{"type":"topic","path":"/topics/automation/","url":"https://newruntime.com/topics/automation/","title":"Automation","reason":"Explore the automation topic hub.","media_type":"text/html","markdown_url":"https://newruntime.com/topics/automation.md","json_url":"https://newruntime.com/topics/automation.json"},{"type":"topic","path":"/topics/developer-tools/","url":"https://newruntime.com/topics/developer-tools/","title":"Developer Tools","reason":"Explore the developer-tools topic hub.","media_type":"text/html","markdown_url":"https://newruntime.com/topics/developer-tools.md","json_url":"https://newruntime.com/topics/developer-tools.json"},{"type":"topic","path":"/topics/sandbox/","url":"https://newruntime.com/topics/sandbox/","title":"Sandbox","reason":"Explore the sandbox topic hub.","media_type":"text/html","markdown_url":"https://newruntime.com/topics/sandbox.md","json_url":"https://newruntime.com/topics/sandbox.json"},{"type":"collection","path":"/posts/","url":"https://newruntime.com/posts/","title":"Field Notes","reason":"Open the latest editorial analysis.","media_type":"text/html","json_url":"https://newruntime.com/posts.json"},{"type":"collection","path":"/sources/","url":"https://newruntime.com/sources/","title":"Sources","reason":"See the original sources this archive cites.","media_type":"text/html"}]}
