> ## 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.

# Screenshot

> Capture a PNG screenshot of the active page, full-page or element-scoped.

## Overview

Captures a PNG of the session's active page and returns it base64-encoded. Supports viewport, full-page, and element-bounded capture via a CSS selector.

## Path Parameters

<ParamField path="id" type="string" required={true}>
  Browser session ID (UUID).
</ParamField>

## Body

<ParamField body="url" type="string">
  Optional URL to navigate to before capturing.
</ParamField>

<ParamField body="fullPage" type="boolean" default="false">
  When true, capture the full scrollable document height instead of just the viewport.
</ParamField>

<ParamField body="selector" type="string">
  CSS selector of an element to capture. Clipped to the element's bounding box.
</ParamField>

## Example Request

<CodeGroup>
  ```bash cURL (viewport) theme={null}
  curl -X POST "https://api.scrapengine.io/api/v1/browser/sessions/baa3f390-fa6e-4a24-b84a-a575a5f3a9c7/screenshot" \
    -H "Authorization: Bearer $SCRAPENGINE_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{}'
  ```

  ```bash cURL (full page) theme={null}
  curl -X POST "https://api.scrapengine.io/api/v1/browser/sessions/baa3f390-fa6e-4a24-b84a-a575a5f3a9c7/screenshot" \
    -H "Authorization: Bearer $SCRAPENGINE_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "url": "https://example.com",
      "fullPage": true
    }'
  ```
</CodeGroup>

## Response

### Success Response (200)

<ResponseField name="image" type="string">
  Base64-encoded PNG bytes.
</ResponseField>

<ResponseField name="url" type="string">
  Effective URL after any redirects.
</ResponseField>

<ResponseField name="width" type="integer">
  Screenshot width in pixels.
</ResponseField>

<ResponseField name="height" type="integer">
  Screenshot height in pixels.
</ResponseField>

**Example Response:**

```json theme={null}
{
  "url": "https://example.com/",
  "image": "iVBORw0KGgoAAAANSUhEUgAA...",
  "width": 1920,
  "height": 1080
}
```

### Error Responses

| Status | Description                                                |
| ------ | ---------------------------------------------------------- |
| `400`  | Invalid body — bad selector or unreachable URL.            |
| `401`  | Unauthorized — invalid or missing API key.                 |
| `404`  | Session not found, or selector matched no visible element. |
| `503`  | The browser session is temporarily unreachable.            |
