Skip to content
APIs Pricing Docs Guides Log in Start free

Connect to a session

GET
/api/v1/browser/session/{session_id}

Upgrades to a websocket and proxies it to the session's browser (CDP or Playwright). The session id is the capability, so no bearer token is required. Disconnecting does not end the session; reconnect with the same id. Not separately billed.

Operation id
browser.session.connect
Authentication
Bearer API key
Required permission
browser.connect
Price
0 credits per successful request
Rate limit
120 requests per minute per key, 600 per workspace

Request

Examples

curl -X GET https://webknx.com/api/v1/browser/session/{session_id} \
  -H "Authorization: Bearer $WEBKNX_SECRET_KEY" \
  -H "Content-Type: application/json" \
  -d 'null' \
  --output qrcode.png
const res = await fetch("https://webknx.com/api/v1/browser/session/{session_id}", {
  method: "GET",
  headers: {
    Authorization: `Bearer ${process.env.WEBKNX_SECRET_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify(null),
});
if (!res.ok) throw new Error((await res.json()).error.code);
const png = Buffer.from(await res.arrayBuffer());
import os, requests

res = requests.get(
    "https://webknx.com/api/v1/browser/session/{session_id}",
    headers={"Authorization": f"Bearer {os.environ['WEBKNX_SECRET_KEY']}"},
    json=null,
    timeout=15,
)
res.raise_for_status()
open("qrcode.png", "wb").write(res.content)
$res = Http::withToken(getenv('WEBKNX_SECRET_KEY'))
    ->post('https://webknx.com/api/v1/browser/session/{session_id}', NULL)
    ->throw();
file_put_contents('qrcode.png', $res->body());

Request body

null

Responses

200
The connection is upgraded to a websocket carrying the CDP/Playwright protocol.

404
No such session. application/json

{
    "code": "session_not_found",
    "message": "No such session."
}

502
The browser container could not be prepared. application/json

{
    "code": "backend_unavailable",
    "message": "Could not prepare the browser container."
}

See errors and retries for how to handle each error code.