Skip to main content
POST
Run Task

Overview

The task runner is the workhorse of the Browser Session API. A single request can:
  1. Navigate to a url (optional)
  2. Execute a sequential list of actions against the active page
  3. Capture output artifacts — screenshot, pdf, and/or content — at the end
Actions run in order. If any action fails, the task aborts and the error is returned. Use this endpoint for multi-step flows (login → search → extract) that would otherwise require multiple round trips.

Path Parameters

string
required
Browser session ID (UUID).

Body

string
Optional URL to navigate to before running actions.
string
default:"load"
Wait condition for the initial navigation. One of domcontentloaded, load, networkidle.
object[]
Sequential list of actions to execute. See Action schema below.
object
When present, a screenshot is taken after all actions complete. Supports { fullPage?: boolean, selector?: string }.
object
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.
boolean
When true, returns { html, url } of the final page in the response.

Action schema

Every action has a type field. The remaining fields depend on the type. Key per-field notes:
string
For uploadFile: must match a filename previously uploaded via POST /browser/sessions/{id}/files.
string
For authenticate when mode is vault or vault_then_prompt: UUID of a credential from POST /browser/credentials. Never pass raw username/password.
string
For authenticate: one of vault, prompt_user, vault_then_prompt.
object
For authenticate: { username, password, submit?, totp? } — CSS selectors pointing at each login form field.
object
For authenticate: how to detect login success. { condition: "url" | "selector" | "text" | "networkIdle", value: string, timeoutMs?: integer }.
integer
default:"300000"
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)

string
Effective URL of the active tab after all actions.
string
Base64-encoded PNG, present when the request included screenshot.
string
Base64-encoded PDF bytes, present when the request included pdf.
object
{ html, url }, present when the request had content: true.
object[]
One entry per action, in order. Shape depends on the action type (e.g. evaluate returns { value }, authenticate returns { success, reason }).
Example Response:

Error Responses

Notes

  • Actions run sequentially. Order matters — put wait between flaky interactions.
  • screenshot, pdf, and content are all independent and can be combined in a single task.
  • For long-running login flows, prefer authenticate over scripted type/click pairs — it handles common anti-bot consent banners and supports vault-stored credentials.
  • filename in uploadFile must be uploaded first via POST /browser/sessions/{id}/files.