Render a screenshot
Render a web page (`url`) or a raw HTML string (`html`) to a PNG, JPEG, WebP image, or a PDF. Provide **exactly one** of `url` or `html`. By default the request is **synchronous**: dOCR renders the page and returns the finished screenshot record (with a hosted `url`) in the response. Set `async: true` to return immediately with a `pending` record and receive a [`screenshot.completed`](/docs/guides/webhooks) webhook when the render finishes. Each successful render costs **1 credit**. Cache hits and failed renders cost nothing. See the [Screenshots guide](/docs/guides/screenshots) for a full walkthrough of formats, devices, caching, and signed URLs.
API key as a Bearer token: Authorization: Bearer docr_sk_…
In: header
URL to render. Provide exactly one of url or html.
uriRaw HTML to render. Provide exactly one of url or html.
Output format.
"png""png" | "jpeg" | "webp" | "avif" | "tiff" | "pdf"Capture the entire scrollable page rather than just the viewport.
falseViewport width in pixels. Ignored when device is set.
1280100 <= value <= 3840Viewport height in pixels. Ignored when device is set.
1024100 <= value <= 4320A device preset. When set, it overrides viewportWidth,
viewportHeight, and deviceScaleFactor.
"iphone_15" | "iphone_se" | "pixel_8" | "ipad" | "macbook" | "desktop"Pixel density. 2 produces a retina-resolution image.
11 <= value <= 3Compression quality for jpeg and webp. Ignored for png.
800 <= value <= 100Render a transparent background (PNG/WebP).
falseBlock known ad networks before rendering.
falseHide common cookie-consent banners.
falseHide common chat and support widgets.
falseSeconds to wait after the page loads before capturing.
00 <= value <= 30The navigation lifecycle event to wait for before capturing.
"load""load" | "domcontentloaded" | "networkidle0" | "networkidle2"Wait until this CSS selector appears before capturing.
Maximum seconds to wait for navigation before failing.
601 <= value <= 90Emulate prefers-color-scheme: dark.
Reuse a previously stored render for an identical set of options. A cache hit returns instantly and costs 0 credits.
falseHow long a cached render stays valid, in seconds (4 hours–30 days).
14400 <= value <= 2592000Render in the background. Returns a 202 with a pending record;
completion is delivered to webhookUrl and your account webhooks.
falseURL to receive the completion event when async is true.
uriPersist the render to storage and return a hosted url. Set to
false to stream the raw bytes back in the response without storing.
trueCSS selector of a single element to screenshot (instead of the page).
CSS selector to scroll into view before capturing.
Left offset of the capture region (with clipY/clipWidth/clipHeight).
Top offset of the capture region.
Width of the capture region. Must be set together with clipHeight.
Height of the capture region. Must be set together with clipWidth.
Emulate a mobile device (respects the meta viewport tag).
falseEmulate touch support.
falseEmulate landscape orientation.
falseResize the output image to this width (thumbnail), preserving aspect ratio.
Resize the output image to this height (thumbnail), preserving aspect ratio.
Scroll to the bottom and back before capturing, to trigger lazy-loaded content.
falseCap the height (px) of a full-page capture; handles infinite-scroll pages.
Print background graphics in the PDF.
trueUse landscape orientation.
falsePaper size for the PDF.
"a0" | "a1" | "a2" | "a3" | "a4" | "a5" | "a6" | "letter" | "legal" | "tabloid" | "ledger"Size the PDF page to fit the full content on one page.
falseUniform PDF margin in px (overridden by per-side margins).
Emulate prefers-reduced-motion: reduce.
falseEmulate the CSS media type.
"screen" | "print"CSS selectors to hide (display:none) before capturing.
CSS selector to click before capturing.
CSS selector to hover before capturing.
Custom CSS injected into the page.
Custom JavaScript evaluated in the page before capturing.
Block common analytics/tracker requests.
falseBlock requests of these resource types.
Block requests whose URL matches these glob patterns (e.g. *.ads.com/*).
Override the User-Agent header.
Value for the Authorization request header (for protected pages).
Cookies to set, each name=value; Domain=...; Path=/; Secure.
Extra request headers, each Header-Name: value.
Emulate this IANA time zone (e.g. America/New_York).
Bypass the page's Content-Security-Policy (needed for some injected scripts).
falseMax seconds to wait for the target site to respond.
301 <= value <= 30Screenshot the page even when the host responds with a 4xx/5xx status.
falseFail the render if any network request fails during load.
falseFail the render if the page text contains this string (case-insensitive).
Fail the render if the page text does NOT contain this string.
Return the rendered image's width/height/bytes in metadata.
falseReturn the page <title> in metadata.
falseReturn the page favicon URL in metadata.
falseReturn Open Graph / Twitter card tags in metadata.
falseReturn the page HTML content in metadata.
falseReturn the host HTTP status code in metadata.
falseReturn the host HTTP response headers in metadata.
falseCustom cache key (overrides the computed one) when cache is true.
Sign the one-off webhookUrl delivery with your org signing secret.
trueAlso deliver screenshot.failed events to webhookUrl.
falseCorrelation id echoed back in webhook events and the X-docr-External-Identifier header.
Response Body
application/json
application/json
application/json
application/json
application/json
application/json
curl -X POST "https://app.docr.dev/api/v1/screenshots" \ -H "Content-Type: application/json" \ -d '{ "url": "https://example.com", "format": "png", "fullPage": true, "viewportWidth": 1280 }'{
"screenshot": {
"id": "6a382443304f240b189f228a",
"orgId": "string",
"kind": "screenshot",
"status": "pending",
"format": "png",
"url": "https://res.cloudinary.com/docr/image/upload/screenshot-6a382443.png",
"width": 1280,
"height": 3840,
"fullPage": true,
"cacheHit": true,
"creditsUsed": 1,
"externalIdentifier": "string",
"metadata": {},
"error": "string",
"createdAt": "2019-08-24T14:15:22Z",
"updatedAt": "2019-08-24T14:15:22Z"
}
}{
"screenshot": {
"id": "6a382443304f240b189f228a",
"orgId": "string",
"kind": "screenshot",
"status": "pending",
"format": "png",
"url": "https://res.cloudinary.com/docr/image/upload/screenshot-6a382443.png",
"width": 1280,
"height": 3840,
"fullPage": true,
"cacheHit": true,
"creditsUsed": 1,
"externalIdentifier": "string",
"metadata": {},
"error": "string",
"createdAt": "2019-08-24T14:15:22Z",
"updatedAt": "2019-08-24T14:15:22Z"
}
}{
"error": "string"
}{
"error": "Invalid or revoked API key"
}{
"error": "Credit limit reached (100/100). Upgrade your plan."
}{
"error": "IP 203.0.113.4 is not whitelisted"
}{
"error": "string"
}