# Screenshot API

The webcapture website screenshot API turns a public URL into a PNG, JPEG, or WebP capture by rendering it in a real Chromium browser. Full-page capture is the default, so long pages come back whole; the same POST can switch to the layout viewport, emulate a light or dark color scheme, or block ads first.

[Try it free without an account](https://webcapture.io/tools/url-to-screenshot), or keep reading for the API.

## Quick start

One POST. The connection is held until the file is ready; add `?wait=false` to get a ticket instead for async pickup.

```
curl -X POST \
  https://webcapture.io/v1/convert \
  -H "Authorization: Bearer wc_your_key" \
  -H "Content-Type: application/json" \
  -d '{"url": "https://example.com", "format": "png", "viewport": {"width": 1440, "height": 900}}'

200 {"id": "cnv_9f2c01ab", "bytes": 187442, "remaining": 49,
     "download": "https://webcapture.io/v1/conversions/cnv_9f2c01ab.pdf"}
```

The download path keeps its legacy .pdf suffix for every format; the content type and the filename tell the truth.

## What one call controls

All image parameters apply to PNG, JPEG, and WebP alike; the `format` field picks which of the three you get (the same field also carries `pdf` and `markdown` on other pages). Checked 2026-11-11 against the API reference ([/docs](https://webcapture.io/docs)); the type and default columns restate that reference, so nothing here is a second source of truth.

| Parameter | Type | Default | What it does |
| --- | --- | --- | --- |
| `format` | string | `png` on this page's examples; `pdf` is the endpoint default | `png`, `jpeg`, `webp`, plus `pdf` and `markdown` if you want documents from the same call. |
| `fullPage` | boolean | true | Capture the full scrollable page instead of the layout viewport. This is what makes very long pages come back whole. |
| `viewport` | object | none | Layout viewport set before capture, `width` and `height` each 200 to 7680 px. |
| `colorScheme` | string | `light` | `light`, `dark`, or `site` (keep the page's own preference). |
| `waitFor` | string | none | CSS selector the render waits for before the capture, 1 to 500 characters; capped at min(`settle`, 10 seconds). A selector that never appears fails the render. |
| `waitForNetwork` | boolean | off | Hold navigation until the network settles (networkidle) instead of the load event. |
| `settle` | integer ms | deployment default | Milliseconds to wait after load before the capture, 0 to 10000. |
| `blockAds` | boolean | false | Filter ad and tracker requests with community filter lists and hide leftover ad slots. Best effort: some sites show walls to blockers. |
| `quality` | integer | 80 | Encoder quality for JPEG and WebP only, 1 to 100; PNG is lossless and ignores it. |
| `dpi` | number | 1 | Output density 1 to 4, applied as the browser context's device scale factor; image formats only. |
| `clip` | object | none | Page coordinate region `{x, y, width, height}` to crop to. Mutually exclusive with `cssSelector`; requires fullPage (an explicit fullPage false is refused with 422). |
| `cssSelector` | string | none | Capture the matched element instead of the page, 1 to 500 characters; the render waits for the element to attach and scrolls it into view itself. |
| `filename` | string | derived from the page | Suggested download name, letters digits dot underscore dash, 1 to 100 characters. |

One correction this restructure makes explicit: the old table listed `scale` 0.1&ndash;2 here, but in the reference that knob is PDF-only; the image density dial is `dpi`, 1 to 4, and that is the row this table now carries.

## Screenshots of very long pages

Full page is on by default, so a dashboard or a 20,000 px article is one call with no scrolling script and no stitching. If you need a fixed frame instead, set `fullPage` false and size the `viewport`; use `waitFor` plus `settle` when lazy content loads late. The [free URL to screenshot tool](https://webcapture.io/tools/url-to-screenshot) runs the same defaults in the browser.

## Polling a capture instead of holding

The quick start holds the HTTP connection open until the pixels are ready, which is the right shape for a capture that takes a few seconds. When the caller is a queue worker, a cron job, or a serverless function with a hard execution budget, add `?wait=false` to the same POST: the endpoint answers `202` right away with a ticket instead of holding, and the ticket carries four fields: `id`, `status` (it starts `"queued"`), a `poll` URL, and the `download` URL that will serve the finished image once it exists.

GET the `poll` URL with the same Authorization header, no faster than about once a second. The status walks `queued` to `rendering` to `ready`, or stops at `failed` with an `error` message in the same body. The poll response also carries `attempts` (the render passes the conversion used; a clean capture reads 1) and, once ready, `bytes`. Renders usually finish in seconds rather than minutes, and a finished capture stays downloadable for at least seven days (30 on Scale), so the process that picks the file up does not have to be the one that queued it.

```
const ticket = await postConvert(key, { url: "https://example.com/dashboard", format: "png" }, { wait: false });
// 202 {"id": "cnv_...", "status": "queued",
//      "poll": ".../v1/conversions/cnv_...", "download": ".../v1/conversions/cnv_....pdf"}

let shot = ticket;
while (shot.status === "queued" || shot.status === "rendering") {
  await new Promise((r) => setTimeout(r, 1000)); // no faster than ~1 poll a second
  shot = await (await fetch(ticket.poll, { headers: { Authorization: `Bearer ${key}` } })).json();
}
if (shot.status === "failed") throw new Error(shot.error); // the render's own failure message
```

Prefer push to poll? A key with a `webhookUrl` receives a signed completion event when a capture finishes (a Pro and Scale feature). The poll endpoint stays the source of truth either way, because webhook delivery is best-effort and can arrive twice; dedupe on the conversion id.

## When a capture fails, the body says why

Every refusal is a JSON body with an `error` message, so a failure lands in your logs as a sentence rather than a bare status code. The statuses a screenshot pipeline actually meets: `401` means the Authorization header is missing, wrong, or the key was revoked; check the header before anything else. `404` on a poll or download means the id belongs to another key's account, not that the capture vanished. `422` is a rejected request: a non-public URL (private and local addresses are refused), a `waitFor` selector past its 500-character limit, or a `clip` paired with a viewport-only capture, which the endpoint refuses rather than trimming silently.

`429` comes in three kinds the body separates for you. The monthly quota wall carries `used`, `limit`, `resetDate`, and an `upgradeUrl`; nothing bills beyond quota: the capture waits for the month to turn over. A full render queue or a rate-limited address instead carries `retryAfterSec`: wait that many seconds and resend the same request unchanged; the queue-full kind also sets a matching `retry-after` header. The third kind is the account's in-flight cap (1, 3, or 10 concurrent renders by tier): its body names `code`, `feature`, `requiredTier`, and `upgradeUrl`, and the fix is to let an in-flight capture finish rather than send another. And `502` means the page itself refused to render, most often a bot wall; one retry later is reasonable, and a target that keeps refusing is out of scope by design.

```
const res = await fetch("https://webcapture.io/v1/convert", { method: "POST", headers, body });
if (!res.ok) {
  const body = await res.json(); // {"error": "..."} always; the 429s add fields
  if (res.status === 429 && body.resetDate) {
    console.log(`quota ${body.used}/${body.limit}, resets ${body.resetDate}; nothing billed`);
  } else if (res.status === 429 && body.retryAfterSec) {
    await new Promise((r) => setTimeout(r, body.retryAfterSec * 1000)); // resend unchanged
  } else {
    throw new Error(`${res.status}: ${body.error}`);
  }
}
```

## Honest limits

- No transparent-background option: captures keep whatever the page paints behind its content.
- `disableBackgrounds` is PDF only; it does not apply to images.
- `clip` cannot be combined with `cssSelector`, and it requires the full-page path.
- Ad blocking is best effort: community lists miss some slots, and hiding can shift a layout the same way an ad blocker in a normal browser would.

## How this compares

|  | webcapture | Urlbox | PDFShift | Browserless |
| --- | --- | --- | --- | --- |
| Sync by default | Yes | Yes | Queue-based | Yes |
| Free plan | Yes, 50 free renders (full API incl. MCP) | No, trial | No, trial | Time-based credit |
| Images (PNG/JPEG/WebP) | Yes | Yes | No, PDF only | Yes |
| PDF from the same call | Yes, same endpoint | Separate product | Yes | Separate endpoint |
| Markdown from the same call | Yes | No | No | No |

Cells come from the vendors' own documentation; the full grid with sources lives on the [comparison page](https://webcapture.io/compare). PDFShift's gap is the point: if you also need PDF or Markdown, this is one endpoint instead of two vendors. Sibling page: the [HTML to image API](https://webcapture.io/html-to-image-api) is the same capture path described for image pipelines.

## JavaScript

```
import { writeFile } from "node:fs/promises";

const key = process.env.WC_KEY;
const res = await fetch("https://webcapture.io/v1/convert", {
  method: "POST",
  headers: { "Authorization": `Bearer ${key}`, "Content-Type": "application/json" },
  body: JSON.stringify({ url: "https://example.com", format: "webp", quality: 82, colorScheme: "dark" }),
});
const receipt = await res.json();
const shot = await fetch(receipt.download, {
  headers: { "Authorization": `Bearer ${key}` },
});
await writeFile("capture.webp", Buffer.from(await shot.arrayBuffer()));
```

## A second capture: the nightly visual audit

The quick start fires one shot and exits. The second shape this page's buyers run is scheduled: every night, capture the same dashboard at a fixed viewport, in the dark scheme the team actually reads it in, waiting for the chart widget to mount before the shutter opens. Every knob the script needs is already in the table above: `viewport` pins the layout at 1440&times;900, `colorScheme` pins the palette, `waitFor` holds the capture until `#chart` exists, and `filename` names the archive file so a month of nightly captures sorts in any file browser.

```
const day = new Date().toISOString().slice(0, 10);
const res = await fetch("https://webcapture.io/v1/convert", {
  method: "POST",
  headers: { "Authorization": `Bearer ${key}`, "Content-Type": "application/json" },
  body: JSON.stringify({
    url: "https://example.com/dashboard",
    format: "png",
    viewport: { width: 1440, height: 900 },
    colorScheme: "dark",
    waitFor: "#chart",
    settle: 2000,           // two extra seconds after the chart mounts
    filename: `dashboard-${day}`,
  }),
});
if (!res.ok) throw new Error(`${res.status}: ${(await res.json()).error}`);
const receipt = await res.json();
const shot = await fetch(receipt.download, { headers: { Authorization: `Bearer ${key}` } });
await writeFile(`captures/dashboard-${day}.png`, Buffer.from(await shot.arrayBuffer()));
```

One honest note on comparing nights: run-over-run diffs are only as stable as the inputs. The same URL, viewport, color scheme, and engine version make two captures comparable; a redesigned page, a changed font, or an engine update moves the bytes for reasons that have nothing to do with a regression. Log the receipt's `id` and `attempts` alongside each capture so a diff review can tell a retry from a redesign.

## Which capture is yours?

Three shapes cover most of what gets sent to this endpoint. Each links the options that do the work, straight into the table above:

- **Whole-page archives.** A long article or a dashboard taller than any screen comes back in one call with no scrolling script and no stitching: leave `fullPage` on (that is the default) and the scroll height decides the capture. Start at the [fullPage](#p-fullpage) row; add `viewport` only when you want to pin which responsive layout the long capture renders.
- **Waiting on a widget.** A chart, a map, or a table that mounts after load: name it with `waitFor` and give the mount a `settle` budget, so the pixels land after the data does rather than before. The [waitFor](#p-waitfor) and [settle](#p-settle) rows carry the exact budgets; the nightly audit above is this shape written out.
- **Clean marketing shots.** Ad slots and trackers out, bytes at a chosen size: switch `blockAds` on, pick a `format`, and set `quality` where your delivery channel needs it. The [blockAds](#p-blockads), [format](#p-format), and [quality](#p-quality) rows say what each one costs you, including that blockAds is best effort and can shift a layout the way a browser ad blocker would.

Pricing: Free 50 renders a month, Pro $19 for 5,000, Scale $69 for 35,000. Every tier includes all five output formats; the full terms sit on [pricing](https://webcapture.io/pricing). Related reading in the [HTML to PDF guides](https://webcapture.io/guides).

## Render your first page in seconds

Mint a key, POST a URL, and the finished document comes back in the same response; pass ?wait=false for a job ticket with poll and download URLs. The first 50 renders a month are free, and there is no credit card. Not ready for a key? The free [URL to PDF tool](https://webcapture.io/tools/url-to-pdf) renders public pages without one.