Run Task
Tasks
Run Task
Run a scripted sequence of browser actions (navigate, click, type, scroll, evaluate, upload, authenticate, etc.) and optionally return a screenshot, PDF, or page content in the same response.
POST
Run Task
Overview
The task runner is the workhorse of the Browser Session API. A single request can:- Navigate to a
url(optional) - Execute a sequential list of
actionsagainst the active page - Capture output artifacts —
screenshot,pdf, and/orcontent— at the end
Path Parameters
Browser session ID (UUID).
Body
Optional URL to navigate to before running
actions.Wait condition for the initial navigation. One of
domcontentloaded, load, networkidle.Sequential list of actions to execute. See Action schema below.
When present, a screenshot is taken after all actions complete. Supports
{ fullPage?: boolean, selector?: string }.When present, renders a PDF after all actions complete. Accepts the same options as
POST /browser/sessions/{id}/pdf (format, landscape, margin, etc.). Returned base64-encoded.When true, returns
{ html, url } of the final page in the response.Action schema
Every action has atype field. The remaining fields depend on the type.
| Type | Required fields | Optional fields |
|---|---|---|
navigate | url | waitUntil |
click | selector or coordinates | — |
type | selector, text | — |
press | key | selector |
scroll | one of selector / coordinates / text | — |
wait | selector or text | — |
evaluate | script | — |
screenshot | — | selector |
uploadFile | selector, filename | — |
authenticate | mode + matching fields | credentialId, selectors, success, pauseTimeoutMs |
select | selector, text | — |
hover | selector | — |
For
uploadFile: must match a filename previously uploaded via POST /browser/sessions/{id}/files.For
authenticate when mode is vault or vault_then_prompt: UUID of a credential from POST /browser/credentials. Never pass raw username/password.For
authenticate: one of vault, prompt_user, vault_then_prompt.For
authenticate: { username, password, submit?, totp? } — CSS selectors pointing at each login form field.For
authenticate: how to detect login success. { condition: "url" | "selector" | "text" | "networkIdle", value: string, timeoutMs?: integer }.For
authenticate with mode: prompt_user: max time to wait for the end-user to complete login via the live view.Example Request
Response
Success Response (201)
Effective URL of the active tab after all actions.
Base64-encoded PNG, present when the request included
screenshot.Base64-encoded PDF bytes, present when the request included
pdf.{ html, url }, present when the request had content: true.One entry per action, in order. Shape depends on the action type (e.g.
evaluate returns { value }, authenticate returns { success, reason }).Error Responses
| Status | Description |
|---|---|
400 | Invalid body — unknown action type, missing required fields for an action, or conflicting parameters. |
401 | Unauthorized — invalid or missing API key. |
404 | Session not found, or a selector inside an action matched nothing. |
408 | An action timed out (e.g. wait selector did not appear, authenticate success condition not met). |
422 | Action failed semantically (e.g. authenticate with mode: vault and domain_mismatch). |
503 | The browser session is temporarily unreachable. |
Notes
- Actions run sequentially. Order matters — put
waitbetween flaky interactions. screenshot,pdf, andcontentare all independent and can be combined in a single task.- For long-running login flows, prefer
authenticateover scriptedtype/clickpairs — it handles common anti-bot consent banners and supports vault-stored credentials. filenameinuploadFilemust be uploaded first viaPOST /browser/sessions/{id}/files.