Open New Tab
curl --request POST \
--url https://api.example.com/browser/sessions/{id}/pages \
--header 'Content-Type: application/json' \
--data '
{
"url": "<string>",
"activate": true
}
'import requests
url = "https://api.example.com/browser/sessions/{id}/pages"
payload = {
"url": "<string>",
"activate": True
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({url: '<string>', activate: true})
};
fetch('https://api.example.com/browser/sessions/{id}/pages', 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.example.com/browser/sessions/{id}/pages",
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([
'url' => '<string>',
'activate' => true
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$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.example.com/browser/sessions/{id}/pages"
payload := strings.NewReader("{\n \"url\": \"<string>\",\n \"activate\": true\n}")
req, _ := http.NewRequest("POST", url, payload)
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.example.com/browser/sessions/{id}/pages")
.header("Content-Type", "application/json")
.body("{\n \"url\": \"<string>\",\n \"activate\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/browser/sessions/{id}/pages")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"url\": \"<string>\",\n \"activate\": true\n}"
response = http.request(request)
puts response.read_body{
"pageId": "<string>",
"url": "<string>"
}Browser Sessions
Open New Tab
Open a new tab in the session, optionally navigating to a URL.
POST
/
browser
/
sessions
/
{id}
/
pages
Open New Tab
curl --request POST \
--url https://api.example.com/browser/sessions/{id}/pages \
--header 'Content-Type: application/json' \
--data '
{
"url": "<string>",
"activate": true
}
'import requests
url = "https://api.example.com/browser/sessions/{id}/pages"
payload = {
"url": "<string>",
"activate": True
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({url: '<string>', activate: true})
};
fetch('https://api.example.com/browser/sessions/{id}/pages', 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.example.com/browser/sessions/{id}/pages",
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([
'url' => '<string>',
'activate' => true
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$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.example.com/browser/sessions/{id}/pages"
payload := strings.NewReader("{\n \"url\": \"<string>\",\n \"activate\": true\n}")
req, _ := http.NewRequest("POST", url, payload)
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.example.com/browser/sessions/{id}/pages")
.header("Content-Type", "application/json")
.body("{\n \"url\": \"<string>\",\n \"activate\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/browser/sessions/{id}/pages")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"url\": \"<string>\",\n \"activate\": true\n}"
response = http.request(request)
puts response.read_body{
"pageId": "<string>",
"url": "<string>"
}Overview
The/browser/sessions/{id}/pages endpoint opens a new tab inside a browser session. Both body fields are optional:
- Omit
urlto openabout:blank. - Set
activate: falseto open the tab in the background without switching focus from the currently active tab.
pageId — the CDP target identifier used by /pages/{pageId}/activate and DELETE /pages/{pageId}.
Path Parameters
string
required
Browser session ID (UUID). Create via
POST /browser/sessions.Body
All body fields are optional.string
Optional URL to load in the new tab. Must use the
http or https scheme. When omitted, the tab opens to about:blank.boolean
default:"true"
When
true (default), the new tab becomes the active tab for subsequent session-scoped operations. Set false to open in the background.Example Request
curl -X POST "https://api.scrapengine.io/api/v1/browser/sessions/0f2b1f6a-88ac-4d25-bc58-67a6f4b4a001/pages" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{}'
curl -X POST "https://api.scrapengine.io/api/v1/browser/sessions/0f2b1f6a-88ac-4d25-bc58-67a6f4b4a001/pages" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"url": "https://example.com"
}'
curl -X POST "https://api.scrapengine.io/api/v1/browser/sessions/0f2b1f6a-88ac-4d25-bc58-67a6f4b4a001/pages" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"url": "https://example.com",
"activate": false
}'
const response = await fetch(
"https://api.scrapengine.io/api/v1/browser/sessions/0f2b1f6a-88ac-4d25-bc58-67a6f4b4a001/pages",
{
method: "POST",
headers: {
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json",
},
body: JSON.stringify({
url: "https://example.com",
activate: false,
}),
},
);
const data = await response.json();
import requests
url = "https://api.scrapengine.io/api/v1/browser/sessions/0f2b1f6a-88ac-4d25-bc58-67a6f4b4a001/pages"
headers = {
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json",
}
payload = {
"url": "https://example.com",
"activate": False,
}
response = requests.post(url, headers=headers, json=payload)
data = response.json()
Response
Success Response (201)
string
CDP target identifier of the newly-opened tab. Use this to activate or close it later.
string
Actual URL of the new tab after any redirects, or
about:blank when no URL was provided.{
"pageId": "EA5E9AA71C7A91C467F8CDBB266EE5E0",
"url": "https://example.com/"
}
Error Responses
| Status | Description |
|---|---|
400 | Invalid body — malformed URL or non-http(s) scheme. |
401 | Unauthorized — invalid or missing API key. |
404 | Session not found or not owned by the caller. |
408 | Navigation timeout while loading the supplied URL. |
503 | The browser session is temporarily unreachable. |
Notes
- An empty body opens an active
about:blanktab. - Pass
activate: falseto open in the background — the previously active tab remains active for subsequent mouse, keyboard, navigate, content, and screenshot calls. - Store the returned
pageId— it’s the handle you pass toPOST /pages/{pageId}/activateandDELETE /pages/{pageId}.
Was this page helpful?