API Reference
End a browser session
Terminates the browser session and releases all associated resources.
POST
/
v1
/
sessions
/
{id}
/
end
JavaScript
import Stagehand from 'stagehand-sdk';
const client = new Stagehand({
browserbaseAPIKey: process.env['BROWSERBASE_API_KEY'], // This is the default and can be omitted
browserbaseProjectID: process.env['BROWSERBASE_PROJECT_ID'], // This is the default and can be omitted
modelAPIKey: process.env['MODEL_API_KEY'], // This is the default and can be omitted
});
const response = await client.sessions.end('c4dbf3a9-9a58-4b22-8a1c-9f20f9f9e123');
console.log(response.success);import os
from stagehand import Stagehand
client = Stagehand(
browserbase_api_key=os.environ.get("BROWSERBASE_API_KEY"), # This is the default and can be omitted
browserbase_project_id=os.environ.get("BROWSERBASE_PROJECT_ID"), # This is the default and can be omitted
model_api_key=os.environ.get("MODEL_API_KEY"), # This is the default and can be omitted
)
response = client.sessions.end(
id="c4dbf3a9-9a58-4b22-8a1c-9f20f9f9e123",
)
print(response.success)package main
import (
"context"
"fmt"
"github.com/browserbase/stagehand-go"
"github.com/browserbase/stagehand-go/option"
)
func main() {
client := stagehand.NewClient(
option.WithBrowserbaseAPIKey("My Browserbase API Key"),
option.WithBrowserbaseProjectID("My Browserbase Project ID"),
option.WithModelAPIKey("My Model API Key"),
)
response, err := client.Sessions.End(
context.TODO(),
"c4dbf3a9-9a58-4b22-8a1c-9f20f9f9e123",
stagehand.SessionEndParams{},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", response.Success)
}
package com.browserbase.api.example;
import com.browserbase.api.client.StagehandClient;
import com.browserbase.api.client.okhttp.StagehandOkHttpClient;
import com.browserbase.api.models.sessions.SessionEndParams;
import com.browserbase.api.models.sessions.SessionEndResponse;
public final class Main {
private Main() {}
public static void main(String[] args) {
StagehandClient client = StagehandOkHttpClient.fromEnv();
SessionEndResponse response = client.sessions().end("c4dbf3a9-9a58-4b22-8a1c-9f20f9f9e123");
}
}package com.browserbase.api.example
import com.browserbase.api.client.StagehandClient
import com.browserbase.api.client.okhttp.StagehandOkHttpClient
import com.browserbase.api.models.sessions.SessionEndParams
import com.browserbase.api.models.sessions.SessionEndResponse
fun main() {
val client: StagehandClient = StagehandOkHttpClient.fromEnv()
val response: SessionEndResponse = client.sessions().end("c4dbf3a9-9a58-4b22-8a1c-9f20f9f9e123")
}require "stagehand"
stagehand = Stagehand::Client.new(
browserbase_api_key: "My Browserbase API Key",
browserbase_project_id: "My Browserbase Project ID",
model_api_key: "My Model API Key"
)
response = stagehand.sessions.end_("c4dbf3a9-9a58-4b22-8a1c-9f20f9f9e123")
puts(response)<?php
require_once dirname(__DIR__) . '/vendor/autoload.php';
use Stagehand\Client;
use Stagehand\Core\Exceptions\APIException;
$client = new Client(
browserbaseAPIKey: getenv('BROWSERBASE_API_KEY') ?: 'My Browserbase API Key',
browserbaseProjectID: getenv(
'BROWSERBASE_PROJECT_ID'
) ?: 'My Browserbase Project ID',
modelAPIKey: getenv('MODEL_API_KEY') ?: 'My Model API Key',
);
try {
$response = $client->sessions->end(
'c4dbf3a9-9a58-4b22-8a1c-9f20f9f9e123', xStreamResponse: 'true'
);
var_dump($response);
} catch (APIException $e) {
echo $e->getMessage();
}using System;
using Stagehand;
using Stagehand.Models.Sessions;
StagehandClient client = new();
SessionEndParams parameters = new()
{
ID = "c4dbf3a9-9a58-4b22-8a1c-9f20f9f9e123"
};
var response = await client.Sessions.End(parameters);
Console.WriteLine(response);curl --request POST \
--url https://api.stagehand.browserbase.com/v1/sessions/{id}/end \
--header 'x-bb-api-key: <api-key>' \
--header 'x-bb-project-id: <api-key>'{
"success": true
}Authorizations
Browserbase API key for authentication
Deprecated. Browserbase API keys are now project-scoped, so this header is no longer required.
Headers
Whether to stream the response via SSE
Available options:
true, false Example:
"true"
Path Parameters
Unique session identifier
Example:
"c4dbf3a9-9a58-4b22-8a1c-9f20f9f9e123"
Response
200 - application/json
Default Response
Indicates whether the request was successful
⌘I
JavaScript
import Stagehand from 'stagehand-sdk';
const client = new Stagehand({
browserbaseAPIKey: process.env['BROWSERBASE_API_KEY'], // This is the default and can be omitted
browserbaseProjectID: process.env['BROWSERBASE_PROJECT_ID'], // This is the default and can be omitted
modelAPIKey: process.env['MODEL_API_KEY'], // This is the default and can be omitted
});
const response = await client.sessions.end('c4dbf3a9-9a58-4b22-8a1c-9f20f9f9e123');
console.log(response.success);import os
from stagehand import Stagehand
client = Stagehand(
browserbase_api_key=os.environ.get("BROWSERBASE_API_KEY"), # This is the default and can be omitted
browserbase_project_id=os.environ.get("BROWSERBASE_PROJECT_ID"), # This is the default and can be omitted
model_api_key=os.environ.get("MODEL_API_KEY"), # This is the default and can be omitted
)
response = client.sessions.end(
id="c4dbf3a9-9a58-4b22-8a1c-9f20f9f9e123",
)
print(response.success)package main
import (
"context"
"fmt"
"github.com/browserbase/stagehand-go"
"github.com/browserbase/stagehand-go/option"
)
func main() {
client := stagehand.NewClient(
option.WithBrowserbaseAPIKey("My Browserbase API Key"),
option.WithBrowserbaseProjectID("My Browserbase Project ID"),
option.WithModelAPIKey("My Model API Key"),
)
response, err := client.Sessions.End(
context.TODO(),
"c4dbf3a9-9a58-4b22-8a1c-9f20f9f9e123",
stagehand.SessionEndParams{},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", response.Success)
}
package com.browserbase.api.example;
import com.browserbase.api.client.StagehandClient;
import com.browserbase.api.client.okhttp.StagehandOkHttpClient;
import com.browserbase.api.models.sessions.SessionEndParams;
import com.browserbase.api.models.sessions.SessionEndResponse;
public final class Main {
private Main() {}
public static void main(String[] args) {
StagehandClient client = StagehandOkHttpClient.fromEnv();
SessionEndResponse response = client.sessions().end("c4dbf3a9-9a58-4b22-8a1c-9f20f9f9e123");
}
}package com.browserbase.api.example
import com.browserbase.api.client.StagehandClient
import com.browserbase.api.client.okhttp.StagehandOkHttpClient
import com.browserbase.api.models.sessions.SessionEndParams
import com.browserbase.api.models.sessions.SessionEndResponse
fun main() {
val client: StagehandClient = StagehandOkHttpClient.fromEnv()
val response: SessionEndResponse = client.sessions().end("c4dbf3a9-9a58-4b22-8a1c-9f20f9f9e123")
}require "stagehand"
stagehand = Stagehand::Client.new(
browserbase_api_key: "My Browserbase API Key",
browserbase_project_id: "My Browserbase Project ID",
model_api_key: "My Model API Key"
)
response = stagehand.sessions.end_("c4dbf3a9-9a58-4b22-8a1c-9f20f9f9e123")
puts(response)<?php
require_once dirname(__DIR__) . '/vendor/autoload.php';
use Stagehand\Client;
use Stagehand\Core\Exceptions\APIException;
$client = new Client(
browserbaseAPIKey: getenv('BROWSERBASE_API_KEY') ?: 'My Browserbase API Key',
browserbaseProjectID: getenv(
'BROWSERBASE_PROJECT_ID'
) ?: 'My Browserbase Project ID',
modelAPIKey: getenv('MODEL_API_KEY') ?: 'My Model API Key',
);
try {
$response = $client->sessions->end(
'c4dbf3a9-9a58-4b22-8a1c-9f20f9f9e123', xStreamResponse: 'true'
);
var_dump($response);
} catch (APIException $e) {
echo $e->getMessage();
}using System;
using Stagehand;
using Stagehand.Models.Sessions;
StagehandClient client = new();
SessionEndParams parameters = new()
{
ID = "c4dbf3a9-9a58-4b22-8a1c-9f20f9f9e123"
};
var response = await client.Sessions.End(parameters);
Console.WriteLine(response);curl --request POST \
--url https://api.stagehand.browserbase.com/v1/sessions/{id}/end \
--header 'x-bb-api-key: <api-key>' \
--header 'x-bb-project-id: <api-key>'{
"success": true
}
