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

# Create browser session

> Creates an isolated browser session with network access restricted to the domains you allow.



## OpenAPI

````yaml /openapi/source/external/agent-browser/agent-browser.json post /browser_sessions
openapi: 3.1.0
info:
  version: 1.0.0
  title: Telnyx API
  x-latency-category: interactive
  x-endpoint-cost: light
  description: >-
    Isolated, short-lived browser sessions for AI agents — navigate, observe,
    click, fill, and screenshot through one API.


    ## Authentication


    All endpoints require a Telnyx API key sent as a Bearer token in the
    `Authorization` header.


    ## Session Quota


    Creating a session is subject to a concurrent-session quota per
    organization. When capacity is exhausted, create returns `429
    quota_exceeded` with `retryable: true`. Close unneeded active sessions or
    wait for capacity before retrying.


    ## Error Responses


    Request errors use `{ "error": { "code": string, "message": string,
    "retryable": boolean } }`. Execution failures are reported on action
    resources with HTTP 200 and `data.status` set to `failed` or `unknown`. A
    request can also return HTTP 503 `execution_lost`; inspect action and
    session state before retrying because the action may already have taken
    effect.
  contact:
    email: support@telnyx.com
servers:
  - url: https://api.telnyx.com/v2
    description: Telnyx API v2
security:
  - bearerAuth: []
tags:
  - name: Browser Sessions
    description: Create, list, get, and close browser sessions.
  - name: Actions
    description: >-
      Execute browser actions: navigate, observe, click, fill, select, press,
      scroll, wait_for, screenshot, batch.
  - name: Artifacts
    description: Download screenshots and other artifacts.
paths:
  /browser_sessions:
    post:
      tags:
        - Browser Sessions
      summary: Create browser session
      description: >-
        Creates an isolated browser session with network access restricted to
        the domains you allow.
      operationId: CreateBrowserSession
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateSessionRequest'
            example:
              policy:
                allowed_domains:
                  - example.com
      responses:
        '201':
          description: Session created
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: '#/components/schemas/Session'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '409':
          description: Idempotency key reused with a different normalized create request.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  code: idempotency_conflict
                  message: idempotency key reused with a different request
                  retryable: false
        '429':
          description: >-
            Concurrent-session quota exceeded for the organization. Close
            unneeded active sessions or wait for capacity before retrying.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  code: quota_exceeded
                  message: organization concurrent-session limit reached
                  retryable: true
        '500':
          description: The session could not be created.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  code: internal_error
                  message: failed to provision browser session
                  retryable: true
      x-codeSamples:
        - lang: JavaScript
          source: |-
            import Telnyx from 'telnyx';

            const client = new Telnyx({
              apiKey: process.env['TELNYX_API_KEY'], // This is the default and can be omitted
            });

            const response = await client.browserSessions.create({
              policy: {},
            });

            console.log(response.data);
        - lang: Python
          source: |
            import os
            from telnyx import Telnyx

            client = Telnyx(
                api_key=os.environ.get("TELNYX_API_KEY"),  # This is the default and can be omitted
            )
            response = client.browser_sessions.create(
                policy={},
            )
            print(response.data)
        - lang: Go
          source: "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/team-telnyx/telnyx-go\"\n\t\"github.com/team-telnyx/telnyx-go/option\"\n)\n\nfunc main() {\n\tclient := telnyx.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tbrowserSession, err := client.BrowserSessions.New(\n\t\tcontext.TODO(),\n\t\ttelnyx.BrowserSessionNewParams{\n\t\t\tPolicy: \"policy\",\n\t\t},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", browserSession.Data)\n}\n"
        - lang: Java
          source: >-
            package com.telnyx.sdk.example;


            import com.telnyx.sdk.client.TelnyxClient;

            import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient;

            import
            com.telnyx.sdk.models.browserSessions.BrowserSessionCreateParams;


            public final class Main {
                private Main() {}

                public static void main(String[] args) {
                    TelnyxClient client = TelnyxOkHttpClient.fromEnv();

                    BrowserSessionCreateParams params = BrowserSessionCreateParams.builder()
                        .policy(null)
                        .build();
                    var response = client.browserSessions().create(params);
                }
            }
        - lang: Ruby
          source: |-
            require "telnyx"

            telnyx = Telnyx::Client.new(api_key: "My API Key")

            response = telnyx.browser_sessions.create(policy: {})

            puts(response)
        - lang: PHP
          source: >-
            <?php


            require_once dirname(__DIR__) . '/vendor/autoload.php';


            use Telnyx\Client;

            use Telnyx\Core\Exceptions\APIException;


            $client = new Client(apiKey: getenv('TELNYX_API_KEY') ?: 'My API
            Key');


            try {
              $response = $client->browserSessions->create(
                policy: [],
              );

              var_dump($response);
            } catch (APIException $e) {
              echo $e->getMessage();
            }
        - lang: CLI
          source: |-
            telnyx browser-sessions create \
              --api-key 'My API Key' \
              --policy '{}'
components:
  schemas:
    CreateSessionRequest:
      type: object
      required:
        - policy
      properties:
        policy:
          type: object
          required:
            - allowed_domains
          properties:
            allowed_domains:
              type: array
              items:
                type: string
                minLength: 1
              minItems: 1
              maxItems: 50
              description: >-
                Domain patterns the browser can navigate to. Exact match
                (example.com) or wildcard (*.example.com). IP literals not
                allowed.
          additionalProperties: false
        limits:
          type: object
          properties:
            lifetime_s:
              type: integer
              minimum: 60
              maximum: 1800
              default: 900
              description: Max session duration in seconds (60-1800).
            idle_timeout_s:
              type: integer
              minimum: 30
              default: 300
              description: Idle timeout in seconds. Must not exceed lifetime_s.
          additionalProperties: false
        metadata:
          type: object
          description: Arbitrary key-value metadata.
          additionalProperties: true
        idempotency_key:
          type: string
          minLength: 1
          maxLength: 255
          description: >-
            Scoped to the organization. The same key and identical normalized
            policy, limits, and metadata replay the existing session (HTTP 201);
            a different request returns 409 idempotency_conflict. Replays do not
            restart terminal sessions.
      additionalProperties: false
    Session:
      type: object
      properties:
        id:
          type: string
          example: bsess_3b108e10-906a-486e-9132-196726ba7979
        status:
          type: string
          enum:
            - provisioning
            - ready
            - closing
            - closed
            - failed
            - expired
        failure_reason:
          type:
            - string
            - 'null'
        policy:
          type: object
          properties:
            allowed_domains:
              type: array
              items:
                type: string
          required:
            - allowed_domains
        limits:
          type: object
          properties:
            lifetime_s:
              type: integer
            idle_timeout_s:
              type: integer
          required:
            - lifetime_s
            - idle_timeout_s
        metadata:
          type: object
          additionalProperties: true
        created_at:
          type: string
          format: date-time
        ready_at:
          type:
            - string
            - 'null'
          format: date-time
        last_activity_at:
          type:
            - string
            - 'null'
          format: date-time
        expires_at:
          type:
            - string
            - 'null'
          format: date-time
        closed_at:
          type:
            - string
            - 'null'
          format: date-time
      required:
        - id
        - status
        - failure_reason
        - policy
        - limits
        - metadata
        - created_at
        - ready_at
        - last_activity_at
        - expires_at
        - closed_at
    ErrorResponse:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
            message:
              type: string
            retryable:
              type: boolean
          required:
            - code
            - message
            - retryable
      required:
        - error
    GatewayError:
      type: object
      required:
        - errors
      properties:
        errors:
          type: array
          items:
            type: object
            required:
              - code
              - title
            properties:
              code:
                type: string
              title:
                type: string
              detail:
                type: string
              source:
                type: object
                properties:
                  pointer:
                    type: string
              meta:
                type: object
                properties:
                  url:
                    type: string
                    format: uri
  responses:
    BadRequest:
      description: Invalid request — validation error or invalid parameters.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error:
              code: validation_error
              message: >-
                invalid request: policy.allowed_domains must have at least 1
                item(s)
              retryable: false
    Unauthorized:
      description: Unauthorized — missing or invalid API key.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/GatewayError'
          example:
            errors:
              - code: '10009'
                title: Authentication failed
                detail: Could not find any usable credentials in the request.
                source:
                  pointer: /
                meta:
                  url: https://developers.telnyx.com/docs/overview/errors/10009
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````