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

# Screenshots & Visual Regression

Auto-capture failure screenshots and detect visual regressions against a baseline using perceptual hashing.

# Screenshots & Visual Regression

Two related but distinct features: **failure screenshots** capture what your site looked like when it went down. **Visual regression** compares each check against a baseline and flags pixel-level changes.

## Failure screenshots

When a monitor flips to `down` or `degraded`, Happy Uptime triggers a Cloudflare Browser Rendering session against the monitor's URL, captures a PNG at three viewports (desktop / tablet / mobile), and stores it in R2 keyed by `screenshots/{monitorId}/{checkResultId}.png`.

You see the screenshot:
- In the alert payload (Slack message includes a thumbnail link)
- On the monitor detail page in the dashboard
- Via `GET /screenshots?monitor_id=…`

Storage retention: 30 days for failure screenshots. Baselines are kept indefinitely.

## Visual regression

Enable `screenshot_compare: true` on the monitor, capture a baseline (one click in the dashboard), and every successful check thereafter:

1. Captures a fresh screenshot.
2. Computes a perceptual hash (pHash).
3. Compares against the baseline's hash.
4. If the diff exceeds `screenshot_threshold` (default `0.05`, range 0–1), fires a `visual_regression` alert.

Use cases:
- Marketing site got hijacked? Visual regression catches it before keyword monitoring.
- A deploy accidentally pushed staging banners to prod? Regression catches it.
- A vendor (e.g. payment provider iframe) breaks visually but still returns 200? Regression catches it.

## Per-viewport baselines

Capture separate baselines for desktop/tablet/mobile. Useful when responsive breakpoints render differently and you want to detect changes only at one breakpoint.

## Quick links

**[Screenshot API](/api/overview)**

List, fetch, and manage baselines.
  **[Monitor reference](/concepts/monitors)**

`screenshot_on_failure` + `screenshot_compare` flags.