Skip to main content
POST
/
browsers
JavaScript
import Kernel from '@onkernel/sdk';

const client = new Kernel({
  apiKey: 'My API Key',
});

const browser = await client.browsers.create();

console.log(browser.session_id);
{
  "created_at": "2023-11-07T05:31:56Z",
  "cdp_ws_url": "wss://api.onkernel.com/browser/cdp?jwt=eyJ0eXAi...",
  "browser_live_view_url": "https://api.onkernel.com/browser/remote?jwt=eyJ0eXAi...",
  "headless": false,
  "stealth": false,
  "session_id": "htzv5orfit78e1m2biiifpbv",
  "persistence": {
    "id": "my-awesome-browser-for-user-1234"
  },
  "timeout_seconds": 123,
  "profile": {
    "id": "<string>",
    "name": "<string>",
    "created_at": "2023-11-07T05:31:56Z",
    "updated_at": "2023-11-07T05:31:56Z",
    "last_used_at": "2023-11-07T05:31:56Z"
  },
  "proxy_id": "<string>"
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

application/json

Parameters for creating a browser session. Specify at most one of "persistence" or "profile". These options are mutually exclusive; if both are provided the request is invalid.

invocation_id
string

action invocation ID

Example:

"rr33xuugxj9h0bkf1rdt2bet"

persistence
object

Optional persistence configuration for the browser session.

stealth
boolean

If true, launches the browser in stealth mode to reduce detection by anti-bot mechanisms.

Example:

true

headless
boolean

If true, launches the browser using a headless image (no VNC/GUI). Defaults to false.

Example:

false

timeout_seconds
integer

The number of seconds of inactivity before the browser session is terminated. Only applicable to non-persistent browsers. Activity includes CDP connections and live view connections. Defaults to 60 seconds. Minimum allowed is 10 seconds. Maximum allowed is 86400 (24 hours). We check for inactivity every 5 seconds, so the actual timeout behavior you will see is +/- 5 seconds around the specified value.

Required range: 10 <= x <= 86400
profile
object

Profile selection for the browser session. Provide either id or name. If specified, the matching profile will be loaded into the browser session. Profiles must be created beforehand.

  • Option 1
  • Option 2
extensions
object[]

List of browser extensions to load into the session. Provide each by id or name.

Maximum length: 20
  • Option 1
  • Option 2
proxy_id
string

Optional proxy to associate to the browser session. Must reference a proxy belonging to the caller's org.

Response

Successful response

created_at
string<date-time>
required

When the browser session was created.

cdp_ws_url
string
required

Websocket URL for Chrome DevTools Protocol connections to the browser session

Example:

"wss://api.onkernel.com/browser/cdp?jwt=eyJ0eXAi..."

headless
boolean
required

Whether the browser session is running in headless mode.

Example:

false

stealth
boolean
required

Whether the browser session is running in stealth mode.

Example:

false

session_id
string
required

Unique identifier for the browser session

Example:

"htzv5orfit78e1m2biiifpbv"

timeout_seconds
integer
required

The number of seconds of inactivity before the browser session is terminated.

browser_live_view_url
string

Remote URL for live viewing the browser session. Only available for non-headless browsers.

Example:

"https://api.onkernel.com/browser/remote?jwt=eyJ0eXAi..."

persistence
object

Optional persistence configuration for the browser session.

profile
object

Browser profile metadata.

proxy_id
string

ID of the proxy associated with this browser session, if any.

I