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
- 200
- 400
- 401
- 402
- 422
- 429
- 500
- 503
Remote connection successful
Invalid Request Format - check API documentation for proper syntax.
Unauthorized - missing or invalid API key.
Payment Required - you have run out of trial credits or your payment method has expired. Please add payment details to your account.
Unprocessable Entity - cannot find requested asset associated with your API key.
Too Many Requests - you have exceeded the rate limit for your account. Please wait before making additional requests.
Internal Server Error - please retry your request.
Service Unavailable - our servers have dropped the request due to high load - please retry.