Skip to main content

CDP

POST 

/workstations/:workstation_id/browser/cdp

Connect to a Workstation's browser using Chrome DevTools Protocol (CDP). This endpoint returns a WebSocket URL that can be used to establish a CDP connection with the browser, enabling automation via tools like Puppeteer and Playwright.

Puppeteer

const puppeteer = require('puppeteer');

// Construct the CDP endpoint URL
const id = 'HvcqZjmeoPtP';
const url = `https://api.agentstation.ai/v1/workstations/${id}/browser/connect`;

// Get CDP WebSocket URL from AgentStation API
const response = await fetch(url, {
method: 'POST',
headers: {
'Authorization': 'Bearer <your_token>'
}
});
const conn = await response.json();
// conn.url example: https://zt5ikcbbab6h.cdp.v1.connect.agentstation.ai

// Connect using Puppeteer
const browser = await puppeteer.connect({
browserWSEndpoint: conn.url,
defaultViewport: { width: 1280, height: 720 }
});

// Use the browser instance
const page = await browser.newPage();
await page.goto('https://example.com');

Playwright

const { chromium } = require('playwright');

// Construct the CDP endpoint URL
const id = 'HvcqZjmeoPtP';
const url = `https://api.agentstation.ai/v1/workstations/${id}/browser/connect`;

// Get CDP WebSocket URL from AgentStation API
const response = await fetch(url, {
method: 'POST',
headers: {
'Authorization': 'Bearer <your_token>'
}
});
const conn = await response.json();
// conn.url example: https://zt5ikcbbab6h.cdp.v1.connect.agentstation.ai

// Connect using Playwright
const browser = await chromium.connectOverCDP(conn.url);

// Use the browser instance
const page = await browser.newPage();
await page.goto('https://example.com');

Notes

  • The connection will be automatically closed after the Workstation is released

Request

Responses

Remote connection successful