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

# Synchronous screenshot

> The `screenshot` endpoint runs a browser session, executes JavaScript, and returns a base64-encoded image in a single synchronous request.

## Getting started

### Base URL

```
https://screenshot.cleariflow.com/v1/screenshot
```

### Example request

```bash theme={"system"}
curl -X POST 'https://screenshot.cleariflow.com/v1/screenshot' \
  -H 'Content-Type: application/json' \
  -d '{
    "api_key": "YOUR_UNIQUE_API_KEY",
    "url": "https://cleariflow.com",
    "capture_full_page": true,
    "export_format": "jpeg"
  }'
```

This successful request returns the screenshot as base64 and metadata:

```json theme={"system"}
{
  "ok": true,
  "image_base64": "/9j/4AAQSkZJRg...",
  "content_type": "image/jpeg",
  "meta": {
    "elapsed_ms": 4521
  }
}
```

Decode `image_base64` to obtain the raw JPEG or PNG bytes.

### Render options

The `render` object controls how the browser loads the page before the screenshot is taken. All fields are optional — when omitted, server defaults apply.

```json theme={"system"}
{
  "render": {
    "wait_until": "networkidle",
    "timeout_ms": 60000,
    "post_load_wait_ms": 2000,
    "ignore_https_errors": false,
    "full_page": true,
    "screenshot_format": "jpeg",
    "user_agent": "Mozilla/5.0 ...",
    "viewport": {
      "width": 1365,
      "height": 768
    }
  }
}
```

| Field | Type | Default | Description |
| - | - | - | - |
| `wait_until` | String | `domcontentloaded` | When to consider navigation finished. Use `domcontentloaded` for faster results; use `networkidle` when the page loads data via XHR/fetch after the initial HTML. |
| `timeout_ms` | Integer | `60000` | Maximum time in milliseconds to wait for page load. |
| `post_load_wait_ms` | Integer | `0` | Extra delay in milliseconds after `wait_until` before capture. Useful for animations or lazy-loaded content. |
| `ignore_https_errors` | Boolean | `false` | When `true`, ignore TLS certificate errors on the target page. |
| `full_page` | Boolean | `true` | When `true`, capture the entire scrollable page height. |
| `screenshot_format` | String | `jpeg` | Output format: `jpeg` or `png`. |
| `user_agent` | String | — | Custom User-Agent string for the browser session. |
| `viewport` | Object | `1365×768` | Viewport size via `width` and `height` in pixels. |

### Convenience fields

These top-level fields are aliases merged into `render` and `actions` for backward compatibility and simpler requests:

| Field | Maps to | Description |
| - | - | - |
| `capture_full_page` | `render.full_page` | Full-page capture toggle. |
| `width` / `height` | `render.viewport` | Viewport dimensions in pixels. |
| `delay` | `render.post_load_wait_ms` | Delay in **seconds** before capture. |
| `export_format` | `render.screenshot_format` | `jpeg` or `png`. |
| `user_agent` | `render.user_agent` | Custom User-Agent. |
| `css_injection` | `inject_css` action | CSS injected before capture when no `inject_css` action is present. |

Example with flat fields:

```bash theme={"system"}
curl -X POST 'https://screenshot.cleariflow.com/v1/screenshot' \
  -H 'Content-Type: application/json' \
  -d '{
    "api_key": "YOUR_UNIQUE_API_KEY",
    "url": "https://cleariflow.com",
    "width": 1280,
    "height": 720,
    "delay": 2,
    "export_format": "png"
  }'
```

### Resource options

The `resources` object controls which asset types the browser loads during capture. Blocking heavy assets speeds up requests when visual fidelity allows it.

```json theme={"system"}
{
  "resources": {
    "block": ["images", "fonts", "media"]
  }
}
```

| Value | Blocks |
| - | - |
| `images` | Images (`<img>`, CSS backgrounds) |
| `fonts` | Web fonts |
| `media` | Video and audio streams |

### Legacy GET endpoint

`GET /v1/` returns raw image bytes (JPEG or PNG) instead of JSON. Pass parameters as query strings:

```
https://screenshot.cleariflow.com/v1/?api_key=YOUR_UNIQUE_API_KEY&url=https://cleariflow.com&capture_full_page=true&export_format=jpeg
```

Supported query parameters: `url`, `api_key`, `session_id`, `fingerprint`, `capture_full_page`, `width`, `height`, `delay`, `css_injection`, `user_agent`, `export_format`.

### Request parameters

**url** `String` *required*

The target URL to capture. Must be a public HTTP or HTTPS URL. Requests to localhost and private IP addresses are blocked by SSRF protection.

**api\_key** `String` *required*

Your unique API key.

**session\_id** `String`

Optional session identifier to reuse browser state (cookies, local storage) across multiple requests.

**fingerprint** `String`

Browser fingerprint preset. Supported values: `desktop_en_us`, `desktop_ru_ru`, `mobile_en_us`.

**render** `Object`

Rendering and capture options for the browser session.

**render.wait\_until** `String`

When to consider navigation finished. Values: `domcontentloaded`, `networkidle`. Defaults to `domcontentloaded`.

**render.timeout\_ms** `Integer`

Maximum time in milliseconds to wait for page load. Defaults to 60000.

**render.post\_load\_wait\_ms** `Integer`

Additional delay in milliseconds after the page load event before capture.

**render.ignore\_https\_errors** `Boolean`

When `true`, ignore TLS certificate errors for the target page.

**render.full\_page** `Boolean`

When `true`, capture the full scrollable page. Defaults to `true`.

**render.screenshot\_format** `String`

Output format: `jpeg` or `png`. Defaults to `jpeg`.

**render.user\_agent** `String`

Custom User-Agent for the browser session.

**render.viewport** `Object`

Viewport size with `width` and `height` in pixels.

**resources** `Object`

Resource loading controls.

**resources.block** `Array`

Resource types to block. Supported values: `images`, `fonts`, `media`.

**actions** `Array`

Ordered list of browser actions to perform before capture. Each action is an object with a `type` field.

**actions\[].type** `String` *required*

Action type. Supported values: `wait`, `wait_for`, `click`, `type`, `scroll`, `inject_css`.

**actions\[].selector** `String`

CSS selector for `wait_for`, `click`, or `type` actions.

**actions\[].text** `String`

Text to type for the `type` action.

**actions\[].css** `String`

CSS string for the `inject_css` action.

**actions\[].to** `String`

Scroll target for the `scroll` action (e.g. `bottom`).

**actions\[].wait\_ms** `Integer`

Duration in milliseconds for the `wait` action.

**cookies** `Array`

Cookies to inject before navigation. Each cookie object requires `name` and `value`; optional fields: `domain`, `path`.

**capture\_full\_page** `Boolean`

Convenience alias for `render.full_page`.

**width** `Integer`

Convenience alias for `render.viewport.width`.

**height** `Integer`

Convenience alias for `render.viewport.height`.

**delay** `Integer`

Delay in seconds before capture. Mapped to `render.post_load_wait_ms`.

**css\_injection** `String`

CSS injected via an `inject_css` action when not already present in `actions`.

**export\_format** `String`

Convenience alias for `render.screenshot_format`. Values: `jpeg`, `png`.

### Response parameters

The API response is returned in a universal and lightweight [JSON format](https://www.json.org/json-en.html).

**ok** `Boolean`

Whether the screenshot completed successfully.

**image\_base64** `String`

Base64-encoded image data. Decode to obtain raw JPEG or PNG bytes.

**content\_type** `String`

MIME type of the image (`image/jpeg` or `image/png`).

**meta** `Object`

Metadata about the capture, including elapsed time in milliseconds.

**error** `Object`

Error details when `ok` is `false`.


## OpenAPI

````yaml openapi/screenshot.json POST /v1/screenshot
openapi: 3.0.3
info:
  title: Cleariflow Website Screenshot API
  version: 1.0.0
  description: Capture website screenshots via GET or POST.
servers:
  - url: https://screenshot.cleariflow.com
security: []
paths:
  /v1/screenshot:
    post:
      summary: Synchronous screenshot (JSON response with base64 image)
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ScreenshotRequest'
      responses:
        '200':
          description: Screenshot result
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ScreenshotResponse'
        '400':
          description: Bad request
        '401':
          description: Unauthorized
        '429':
          description: Rate limit exceeded
components:
  schemas:
    ScreenshotRequest:
      type: object
      required:
        - url
      properties:
        url:
          type: string
          format: uri
        api_key:
          type: string
        session_id:
          type: string
        fingerprint:
          type: string
        render:
          $ref: '#/components/schemas/RenderOptions'
        resources:
          $ref: '#/components/schemas/ResourceOptions'
        actions:
          type: array
          items:
            $ref: '#/components/schemas/Action'
        cookies:
          type: array
          items:
            $ref: '#/components/schemas/Cookie'
        capture_full_page:
          type: boolean
          description: Convenience alias for render.full_page
        width:
          type: integer
          description: Convenience alias for render.viewport.width
        height:
          type: integer
          description: Convenience alias for render.viewport.height
        delay:
          type: integer
          description: Delay in seconds; mapped to render.post_load_wait_ms
        css_injection:
          type: string
          description: Injects CSS via inject_css action when not already present
        user_agent:
          type: string
          description: Convenience alias for render.user_agent
        export_format:
          type: string
          enum:
            - jpeg
            - png
          description: Convenience alias for render.screenshot_format
    ScreenshotResponse:
      type: object
      properties:
        ok:
          type: boolean
        image_base64:
          type: string
        content_type:
          type: string
        meta:
          type: object
          additionalProperties: true
        error:
          type: object
          additionalProperties: true
    RenderOptions:
      type: object
      properties:
        wait_until:
          type: string
          enum:
            - domcontentloaded
            - networkidle
        timeout_ms:
          type: integer
        post_load_wait_ms:
          type: integer
        ignore_https_errors:
          type: boolean
        full_page:
          type: boolean
        screenshot_format:
          type: string
          enum:
            - jpeg
            - png
        user_agent:
          type: string
        viewport:
          $ref: '#/components/schemas/ViewportOptions'
    ResourceOptions:
      type: object
      properties:
        block:
          type: array
          items:
            type: string
            enum:
              - images
              - fonts
              - media
    Action:
      type: object
      required:
        - type
      properties:
        type:
          type: string
          enum:
            - wait
            - wait_for
            - click
            - type
            - scroll
            - inject_css
        selector:
          type: string
        text:
          type: string
        attr:
          type: string
        to:
          type: string
        wait_ms:
          type: integer
        css:
          type: string
    Cookie:
      type: object
      required:
        - name
        - value
      properties:
        path:
          type: string
        value:
          type: string
        name:
          type: string
        domain:
          type: string
    ViewportOptions:
      type: object
      properties:
        width:
          type: integer
        height:
          type: integer

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.