Skip to main content
POST
/
v1
/
sessions
/
{id}
/
extract
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.extract('c4dbf3a9-9a58-4b22-8a1c-9f20f9f9e123');

console.log(response.data);
{
  "success": true,
  "data": {
    "result": "<unknown>",
    "actionId": "<string>"
  }
}

Authorizations

x-bb-api-key
string
header
required

Browserbase API key for authentication

x-bb-project-id
string
header
required

Browserbase project ID

x-model-api-key
string
header
required

API key for the AI model provider (OpenAI, Anthropic, etc.)

Headers

x-stream-response
enum<string>

Whether to stream the response via SSE

Available options:
true,
false
Example:

"true"

x-sent-at
string<date-time>

ISO timestamp when request was sent

Example:

"2025-01-15T10:30:00Z"

Path Parameters

id
string
required

Unique session identifier

Example:

"c4dbf3a9-9a58-4b22-8a1c-9f20f9f9e123"

Body

application/json
instruction
string

Natural language instruction for what to extract

Example:

"Extract all product names and prices from the page"

schema
object

JSON Schema defining the structure of data to extract

options
object
frameId
string

Target frame ID for the extraction

streamResponse
boolean

Whether to stream the response via SSE

Example:

true

Response

200 - application/json

Default Response

success
boolean
required

Indicates whether the request was successful

data
object
required