> ## Documentation Index
> Fetch the complete documentation index at: https://docs-preview.webcompute.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Execute browser-control code

> Runs the current Playwright-backed browser-control API against a ready managed browser. Use this when deterministic browser control is the right tool.



## OpenAPI

````yaml /openapi/webcompute.json post /v1/browsers/{id}/playwright/execute
openapi: 3.0.0
info:
  title: Webcompute API
  description: >-
    Public Webcompute REST API for managed browsers, browser-control execution,
    resources, quick actions, and health checks.
  version: 0.1.0
servers:
  - url: https://api.webcompute.dev
    description: Webcompute production API
security:
  - bearer: []
tags:
  - name: Health
    description: Public liveness and readiness checks.
  - name: Browsers
    description: >-
      Managed browser lifecycle, browser control, status, blockers, and
      resources.
  - name: Quick Actions
    description: Ephemeral browser actions for scrape, screenshot, and PDF generation.
paths:
  /v1/browsers/{id}/playwright/execute:
    post:
      tags:
        - Browsers
      summary: Execute browser-control code
      description: >-
        Runs the current Playwright-backed browser-control API against a ready
        managed browser. Use this when deterministic browser control is the
        right tool.
      operationId: executeBrowserControl
      parameters:
        - name: id
          required: true
          in: path
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PlaywrightExecuteDto'
      responses:
        '200':
          description: Browser-control execution completed.
        '409':
          description: Browser not ready
      security:
        - bearer: []
components:
  schemas:
    PlaywrightExecuteDto:
      type: object
      properties:
        code:
          type: string
          description: >-
            Top-level async Playwright code body. page, context, browser, files,
            and artifacts are in scope. Maximum 262144 UTF-8 bytes.
        pageId:
          type: object
          description: Optional canonical page id such as page_tab-1.
        timeoutMs:
          type: integer
          minimum: 1
          maximum: 120000
          default: 30000
          description: Execution timeout in milliseconds.
        capture:
          oneOf:
            - type: boolean
              enum:
                - false
            - type: object
              additionalProperties: false
              properties:
                screenshot:
                  type: string
                  enum:
                    - never
                    - on_error
                    - always
                status:
                  type: boolean
                observation:
                  anyOf:
                    - type: boolean
                    - type: object
                      additionalProperties: false
                      properties:
                        enabled:
                          type: boolean
                        kind:
                          type: string
                          enum:
                            - aria
                            - text
                            - none
                        locator:
                          type: string
                          minLength: 1
                          maxLength: 2000
                        depth:
                          type: integer
                          minimum: 1
                          maximum: 8
                        boxes:
                          type: boolean
                        timeoutMs:
                          type: integer
                          minimum: 1
                          maximum: 10000
                        maxChars:
                          type: integer
                          minimum: 1
                          maximum: 50000
                        includeOn:
                          type: string
                          enum:
                            - always
                            - success
                            - error
                            - blocker
                activity:
                  anyOf:
                    - type: boolean
                    - type: object
                      additionalProperties: false
                      properties:
                        maxPages:
                          type: integer
                          minimum: 1
                          maximum: 50
                        maxNavigationsPerPage:
                          type: integer
                          minimum: 1
                          maximum: 20
          description: >-
            Set false to disable all automatic post-step capture, or pass an
            object to customize screenshot, status, observation, and activity
            capture.
        variables:
          type: object
          additionalProperties:
            type: string
            maxLength: 16384
          maxProperties: 50
          description: >-
            Bounded string variables made available to Playwright code through
            the variables global. Runtime validation enforces the UTF-8 byte
            limit.
        variableScopes:
          type: object
          additionalProperties:
            type: object
            additionalProperties: false
            properties:
              active:
                type: boolean
              allowedDomains:
                type: array
                items:
                  type: string
                  maxLength: 255
                  pattern: ^[A-Za-z0-9_.-]+\.?$
                maxItems: 20
          maxProperties: 50
          description: >-
            Bounded variable scope metadata for provided or policy-only
            variables.
      required:
        - code
  securitySchemes:
    bearer:
      scheme: bearer
      bearerFormat: API key
      type: http

````