Execute Playwright/TypeScript code against the browser
Changed onExecute arbitrary Playwright code in a fresh execution context against the browser. The code runs in the same VM as the browser, minimizing latency and maximizing throughput. It has access to 'page', 'context', 'browser', and 'webmcp' variables. Use 'webmcp.listTools()' to discover browser-wide WebMCP tools and 'webmcp.invokeTool(toolRef, input?, { timeoutSec? })' to invoke an exact registration. It can return a value, and this value is returned in the response.
Every call runs in an executor: a dedicated Node.js process with its own browser connection. Calls on different executors run concurrently; calls on the same executor run one at a time. A timeout, crash, or blocked event loop in one executor does not affect other executors. After a timeout the executor keeps its process and drops its browser connection, so code abandoned by the timeout cannot keep driving the browser. After a crash or a blocked event loop, the next call on that executor starts a fresh process.
Calls without 'executor' run in the executor named 'default', which always exists and is the same as passing 'executor: "default"'. In the default executor, 'page' is bound to an active tab reported by Chrome. In single-window sessions, this is the foreground tab. When multiple browser windows are open, Chrome reports one active tab per window and the selected window is unspecified. 'context' is the BrowserContext that owns the selected page. Use 'browser.contexts()' to select a context or page explicitly.
Pass any other name to run the call in a named executor. The first call with a new name creates it. Each named executor owns a tab: its first call opens a new background tab in the default browser context, and 'page' is bound to that tab on every later call while it stays open. Opening it does not change the active tab of an existing window. If the tab is closed, the next call opens a new one and reports 'tab.created: true'. Executor code can still reach other tabs through 'context' and 'browser'; ownership only decides what 'page' is bound to. Use named executors to drive several tabs of one browser in parallel.
A browser can have at most 8 named executors; the default executor does not count. A call that would create another returns 409 with the current executors; delete one with DELETE /browsers/{id_or_name}/playwright/executors/{name}. Named executors are not removed automatically while the browser runs; when it shuts down, they are removed and their tabs closed.
Request
- Base URLhttps://api.onkernel.com
- URLhttps://api.onkernel.com/browsers/{id_or_name}/playwright/execute
- AuthHTTP bearer
Path parameters
Browser session ID or name
Headers
Makes retrying the call safe. A call with a key already used on this browser returns the first call's response instead of running the code again, waiting for it if it is still running. A call with a key keeps running for 10 seconds after its last caller disconnects, so a retry can collect its response; after that it is cancelled like a call without a key. A response is kept for 10 minutes once the call finishes, and only the most recent responses are kept. A call rejected before the code runs, such as with 400, 409 or 429, does not use up its key. The Kernel SDKs send a key automatically and reuse it when they retry.
Request body
Example request
{
"executor": "checkout"
}Response
Code executed successfully
Changes
- info
added the new optional
headerrequest parameterIdempotency-Key - info
added the non-success response with the status
- info