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

# Run commands in a session

> Runs an ordered list of browser automation commands in an existing session and returns the per-command results. Requires scope: browser:sessions



## OpenAPI

````yaml /api-specs/services.json post /browser/v1/sessions/{id}/commands
openapi: 3.1.0
info:
  title: Voyant Cloud REST API
  version: 1.0.0
  description: >-
    Public REST API for Voyant Cloud products: Vault, SMS, Email, Verification,
    Video, Realtime, and Browser. All requests authenticate with an API token
    passed as an HTTP bearer token in the Authorization header. Each operation
    requires a specific token scope, documented in the operation description.
servers:
  - url: https://api.voyant.travel
    description: Production
security:
  - bearerAuth: []
tags:
  - name: Vault
    description: >-
      Encrypted secret storage and envelope/per-call cryptography scoped to an
      organization vault.
  - name: SMS
    description: Send SMS messages and inspect message history and phone numbers.
  - name: Email
    description: Send transactional email and inspect message history.
  - name: Verification
    description: >-
      Start and check one-time-code verifications across SMS, call, email, and
      WhatsApp.
  - name: Video
    description: >-
      Upload, manage, caption, and watermark videos, and mint signed playback
      tokens.
  - name: Realtime
    description: >-
      Publish messages to realtime channels, inspect history and presence, and
      mint short-lived subscriber tokens.
  - name: Browser
    description: >-
      Headless browser rendering, scraping, structured extraction, crawling, and
      interactive sessions.
paths:
  /browser/v1/sessions/{id}/commands:
    post:
      tags:
        - Browser
      summary: Run commands in a session
      description: >-
        Runs an ordered list of browser automation commands in an existing
        session and returns the per-command results. Requires scope:
        browser:sessions
      operationId: runBrowserSessionCommands
      parameters:
        - $ref: '#/components/parameters/BrowserSessionId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RunBrowserCommandsInput'
      responses:
        '200':
          description: Command results
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RunBrowserCommandsResult'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/TooManyRequests'
        '500':
          $ref: '#/components/responses/ServerError'
        '503':
          $ref: '#/components/responses/ServiceUnavailable'
      x-codeSamples:
        - lang: typescript
          label: SDK
          source: >-
            import { createVoyantCloudClient } from "@voyant-travel/cloud-sdk";


            const cloud = createVoyantCloudClient({ apiKey:
            process.env.VOYANT_API_KEY });


            const result = await cloud.browser.sessions.runCommands("<id>", {
              "commands": [
                {
                  "op": "goto",
                  "url": "<string>",
                  "selector": "<string>",
                  "text": "<string>",
                  "values": [
                    "<string>"
                  ],
                  "ms": 123,
                  "script": "<string>",
                  "urls": [
                    "<string>"
                  ],
                  "cookies": [
                    {
                      "name": "<string>",
                      "value": "<string>",
                      "url": "<string>",
                      "domain": "<string>",
                      "path": "<string>",
                      "expires": 123,
                      "httpOnly": true,
                      "secure": true,
                      "sameSite": "Strict"
                    }
                  ],
                  "width": 123,
                  "height": 123,
                  "deviceScaleFactor": 123,
                  "userAgent": "<string>",
                  "headers": {},
                  "options": {}
                }
              ]
            });
        - lang: bash
          label: cURL
          source: |-
            curl --request POST \
              --url https://api.voyant.travel/browser/v1/sessions/<id>/commands \
              --header 'Authorization: Bearer <token>' \
              --header 'Content-Type: application/json' \
              --data '{
              "commands": [
                {
                  "op": "goto",
                  "url": "<string>",
                  "selector": "<string>",
                  "text": "<string>",
                  "values": [
                    "<string>"
                  ],
                  "ms": 123,
                  "script": "<string>",
                  "urls": [
                    "<string>"
                  ],
                  "cookies": [
                    {
                      "name": "<string>",
                      "value": "<string>",
                      "url": "<string>",
                      "domain": "<string>",
                      "path": "<string>",
                      "expires": 123,
                      "httpOnly": true,
                      "secure": true,
                      "sameSite": "Strict"
                    }
                  ],
                  "width": 123,
                  "height": 123,
                  "deviceScaleFactor": 123,
                  "userAgent": "<string>",
                  "headers": {},
                  "options": {}
                }
              ]
            }'
        - lang: javascript
          label: Node
          source: >-
            const response = await
            fetch("https://api.voyant.travel/browser/v1/sessions/<id>/commands",
            {
              method: "POST",
              headers: {
                "Content-Type": "application/json",
                "Authorization": "Bearer <token>"
              },
              body: JSON.stringify({
                "commands": [
                  {
                    "op": "goto",
                    "url": "<string>",
                    "selector": "<string>",
                    "text": "<string>",
                    "values": [
                      "<string>"
                    ],
                    "ms": 123,
                    "script": "<string>",
                    "urls": [
                      "<string>"
                    ],
                    "cookies": [
                      {
                        "name": "<string>",
                        "value": "<string>",
                        "url": "<string>",
                        "domain": "<string>",
                        "path": "<string>",
                        "expires": 123,
                        "httpOnly": true,
                        "secure": true,
                        "sameSite": "Strict"
                      }
                    ],
                    "width": 123,
                    "height": 123,
                    "deviceScaleFactor": 123,
                    "userAgent": "<string>",
                    "headers": {},
                    "options": {}
                  }
                ]
              }),
            });


            const data = await response.json();
        - lang: python
          label: Python
          source: |-
            import requests

            response = requests.post(
                "https://api.voyant.travel/browser/v1/sessions/<id>/commands",
                headers={
                    "Authorization": "Bearer <token>"
                },
                json={
                    "commands": [
                        {
                            "op": "goto",
                            "url": "<string>",
                            "selector": "<string>",
                            "text": "<string>",
                            "values": [
                                "<string>"
                            ],
                            "ms": 123,
                            "script": "<string>",
                            "urls": [
                                "<string>"
                            ],
                            "cookies": [
                                {
                                    "name": "<string>",
                                    "value": "<string>",
                                    "url": "<string>",
                                    "domain": "<string>",
                                    "path": "<string>",
                                    "expires": 123,
                                    "httpOnly": True,
                                    "secure": True,
                                    "sameSite": "Strict"
                                }
                            ],
                            "width": 123,
                            "height": 123,
                            "deviceScaleFactor": 123,
                            "userAgent": "<string>",
                            "headers": {},
                            "options": {}
                        }
                    ]
                }
            )

            data = response.json()
components:
  parameters:
    BrowserSessionId:
      name: id
      in: path
      required: true
      schema:
        type: string
      example: bses_01HZX9Q3J5K8N2P4R6T8V0W2Y4
  schemas:
    RunBrowserCommandsInput:
      type: object
      required:
        - commands
      properties:
        commands:
          type: array
          items:
            $ref: '#/components/schemas/BrowserCommand'
    RunBrowserCommandsResult:
      type: object
      required:
        - sessionId
        - results
        - totalMs
      properties:
        sessionId:
          type: string
        results:
          type: array
          items:
            $ref: '#/components/schemas/BrowserCommandResult'
        totalMs:
          type: number
    BrowserCommand:
      type: object
      description: >-
        A single browser automation command. The op field selects the operation;
        remaining fields depend on op.
      required:
        - op
      properties:
        op:
          type: string
          enum:
            - goto
            - waitForSelector
            - waitForNavigation
            - waitForTimeout
            - click
            - type
            - select
            - screenshot
            - pdf
            - content
            - title
            - url
            - evaluate
            - cookies.get
            - cookies.set
            - setViewport
            - setUserAgent
            - setExtraHTTPHeaders
        url:
          type: string
        selector:
          type: string
        text:
          type: string
        values:
          type: array
          items:
            type: string
        ms:
          type: integer
        script:
          type: string
        urls:
          type: array
          items:
            type: string
        cookies:
          type: array
          items:
            $ref: '#/components/schemas/BrowserCookie'
        width:
          type: integer
        height:
          type: integer
        deviceScaleFactor:
          type: number
        userAgent:
          type: string
        headers:
          type: object
          additionalProperties:
            type: string
        options:
          type: object
          additionalProperties: true
    BrowserCommandResult:
      type: object
      required:
        - op
        - durationMs
        - ok
      properties:
        op:
          type: string
        durationMs:
          type: number
        ok:
          type: boolean
        result: {}
        error:
          type: string
    Error:
      type: object
      properties:
        error:
          type: string
    RateLimitError:
      type: object
      required:
        - error
      properties:
        error:
          type: string
        retryAfterMs:
          type: integer
          description: Milliseconds to wait before retrying.
    BrowserCookie:
      type: object
      required:
        - name
        - value
      properties:
        name:
          type: string
        value:
          type: string
        url:
          type: string
        domain:
          type: string
        path:
          type: string
        expires:
          type: number
        httpOnly:
          type: boolean
        secure:
          type: boolean
        sameSite:
          type: string
          enum:
            - Strict
            - Lax
            - None
  responses:
    BadRequest:
      description: Invalid request
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Unauthorized:
      description: Authentication is missing, invalid, revoked, or expired.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Forbidden:
      description: The API token does not include a scope required for this operation.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    NotFound:
      description: Resource not found
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    TooManyRequests:
      description: Rate limit exceeded.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/RateLimitError'
    ServerError:
      description: An unexpected error occurred.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    ServiceUnavailable:
      description: >-
        A required dependency (for example the platform database) is not
        available.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        Voyant Cloud API token, passed as `Authorization: Bearer <token>`. Each
        token carries a fixed set of scopes; an operation rejects tokens missing
        its required scope.

````