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

# Screenshot

> Capture a full-page screenshot of any URL as a PNG or JPEG image.

## Authentication

Requires an API key in the `Authorization` header.

```bash theme={"dark"}
Authorization: Bearer YOUR_API_KEY
```

## Request

<ParamField body="url" type="string" required>
  The URL to capture. Must be a valid `http://` or `https://` URL.
</ParamField>

<ParamField body="full_page" type="boolean">
  Capture the entire scrollable page rather than just the viewport. Default: `true`.
</ParamField>

<ParamField body="format" type="string">
  Image format — `png` (default) or `jpeg`.
</ParamField>

<ParamField body="selector" type="string">
  Optional CSS selector to capture a single element instead of the full page.
</ParamField>

<ParamField body="render_js" type="boolean">
  Render the page in a headless browser before capturing. Default: `true`.
</ParamField>

<ParamField body="block_ads" type="boolean">
  Block ad networks while loading. Default: `true`.
</ParamField>

<ParamField body="block_trackers" type="boolean">
  Block tracking scripts while loading. Default: `true`.
</ParamField>

<ParamField body="wait_for" type="string">
  CSS selector to wait for before capturing (useful for lazy-loaded content).
</ParamField>

<ParamField body="timeout" type="integer">
  Page load timeout in milliseconds. Default: `30000`. Maximum: `60000`.
</ParamField>

<ParamField body="headers" type="object">
  Optional custom request headers to send with the page load.
</ParamField>

### Example request

<CodeGroup>
  ```bash cURL theme={"dark"}
  curl -X POST "https://encrata.com/api/agent/screenshot" \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{ "url": "https://example.com", "full_page": true, "format": "png" }'
  ```

  ```python Python theme={"dark"}
  import requests

  resp = requests.post(
      "https://encrata.com/api/agent/screenshot",
      headers={"Authorization": "Bearer YOUR_API_KEY"},
      json={"url": "https://example.com", "full_page": True, "format": "png"},
  )
  print(resp.json())
  ```

  ```javascript JavaScript theme={"dark"}
  const resp = await fetch("https://encrata.com/api/agent/screenshot", {
    method: "POST",
    headers: {
      Authorization: "Bearer YOUR_API_KEY",
      "Content-Type": "application/json",
    },
    body: JSON.stringify({ url: "https://example.com", full_page: true, format: "png" }),
  });
  const data = await resp.json();
  ```
</CodeGroup>

## Response

<ResponseField name="success" type="boolean">
  Whether the screenshot succeeded.
</ResponseField>

<ResponseField name="url" type="string">
  The final URL that was captured (after redirects).
</ResponseField>

<ResponseField name="status_code" type="integer">
  HTTP status code returned by the target page.
</ResponseField>

<ResponseField name="screenshot" type="string">
  The captured image as a base64-encoded data string.
</ResponseField>

<ResponseField name="format" type="string">
  The image format of the returned screenshot (`png` or `jpeg`).
</ResponseField>

<ResponseField name="metadata" type="object">
  Page metadata such as `title` and dimensions.
</ResponseField>

<ResponseField name="error_code" type="string">
  Machine-readable error code when `success` is `false`.
</ResponseField>

<ResponseField name="error" type="string">
  Human-readable error message when `success` is `false`.
</ResponseField>

<ResponseField name="credits" type="integer">
  Credits consumed. `0` on a failed (refunded) capture.
</ResponseField>

<ResponseField name="latency_ms" type="integer">
  Total processing time in milliseconds.
</ResponseField>

<ResponseExample>
  ```json theme={"dark"}
  {
    "success": true,
    "url": "https://example.com",
    "status_code": 200,
    "screenshot": "iVBORw0KGgoAAAANSUhEUgAA...",
    "format": "png",
    "metadata": {
      "title": "Example Domain"
    },
    "credits": 5,
    "latency_ms": 3120
  }
  ```
</ResponseExample>

## Credits

5 credits per request. Failed captures (blocked, captcha, rate-limited) are
automatically refunded.
