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

# Generate CDP url

> This endpoint allows you to generate a pre-signed URL for accessing the Chrome DevTools Protocol (CDP) of a running box. The URL is valid for a limited time and can be used to interact with the box's browser environment



## OpenAPI

````yaml post /boxes/{boxId}/browser/connect-url/cdp
openapi: 3.0.0
info:
  title: GBOX Open API
  description: GBOX Open API Documentation
  version: '1.0'
  contact: {}
servers:
  - url: https://gbox.ai/api/v1
    description: Production Server
security: []
tags: []
paths:
  /boxes/{boxId}/browser/connect-url/cdp:
    post:
      tags:
        - Browser
      summary: Generate CDP url
      description: >-
        This endpoint allows you to generate a pre-signed URL for accessing the
        Chrome DevTools Protocol (CDP) of a running box. The URL is valid for a
        limited time and can be used to interact with the box's browser
        environment
      operationId: BrowserController_getCdpUrl
      parameters:
        - name: boxId
          required: true
          in: path
          description: Box ID
          schema:
            example: c9bdc193-b54b-4ddb-a035-5ac0c598d32d
            type: string
      requestBody:
        required: false
        description: Generate pre-signed CDP url
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/GenerateCdpUrl'
      responses:
        '200':
          description: Generate pre-signed CDP url
          content:
            application/json:
              schema:
                type: string
                example: >-
                  https://gbox.ai/api/v1/boxes/031df7cd-baa4-4d50-92ee-4ceaf04b0905/browser/connect/
      security:
        - bearer: []
      x-codeSamples:
        - lang: JavaScript
          source: |-
            import GboxSDK from "gbox-sdk";
            import { chromium } from "playwright";

            const gboxSDK = new GboxSDK({
              apiKey: process.env["GBOX_API_KEY"] // This is the default and can be omitted
            });

            async function main() {
              const box = await gboxSDK.create({ type: "linux" });

              // Get browser CDP URL for Chrome DevTools Protocol connection
              const cdpUrl = await box.browser.cdpUrl();

              console.log(`Browser CDP URL: ${cdpUrl}`);

              const browser = await chromium.connectOverCDP(cdpUrl);

              // Use the browser as usual
              const context = await browser.newContext();
              const page = await context.newPage();
              await page.goto("https://example.com");

              // Perform actions on the page
              console.log(await page.title());

              // Close the browser
              await browser.close();
            }

            main();
        - lang: Python
          source: |-
            import os
            import asyncio
            from gbox_sdk import GboxSDK
            from playwright.async_api import async_playwright

            async def main():
                gbox_sdk = GboxSDK(api_key=os.environ["GBOX_API_KEY"])

                # Create a new linux box
                box = gbox_sdk.create(type="linux")

                # Get browser CDP URL for Chrome DevTools Protocol connection
                cdp_url = box.browser.cdp_url()

                print(f"Browser CDP URL: {cdp_url}")

                async with async_playwright() as p:
                    browser = await p.chromium.connect_over_cdp(cdp_url)

                    # Use the browser as usual
                    context = await browser.new_context()
                    page = await context.new_page()
                    await page.goto("https://example.com")

                    # Perform actions on the page
                    title = await page.title()
                    print(title)

                    # Close the browser
                    await browser.close()

            if __name__ == "__main__":
                asyncio.run(main())
        - lang: Go
          source: "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\t\"log\"\n\t\"os\"\n\n\t\"github.com/gbox/gbox-sdk-go\"\n)\n\nfunc main() {\n\tgboxSDK := gbox.NewGboxSDK(os.Getenv(\"GBOX_API_KEY\"))\n\n\t// Create a new linux box\n\tbox, err := gboxSDK.Create(context.Background(), gbox.CreateOptions{Type: \"linux\"})\n\tif err != nil {\n\t\tlog.Fatalf(\"Failed to create linux box: %v\", err)\n\t}\n\n\t// Get browser CDP URL for Chrome DevTools Protocol connection\n\tcdpUrl, err := box.Browser.GetCdpUrl(context.Background())\n\tif err != nil {\n\t\tlog.Fatalf(\"Failed to get browser CDP URL: %v\", err)\n\t}\n\n\tfmt.Printf(\"Browser CDP URL: %s\\n\", cdpUrl)\n\n\t// You can use this URL with CDP libraries like pyppeteer\n\n}"
components:
  schemas:
    GenerateCdpUrl:
      type: object
      properties:
        expiresIn:
          type: string
          description: >-
            The CDP url will be alive for the given duration


            Supported time units: ms (milliseconds), s (seconds), m (minutes), h
            (hours)

            Example formats: "500ms", "30s", "5m", "1h"

            Default: 120m
          example: 120m
          default: 120m
          title: GenerateCdpUrlConfig
      title: Generate Cdp Url
      description: Generate cdp url
  securitySchemes:
    bearer:
      scheme: bearer
      bearerFormat: JWT
      type: http
      description: >-
        Enter your API Key in the format: Bearer <token>. Get it from
        https://gbox.ai

````