Skip to main content
POST
/
v1
/
sessions
/
{id}
/
act
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.act('c4dbf3a9-9a58-4b22-8a1c-9f20f9f9e123', {
  input: 'Click the login button',
});

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.act(
id="c4dbf3a9-9a58-4b22-8a1c-9f20f9f9e123",
input="Click the login button",
):
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.Act(
context.TODO(),
"c4dbf3a9-9a58-4b22-8a1c-9f20f9f9e123",
stagehand.SessionActParams{
Input: stagehand.SessionActParamsInputUnion{
OfString: stagehand.String("Click the login button"),
},
},
)
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.SessionActParams;
import com.browserbase.api.models.sessions.SessionActResponse;

public final class Main {
private Main() {}

public static void main(String[] args) {
StagehandClient client = StagehandOkHttpClient.fromEnv();

SessionActParams params = SessionActParams.builder()
.id("c4dbf3a9-9a58-4b22-8a1c-9f20f9f9e123")
.input("Click the login button")
.build();
SessionActResponse response = client.sessions().act(params);
}
}
package com.browserbase.api.example

import com.browserbase.api.client.StagehandClient
import com.browserbase.api.client.okhttp.StagehandOkHttpClient
import com.browserbase.api.models.sessions.SessionActParams
import com.browserbase.api.models.sessions.SessionActResponse

fun main() {
val client: StagehandClient = StagehandOkHttpClient.fromEnv()

val params: SessionActParams = SessionActParams.builder()
.id("c4dbf3a9-9a58-4b22-8a1c-9f20f9f9e123")
.input("Click the login button")
.build()
val response: SessionActResponse = client.sessions().act(params)
}
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.act("c4dbf3a9-9a58-4b22-8a1c-9f20f9f9e123", input: "Click the login button")

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->act(
'c4dbf3a9-9a58-4b22-8a1c-9f20f9f9e123',
input: 'Click the login button',
frameID: 'frameId',
options: [
'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'],
],
'timeout' => 30000,
'variables' => [
'username' => 'john_doe',
'password' => [
'value' => 'secret123', 'description' => 'The login password'
],
],
],
xStreamResponse: 'true',
);

var_dump($response);
} catch (APIException $e) {
echo $e->getMessage();
}
using System;
using Stagehand;
using Stagehand.Models.Sessions;

StagehandClient client = new();

SessionActParams parameters = new()
{
ID = "c4dbf3a9-9a58-4b22-8a1c-9f20f9f9e123",
Input = "Click the login button",
};

var response = await client.Sessions.Act(parameters);

Console.WriteLine(response);
curl --request POST \
--url https://api.stagehand.browserbase.com/v1/sessions/{id}/act \
--header 'Content-Type: application/json' \
--header 'x-bb-api-key: <api-key>' \
--header 'x-bb-project-id: <api-key>' \
--data '
{
"input": "Click the login button",
"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": "john_doe",
"password": {
"value": "secret123",
"description": "The login password"
}
},
"timeout": 30000
},
"frameId": "<string>",
"streamResponse": true
}
'
{
  "success": true,
  "data": {
    "result": {
      "success": true,
      "message": "Successfully clicked the login button",
      "actionDescription": "Clicked button with text 'Login'",
      "actions": [
        {
          "selector": "[data-testid='submit-button']",
          "description": "Click the submit button",
          "backendNodeId": 123,
          "method": "click",
          "arguments": [
            "Hello World"
          ]
        }
      ]
    },
    "actionId": "<string>"
  }
}

Authorizations

x-bb-api-key
string
header
required

Browserbase API key for authentication

x-bb-project-id
string
header
required

Deprecated. Browserbase API keys are now project-scoped, so this header is no longer required.

Headers

x-stream-response
enum<string>

Whether to stream the response via SSE

Available options:
true,
false
Example:

"true"

Path Parameters

id
string
required

Unique session identifier

Example:

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

Body

application/json
input
required

Natural language instruction or Action object

Example:

"Click the login button"

options
object
frameId
string | null

Target frame ID for the action

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