Skip to content

HTTP API

The Node client is a thin wrapper over this API. Types are in src/protocol.ts.

Two kinds of credential are used. The API key goes in Authorization: Bearer <key>. A slot token goes in x-browserbay-token: <token>.

CallAuthDoes
POST /v1/slotsAPI keyTakes a browser.
GET /v1/slotsAPI keyLists slots. No tokens. A key confined to a namespace sees only its own.
DELETE /v1/slots/:idAPI keyReleases a browser. Idempotent, 204. A key confined to a namespace cannot release another namespace’s slot: that answers 204 and does nothing, as for a slot that does not exist.
GET /v1/nodesAPI keyLists nodes, their capacity and load. 403 for a key confined to a namespace.
GET /v1/slots/:idslot token200 while the slot’s browser is reachable, 404 when gone, 503 while its node reconnects.
WS /v1/cdp/:idslot tokenThe slot’s DevTools endpoint.
GET /healthnone200 when the relay is up. It does not say a node has joined.
GET /.well-known/http-message-signatures-directorynoneThe public key the box signs with, as a JWKS, when the relay has BROWSERBAY_WEB_BOT_AUTH_KEY. Signed over the host that asked.
Terminal window
curl -X POST https://browsers.example.com/v1/slots \
-H "Authorization: Bearer $BROWSERBAY_API_KEY" \
-H "content-type: application/json" \
-d '{ "runId": "task-42", "maxLifetimeSeconds": 1800, "waitMs": 5000 }'
StatusBodyMeaning
201{ "slotId", "token", "nodeId", "applied" }You have a browser. The token is shown once. applied names the options of the request that the slot has.
503no_capacityEvery node is full, or none is connected.
422unsupported, with a messageNodes are connected, and none could serve this request. Either none has a feature or a label it asks for, or every node that does refused the slot’s value (a time zone its system lacks, an option it does not know): the message says which. Answered at once, because waiting would not help.
403forbiddenThe key is confined to a namespace and the run id is outside it.
429quota_exceededThe key’s namespace already holds as many browsers as its quota allows. Answered at once: it does not wait.
400invalid_request, usually with a messageA bad body: runId is 1 to 200 characters, maxLifetimeSeconds is 60 to 86400, a field the box does not know, or an option that is wrong. The message says which.

waitMs defaults to 0 here, while the client’s default is 30 seconds. The box caps it at its BROWSERBAY_MAX_ACQUIRE_WAIT_MS.

All are optional. A request without them is the one a box has always taken.

FieldMeaning
proxy{ "server", "username"?, "password"?, "bypass"? }. The slot’s traffic goes through this proxy. server is http://, https:// or socks5:// with host:port and nothing else. A loopback, unspecified or link-local address is refused (400).
timezoneAn IANA time zone such as Europe/Berlin. Needs a node running BROWSERBAY_ISOLATION=process.
localeA language tag such as de-DE: the browser’s navigator.language and Accept-Language. Needs a node running BROWSERBAY_ISOLATION=process.
nodeLabelsA list of labels. The slot is only placed on a node that carries all of them (BROWSERBAY_NODE_LABELS).
signRequeststrue signs every request of the slot’s browser (Web Bot Auth); false asks for it to be left unsigned; left out, the node’s own setting decides. true needs a node set to optional or always that signs with the key this relay publishes, and false one that is not set to always.
Terminal window
curl -X POST https://browsers.example.com/v1/slots \
-H "Authorization: Bearer $BROWSERBAY_API_KEY" \
-H "content-type: application/json" \
-d '{ "runId": "task-42", "maxLifetimeSeconds": 1800,
"proxy": { "server": "http://proxy.example.com:8080", "username": "user", "password": "secret" },
"nodeLabels": ["residential"] }'

Check applied. A box older than these options answers 201 and ignores a field it does not know, and the browser it made is a plain one: for a proxy, a browser that goes out from the box’s own address. From this version the box refuses a field it does not know (400), and the clients check that applied has what they asked for, release the browser and fail with UnsupportedError if it does not. If you call the API yourself, do the same.

The password is passed to the one node that makes the browser and is kept nowhere: it is not in the relay’s tables, in GET /v1/slots, in GET /v1/nodes or in a log.

Open a WebSocket to /v1/cdp/<slotId> on the box, with the x-browserbay-token header. Use wss:// when the box is served over HTTPS. Speak the Chrome DevTools Protocol.

// Node, with the ws package
import WebSocket from 'ws'
const ws = new WebSocket(`wss://browsers.example.com/v1/cdp/${slotId}`, {
headers: { 'x-browserbay-token': token }
})

The live view guide builds on this.

Terminal window
curl -X DELETE https://browsers.example.com/v1/slots/$SLOT_ID \
-H "Authorization: Bearer $BROWSERBAY_API_KEY"

Answers 204, whether or not the slot still exists.

Terminal window
curl https://browsers.example.com/v1/slots/$SLOT_ID -H "x-browserbay-token: $TOKEN"

200 while the browser is reachable, 404 when it is gone, and 503 while its node reconnects.