API Reference
Observe available actions
Identifies and returns available actions on the current page that match the given instruction.
POST
/
v1
/
sessions
/
{id}
/
observe
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.observe('c4dbf3a9-9a58-4b22-8a1c-9f20f9f9e123');
console.log(response.data);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
)
for session in client.sessions.observe(
id="c4dbf3a9-9a58-4b22-8a1c-9f20f9f9e123",
):
print(session)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.Observe(
context.TODO(),
"c4dbf3a9-9a58-4b22-8a1c-9f20f9f9e123",
stagehand.SessionObserveParams{},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", response.Data)
}package com.browserbase.api.example;
import com.browserbase.api.client.StagehandClient;
import com.browserbase.api.client.okhttp.StagehandOkHttpClient;
import com.browserbase.api.models.sessions.SessionObserveParams;
import com.browserbase.api.models.sessions.SessionObserveResponse;
public final class Main {
private Main() {}
public static void main(String[] args) {
StagehandClient client = StagehandOkHttpClient.fromEnv();
SessionObserveResponse response = client.sessions().observe("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.SessionObserveParams
import com.browserbase.api.models.sessions.SessionObserveResponse
fun main() {
val client: StagehandClient = StagehandOkHttpClient.fromEnv()
val response: SessionObserveResponse = client.sessions().observe("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.observe("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->observe(
'c4dbf3a9-9a58-4b22-8a1c-9f20f9f9e123',
frameID: 'frameId',
instruction: 'Find all clickable navigation links',
options: [
'ignoreSelectors' => ['nav', '.cookie-banner', '#sidebar-ads'],
'model' => [
'auth' => [
'credentials' => [
'clientEmail' => 'client_email',
'privateKey' => 'private_key',
'authProviderX509CertURL' => 'https://example.com',
'authUri' => 'https://example.com',
'clientID' => 'client_id',
'clientX509CertURL' => 'https://example.com',
'privateKeyID' => 'private_key_id',
'projectID' => 'project_id',
'tokenUri' => 'https://example.com',
'type' => 'service_account',
'universeDomain' => 'universe_domain',
],
'type' => 'googleServiceAccount',
'projectID' => 'projectId',
'scopes' => 'string',
'universeDomain' => 'universeDomain',
],
'modelName' => 'openai/gpt-5.4-mini',
'provider' => 'vertex',
'providerOptions' => [
'vertex' => [
'location' => 'us-central1',
'project' => 'my-gcp-project',
'baseURL' => 'https://example.com',
'headers' => ['foo' => 'string'],
],
],
'apiKey' => 'sk-some-openai-api-key',
'baseURL' => 'https://api.openai.com/v1',
'headers' => ['foo' => 'string'],
],
'selector' => 'nav',
'timeout' => 30000,
'variables' => [
'username' => [
'value' => 'john@example.com', 'description' => 'The login email'
],
'rememberMe' => true,
],
],
xStreamResponse: 'true',
);
var_dump($response);
} catch (APIException $e) {
echo $e->getMessage();
}using System;
using Stagehand;
using Stagehand.Models.Sessions;
StagehandClient client = new();
SessionObserveParams parameters = new()
{
ID = "c4dbf3a9-9a58-4b22-8a1c-9f20f9f9e123"
};
var response = await client.Sessions.Observe(parameters);
Console.WriteLine(response);curl --request POST \
--url https://api.stagehand.browserbase.com/v1/sessions/{id}/observe \
--header 'Content-Type: application/json' \
--header 'x-bb-api-key: <api-key>' \
--header 'x-bb-project-id: <api-key>' \
--data '
{
"instruction": "Find all clickable navigation links",
"options": {
"model": {
"modelName": "openai/gpt-5.4-mini",
"provider": "<string>",
"auth": {
"type": "<string>",
"credentials": {
"private_key": "<string>",
"client_email": "<string>",
"type": "<string>",
"project_id": "<string>",
"private_key_id": "<string>",
"client_id": "<string>",
"auth_uri": "<string>",
"token_uri": "<string>",
"auth_provider_x509_cert_url": "<string>",
"client_x509_cert_url": "<string>",
"universe_domain": "<string>"
},
"scopes": "<string>",
"projectId": "<string>",
"universeDomain": "<string>"
},
"providerOptions": {
"vertex": {
"project": "my-gcp-project",
"location": "us-central1",
"baseURL": "<string>",
"headers": {}
}
},
"apiKey": "sk-some-openai-api-key",
"baseURL": "https://api.openai.com/v1",
"headers": {}
},
"variables": {
"username": {
"value": "john@example.com",
"description": "The login email"
},
"rememberMe": true
},
"timeout": 30000,
"selector": "nav",
"ignoreSelectors": [
"nav",
".cookie-banner",
"#sidebar-ads"
]
},
"frameId": "<string>",
"streamResponse": true
}
'{
"success": true,
"data": {
"result": [
{
"selector": "[data-testid='submit-button']",
"description": "Click the submit button",
"backendNodeId": 123,
"method": "click",
"arguments": [
"Hello World"
]
}
],
"actionId": "<string>"
}
}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"
Body
application/json
Previous
Extract data from the pageExtracts structured data from the current page using AI-powered analysis.
Next
⌘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.observe('c4dbf3a9-9a58-4b22-8a1c-9f20f9f9e123');
console.log(response.data);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
)
for session in client.sessions.observe(
id="c4dbf3a9-9a58-4b22-8a1c-9f20f9f9e123",
):
print(session)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.Observe(
context.TODO(),
"c4dbf3a9-9a58-4b22-8a1c-9f20f9f9e123",
stagehand.SessionObserveParams{},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", response.Data)
}package com.browserbase.api.example;
import com.browserbase.api.client.StagehandClient;
import com.browserbase.api.client.okhttp.StagehandOkHttpClient;
import com.browserbase.api.models.sessions.SessionObserveParams;
import com.browserbase.api.models.sessions.SessionObserveResponse;
public final class Main {
private Main() {}
public static void main(String[] args) {
StagehandClient client = StagehandOkHttpClient.fromEnv();
SessionObserveResponse response = client.sessions().observe("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.SessionObserveParams
import com.browserbase.api.models.sessions.SessionObserveResponse
fun main() {
val client: StagehandClient = StagehandOkHttpClient.fromEnv()
val response: SessionObserveResponse = client.sessions().observe("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.observe("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->observe(
'c4dbf3a9-9a58-4b22-8a1c-9f20f9f9e123',
frameID: 'frameId',
instruction: 'Find all clickable navigation links',
options: [
'ignoreSelectors' => ['nav', '.cookie-banner', '#sidebar-ads'],
'model' => [
'auth' => [
'credentials' => [
'clientEmail' => 'client_email',
'privateKey' => 'private_key',
'authProviderX509CertURL' => 'https://example.com',
'authUri' => 'https://example.com',
'clientID' => 'client_id',
'clientX509CertURL' => 'https://example.com',
'privateKeyID' => 'private_key_id',
'projectID' => 'project_id',
'tokenUri' => 'https://example.com',
'type' => 'service_account',
'universeDomain' => 'universe_domain',
],
'type' => 'googleServiceAccount',
'projectID' => 'projectId',
'scopes' => 'string',
'universeDomain' => 'universeDomain',
],
'modelName' => 'openai/gpt-5.4-mini',
'provider' => 'vertex',
'providerOptions' => [
'vertex' => [
'location' => 'us-central1',
'project' => 'my-gcp-project',
'baseURL' => 'https://example.com',
'headers' => ['foo' => 'string'],
],
],
'apiKey' => 'sk-some-openai-api-key',
'baseURL' => 'https://api.openai.com/v1',
'headers' => ['foo' => 'string'],
],
'selector' => 'nav',
'timeout' => 30000,
'variables' => [
'username' => [
'value' => 'john@example.com', 'description' => 'The login email'
],
'rememberMe' => true,
],
],
xStreamResponse: 'true',
);
var_dump($response);
} catch (APIException $e) {
echo $e->getMessage();
}using System;
using Stagehand;
using Stagehand.Models.Sessions;
StagehandClient client = new();
SessionObserveParams parameters = new()
{
ID = "c4dbf3a9-9a58-4b22-8a1c-9f20f9f9e123"
};
var response = await client.Sessions.Observe(parameters);
Console.WriteLine(response);curl --request POST \
--url https://api.stagehand.browserbase.com/v1/sessions/{id}/observe \
--header 'Content-Type: application/json' \
--header 'x-bb-api-key: <api-key>' \
--header 'x-bb-project-id: <api-key>' \
--data '
{
"instruction": "Find all clickable navigation links",
"options": {
"model": {
"modelName": "openai/gpt-5.4-mini",
"provider": "<string>",
"auth": {
"type": "<string>",
"credentials": {
"private_key": "<string>",
"client_email": "<string>",
"type": "<string>",
"project_id": "<string>",
"private_key_id": "<string>",
"client_id": "<string>",
"auth_uri": "<string>",
"token_uri": "<string>",
"auth_provider_x509_cert_url": "<string>",
"client_x509_cert_url": "<string>",
"universe_domain": "<string>"
},
"scopes": "<string>",
"projectId": "<string>",
"universeDomain": "<string>"
},
"providerOptions": {
"vertex": {
"project": "my-gcp-project",
"location": "us-central1",
"baseURL": "<string>",
"headers": {}
}
},
"apiKey": "sk-some-openai-api-key",
"baseURL": "https://api.openai.com/v1",
"headers": {}
},
"variables": {
"username": {
"value": "john@example.com",
"description": "The login email"
},
"rememberMe": true
},
"timeout": 30000,
"selector": "nav",
"ignoreSelectors": [
"nav",
".cookie-banner",
"#sidebar-ads"
]
},
"frameId": "<string>",
"streamResponse": true
}
'{
"success": true,
"data": {
"result": [
{
"selector": "[data-testid='submit-button']",
"description": "Click the submit button",
"backendNodeId": 123,
"method": "click",
"arguments": [
"Hello World"
]
}
],
"actionId": "<string>"
}
}
