Skip to main content
Create a browser session to get a CDP URL for connecting your automation framework.

Create a Session

import BrowsercashSDK from "@browsercash/sdk";

const client = new BrowsercashSDK({
  apiKey: process.env.BROWSER_API_KEY,
});

const session = await client.browser.session.create();
console.log(session);

Session Options

Customize your session with these parameters:
ParameterTypeDescription
countrystring2-letter ISO country code (e.g. US, CA)
nodeIdstringTarget a specific node you’ve used before
typestringconsumer_distributed, hosted
proxyUrlstringSOCKS5 proxy URL, UDP support encouraged
windowSizestringBrowser dimensions as WIDTHxHEIGHT
profileobject{ name: string, persist: boolean } for persistent profiles

Example with Options

const session = await client.browser.session.create({
  country: "US",
  type: "hosted",
  windowSize: "1920x1080",
  profile: {
    name: "my-profile",
    persist: true,
  },
});

Session Types

TypeDescription
consumer_distributedRuns on real consumer devices for maximum stealth
hostedRuns in our data centers for consistent performance

Response

{
  "sessionId": "sess_abc123xyz",
  "status": "active",
  "servedBy": "node-us-east-1",
  "createdAt": "2024-01-15T10:30:00.000Z",
  "cdpUrl": "wss://cdp.browser.cash/sess_abc123xyz"
}

Notes

  • Sessions may take up to 3 seconds to start
  • Sessions automatically terminate after 1 hour
  • CDP URLs are valid only while the session is active
  • Always stop sessions when done to avoid unnecessary billing

Next Steps