Skip to main content
POST
/
v1
/
sessions
/
{id}
Update a Session
curl --request POST \
  --url https://api.browserbase.com/v1/sessions/{id} \
  --header 'Content-Type: application/json' \
  --header 'X-BB-API-Key: <api-key>' \
  --data '
{
  "status": "REQUEST_RELEASE"
}
'
import requests

url = "https://api.browserbase.com/v1/sessions/{id}"

payload = { "status": "REQUEST_RELEASE" }
headers = {
"X-BB-API-Key": "<api-key>",
"Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
method: 'POST',
headers: {'X-BB-API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({status: 'REQUEST_RELEASE'})
};

fetch('https://api.browserbase.com/v1/sessions/{id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://api.browserbase.com/v1/sessions/{id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'status' => 'REQUEST_RELEASE'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-BB-API-Key: <api-key>"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main

import (
"fmt"
"strings"
"net/http"
"io"
)

func main() {

url := "https://api.browserbase.com/v1/sessions/{id}"

payload := strings.NewReader("{\n \"status\": \"REQUEST_RELEASE\"\n}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("X-BB-API-Key", "<api-key>")
req.Header.Add("Content-Type", "application/json")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://api.browserbase.com/v1/sessions/{id}")
.header("X-BB-API-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"status\": \"REQUEST_RELEASE\"\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.browserbase.com/v1/sessions/{id}")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["X-BB-API-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"status\": \"REQUEST_RELEASE\"\n}"

response = http.request(request)
puts response.read_body
{
  "id": "<string>",
  "createdAt": "2023-11-07T05:31:56Z",
  "updatedAt": "2023-11-07T05:31:56Z",
  "projectId": "<string>",
  "startedAt": "2023-11-07T05:31:56Z",
  "expiresAt": "2023-11-07T05:31:56Z",
  "proxyBytes": 123,
  "keepAlive": true,
  "endedAt": "2023-11-07T05:31:56Z",
  "contextId": "<string>",
  "userMetadata": {}
}

Closing a session

Use this endpoint to close an active Browserbase session before its timeout. To close the session, send status: "REQUEST_RELEASE" in the request body. This tells Browserbase to end the session and helps avoid unnecessary usage charges if your work is already complete.
{
  "status": "REQUEST_RELEASE"
}

Authorizations

X-BB-API-Key
string
header
required

Path Parameters

id
string
required

Body

application/json
status
enum<string>
required

Set to REQUEST_RELEASE to request that the session complete. Use before session's timeout to avoid additional charges.

Available options:
REQUEST_RELEASE

Response

200 - application/json

The request has succeeded.

id
string
required
createdAt
string<date-time>
required
updatedAt
string<date-time>
required
projectId
string
required

The Project ID linked to the Session.

startedAt
string<date-time>
required
expiresAt
string<date-time>
required
status
enum<string>
required
Available options:
PENDING,
RUNNING,
ERROR,
TIMED_OUT,
COMPLETED
proxyBytes
integer
required

Bytes used via the Proxy

keepAlive
boolean
required

Indicates if the Session was created to be kept alive upon disconnections

region
enum<string>
required

The region where the Session is running.

Available options:
us-west-2,
us-east-1,
eu-central-1,
ap-southeast-1
endedAt
string<date-time>
contextId
string

Optional. The Context linked to the Session.

userMetadata
object

Arbitrary user metadata to attach to the session. To learn more about user metadata, see User Metadata.