Skip to main content
POST
Execute JavaScript in the persistent Browser REPL

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Headers

Idempotency-Key
string

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.

Required string length: 1 - 255

Path Parameters

id_or_name
string
required

Browser session ID or name

Body

application/json

Request to execute code in the persistent Browser REPL.

code
string
required

JavaScript evaluated in a persistent Node.js runtime. Top-level bindings persist until the browser VM's API process exits, the REPL is reset, or the REPL is terminated after a crash or timeout. Static top-level imports are unsupported; use dynamic import(). Expression values are ignored; emit output with repl.write(...), console methods, or repl.emitImage(...). May be empty only when reset is true.

reset
boolean
default:false

Terminate the current REPL, start a fresh one, and then evaluate code.

timeout_sec
integer
default:60

Maximum execution time in seconds. Default is 60.

Required range: 1 <= x <= 300

Response

Code executed with either a successful result or a structured JavaScript failure.

Result of Browser REPL code execution.

repl_id
string
required

CUID2 identifying the exact state-holding REPL process used for this execution. Stable across calls and Chromium reconnects; changes after an API restart, explicit reset, execution timeout, or REPL crash.

success
boolean
required

Whether the code executed successfully.

content
object[]

Optional ordered text/image output produced by the execution.

Ordered discriminated union of Browser REPL output items.

content_truncated
boolean

True if text or image output was dropped or truncated due to response limits.

duration_ms
integer

Wall-clock execution time in milliseconds.

error
string

Error message if execution failed.

repl_terminated
boolean

True if the REPL identified by repl_id was terminated by this request. The next request lazily starts a fresh REPL with a new repl_id.

stack
string

Stack trace if execution failed.