> ## Documentation Index
> Fetch the complete documentation index at: https://docs.scrapengine.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Open New Tab

> Open a new tab in the session, optionally navigating to a URL.

## Overview

The `/browser/sessions/{id}/pages` endpoint opens a new tab inside a browser session. Both body fields are optional:

* Omit `url` to open `about:blank`.
* Set `activate: false` to open the tab in the background without switching focus from the currently active tab.

The response returns the new tab's `pageId` — the CDP target identifier used by `/pages/{pageId}/activate` and `DELETE /pages/{pageId}`.

## Path Parameters

<ParamField path="id" type="string" required={true}>
  Browser session ID (UUID). Create via `POST /browser/sessions`.
</ParamField>

## Body

All body fields are optional.

<ParamField body="url" type="string">
  Optional URL to load in the new tab. Must use the `http` or `https` scheme. When omitted, the tab opens to `about:blank`.
</ParamField>

<ParamField body="activate" type="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.
</ParamField>

## Example Request

<CodeGroup>
  ```bash cURL (blank tab) theme={null}
  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 '{}'
  ```

  ```bash cURL (with URL) theme={null}
  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"
    }'
  ```

  ```bash cURL (background tab) theme={null}
  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
    }'
  ```

  ```javascript JavaScript theme={null}
  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();
  ```

  ```python Python theme={null}
  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()
  ```
</CodeGroup>

## Response

### Success Response (201)

<ResponseField name="pageId" type="string">
  CDP target identifier of the newly-opened tab. Use this to activate or close it later.
</ResponseField>

<ResponseField name="url" type="string">
  Actual URL of the new tab after any redirects, or `about:blank` when no URL was provided.
</ResponseField>

**Example Response:**

```json theme={null}
{
  "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:blank` tab.
* Pass `activate: false` to 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 to `POST /pages/{pageId}/activate` and `DELETE /pages/{pageId}`.
