Skip to main content
POST
Execute Playwright/TypeScript code against the browser

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 Playwright code

code
string
required

TypeScript/JavaScript code to execute. The code has access to 'page', 'context', and 'browser' variables. It runs within a function, so you can use a return statement at the end to return a value. This value is returned as the result property in the response. Example: "await page.goto('https://example.com'); return await page.title();"

executor
string

Name of a Playwright executor. Calls with the same name run in the same executor, one at a time; the first call with a new name creates it. Calls on different executors run concurrently. 'default' names the executor that runs calls without a name.

Pattern: ^[A-Za-z0-9_-]{1,64}$
Example:

"checkout"

timeout_sec
integer
default:60

Maximum execution time in seconds. Default is 60.

Required range: 1 <= x <= 300

Response

Code executed successfully

Result of Playwright code execution

success
boolean
required

Whether the code executed successfully

error
string

Error message if execution failed

result
any

The value returned by the code (if any)

stderr
string

Standard error from the execution

stdout
string

Standard output from the execution

tab
object

The tab 'page' was bound to for this call. Absent if the call failed before binding a tab.