Headless Browser Quick Actions: Screenshots, Content, PDF, and Crawl
How Cloudflare Browser Run Quick Actions capture rendered pages, extract text, generate PDFs, and crawl sites—with limits, timeouts, and bot rules.
This page summarises Cloudflare Browser Run documentation on Quick Actions: stateless HTTP calls that load a URL or raw HTML in a headless browser and return screenshots, HTML, Markdown, PDFs, structured extracts, or multi-page crawl jobs. Use them when you need one request and no deployed automation script; for full scripting, Cloudflare points you to Puppeteer, Playwright, or CDP instead.
Quick Actions: what they are and how you call them
Section titled “Quick Actions: what they are and how you call them”Quick Actions are simple interfaces for common browser tasks—capture, extract, render, and crawl—without maintaining a long-lived browser session.
Quick Actions provide simple interfaces for common browser tasks like capturing screenshots, extracting HTML content, generating PDFs, and more. You can use Quick Actions in two ways:
REST API: HTTP endpoints for one-off requests or external integration. Workers Bindings: Call Quick Actions directly from a Cloudflare Worker using
env.BROWSER.quickAction().— Cloudflare, Quick Actions
Every Quick Action accepts either url or html (except /scrape, which also requires elements, and /json, which needs prompt or response_format). REST calls use an API token with Browser Run - Edit permission. The /crawl endpoint is REST-only.
REST API vs Workers Bindings
Section titled “REST API vs Workers Bindings”| Method | Authentication | Typical use |
|---|---|---|
REST POST to https://api.cloudflare.com/client/v4/accounts/<accountId>/browser-run/<action> |
Bearer API token | Cron jobs, external backends, one-off tools |
env.BROWSER.quickAction("<action>", { ... }) in a Worker |
Browser binding (no separate token for the action) | Low-latency fetches inside Cloudflare |
For a minimal REST screenshot, see Get started.
Which Quick Action endpoint to use
Section titled “Which Quick Action endpoint to use”Cloudflare lists these Quick Actions:
| Endpoint | Returns | When to choose it |
|---|---|---|
/content |
Fully rendered HTML (including <head>) |
Parsing or downstream processing of the live DOM |
/screenshot |
PNG/JPEG image bytes | Previews, QA, visual regression |
/pdf |
PDF file | Reports, invoices, printable snapshots |
/markdown |
Markdown text | Normalised article or doc text |
/snapshot |
Multiple formats in one response | HTML + screenshot (default), or add Markdown / accessibility tree |
/accessibilityTree |
Accessibility tree JSON | Roles, names, states for a11y or automation |
/scrape |
Matched elements (text, HTML, geometry) | Known CSS selectors (prices, headings) |
/json |
AI-extracted JSON | Natural-language or schema-guided extraction (Workers AI usage) |
/links |
Link list | Navigation audit, same-domain link harvest |
/crawl |
Async job; pages as HTML, Markdown, or JSON | Multi-page site harvest, knowledge bases |
Use Quick Actions when you need a fast, simple way to perform common browser tasks such as capturing screenshots, extracting HTML, or generating PDFs without writing complex scripts. For more advanced automation, custom workflows, or persistent browser sessions, use Puppeteer, Playwright, or CDP.
— Cloudflare, Quick Actions
/snapshot vs calling endpoints separately
Section titled “/snapshot vs calling endpoints separately”/snapshot combines formats so you do not issue separate calls for HTML, screenshots, Markdown, and the accessibility tree.
The
/snapshotendpoint combines multiple formats into a single request, so you do not need to call each endpoint separately. By default, it returns HTML content and a screenshot. You can use theformatsparameter to customize which formats are included, such as adding Markdown and the accessibility tree to the response.— Cloudflare, Capture multiple page formats
Accepted formats values are content, screenshot, markdown, and accessibilityTree. You must request at least two formats; for a single format, use the dedicated endpoint (for example /markdown).
Single-page capture: content, screenshot, PDF, and Markdown
Section titled “Single-page capture: content, screenshot, PDF, and Markdown”/content: fetch HTML after JavaScript runs
Section titled “/content: fetch HTML after JavaScript runs”The
/contentendpoint instructs the browser to navigate to a website and capture the fully rendered HTML of a page, including the head section, after JavaScript execution. This is ideal for capturing content from JavaScript-heavy or interactive websites.— Cloudflare, Fetch HTML
You can block heavy resources with rejectResourceTypes or rejectRequestPattern to speed loads (for example images and CSS on /content).
/screenshot and /pdf: visual outputs
Section titled “/screenshot and /pdf: visual outputs”Screenshots process HTML and JavaScript, then capture the rendered page. Default viewport is 1920×1080; screenshotOptions.fullPage captures the scrollable page. Setting quality requires a non-PNG type (otherwise you get a 400 error).
PDF generation supports url or html, custom styles via addStyleTag, headers/footers through pdfOptions, and request bodies up to 50 MB (Render PDF). Custom fonts can be injected with addStyleTag (Custom fonts).
/markdown and /accessibilityTree: normalised text and a11y structure
Section titled “/markdown and /accessibilityTree: normalised text and a11y structure”Markdown conversion strips styling for readable text and links (Extract Markdown). The accessibility tree includes roles, names, values, states, and hierarchy (Capture accessibility tree).
For /accessibilityTree, interestingOnly defaults to true (semantically meaningful nodes only). Setting root to a CSS selector anchors a subtree; if the selector misses, the tree is null. When root is set and interestingOnly is omitted, interestingOnly defaults to false.
/scrape, /links, and /json: targeted extraction
Section titled “/scrape, /links, and /json: targeted extraction”/scrape: passelements: [{ "selector": "h1" }, ...]; each match returnstext,html,attributes, and layout numbers (Scrape HTML elements)./links: all links on the page;excludeExternalLinks: truekeeps same-domain links (Retrieve links)./json: requiresurlorhtmlpluspromptand/orresponse_format(JSON Schema). Default extraction uses Workers AI (@cf/meta/llama-3.3-70b-instruct-fp8-fast); optionalcustom_aisupplies your own model credentials (Capture structured data using AI).
If /json returns empty results, Cloudflare recommends a clearer prompt, a defined schema, or a custom model (JSON extraction errors in the crawl doc mirrors the same guidance for crawl formats: ["json"]).
/crawl: asynchronous multi-page jobs
Section titled “/crawl: asynchronous multi-page jobs”Site-wide harvesting uses a two-step flow:
There are two steps to using the /crawl endpoint:
Initiate the crawl job — A POST request where you initiate the crawl and receive a response with a job id. Request results of the crawl job — Monitor the crawl with an event subscription or GET request. When it finishes, send a GET request for the results.
— Cloudflare, Crawl web content
Job constraints from the same page:
- Maximum run time: 7 days (then
cancelled_due_to_timeout). - Results kept 14 days after completion.
- Poll with
GET .../crawl/{job_id}?limit=1for lightweight status checks.
Statuses include running, completed, errored, cancelled_due_to_limits, cancelled_by_user, and several cancelled_* variants. Per-URL record statuses include completed, disallowed, skipped, errored, and queued. Filter with query parameters such as status=errored or status=skipped.
render, formats, and scope
Section titled “render, formats, and scope”| Parameter | Default | Effect |
|---|---|---|
render |
true |
true: headless browser + JS; false: fast HTML fetch on Workers |
limit |
10 (max 100,000) | Page cap |
depth |
100,000 (max 100,000) | Link depth from start URL |
source |
all |
all, sitemaps, or links |
formats |
["html"] |
Also markdown, json (Workers AI for JSON) |
When render is true, standard Browser Run parameters (cookies, gotoOptions, rejectResourceTypes, etc.) apply; when render is false, only crawl-specific parameters apply unless noted in the crawl endpoint reference.
crawlPurposes and contentUse declare intent for sites using Content Signals; mismatches against the target site’s directives can return 400.
Crawl identity, robots.txt, and rate limits
Section titled “Crawl identity, robots.txt, and rate limits”The crawl user agent is fixed:
The
/crawlendpoint uses CloudflareBrowserRenderingCrawler/1.0 as its User-Agent, which is different from other Quick Actions endpoints. This User-Agent is not customizable. Unlike other Quick Actions endpoints, theuserAgentparameter is not supported on the /crawl endpoint.— Cloudflare, Crawl web content
Crawl respects robots.txt (including crawl-delay); otherwise a 0.5 s default delay applies between requests to the same domain. Disallowed URLs appear with "status": "disallowed". Bot protection (Turnstile, WAF, Bot Management) is not bypassed; bot detection ID for crawl is 128292352 (Automatic request headers).
JavaScript-heavy pages: gotoOptions.waitUntil and timeouts
Section titled “JavaScript-heavy pages: gotoOptions.waitUntil and timeouts”Incomplete screenshots, HTML, or scrapes usually mean capture happened before dynamic content finished.
For JavaScript-heavy pages or Single Page Applications (SPAs), the default page load behavior may return empty or incomplete results. This happens because the browser considers the page loaded before JavaScript has finished rendering the content.
The simplest solution is to use the gotoOptions.waitUntil parameter set to networkidle0 or networkidle2:
— Cloudflare, FAQ: Why is my page content missing or incomplete?
waitUntil |
Behavior |
|---|---|
domcontentloaded |
Default; DOM ready, often before JS finishes |
networkidle0 |
No network activity for 500 ms |
networkidle2 |
At most two connections for 500 ms |
Faster than full idle: waitForSelector when you know a CSS selector that signals ready content (Quick Actions timeouts). Key timers: goToOptions.timeout (default 30 s, max 60 s), waitForSelector (max 60 s), actionTimeout (default up to 5 min for the capture action).
Authentication, user agent, and caching
Section titled “Authentication, user agent, and caching”Rendering logged-in pages
Section titled “Rendering logged-in pages”These parameters work on all Quick Actions (FAQ):
- HTTP Basic:
authenticate: { username, password } - Cookies:
cookiesarray withname,value,domain,path - Tokens:
setExtraHTTPHeaders(for exampleAuthorization)
Worked examples appear under Capture screenshot (authenticated page sections).
Custom userAgent (not on /crawl)
Section titled “Custom userAgent (not on /crawl)”Quick Actions (except crawl) default to a Chrome 119–style string and allow userAgent in the JSON body (Automatic request headers).
The userAgent parameter does not bypass bot protection. Requests from Browser Run will always be identified as a bot.
— Cloudflare, Set a custom user agent (same note on other Quick Action pages)
Sites should identify Browser Run via non-configurable headers and Web Bot Auth signatures, not User-Agent alone.
Short-lived cache on Quick Actions
Section titled “Short-lived cache on Quick Actions”For Quick Actions (except the /crawl endpoint), generated content is cached by default for five seconds (configurable up to one day via the cacheTTL parameter, or set to 0 to disable caching).
— Cloudflare, FAQ
Customer-submitted html is not cached. Crawl results live in R2 for 14 days after the job completes.
Common mistakes and troubleshooting
Section titled “Common mistakes and troubleshooting”- Empty SPA output — Use
networkidle2orwaitForSelector; raisegoToOptions.timeout(FAQ). - 422 / slow action — Increase
actionTimeout(Quick Actions timeouts). - Crawl: all
skippedor empty records — Checkrobots.txtforCloudflareBrowserRenderingCrawler/1.0; relaxincludePatterns; trysource: "sitemaps"or more depth (Crawl troubleshooting). - Crawl: slow jobs — Use
render: falsefor static HTML; block images/fonts withrejectResourceTypes; remember shared per-domain rate limits across concurrent jobs. - Screenshot blur at large viewport — Raise
viewport.deviceScaleFactor(screenshot and snapshot docs). - Expecting stealth — Custom User-Agent does not evade bot checks; allowlist Browser Run on your own zone if you control it (WAF skip; Quick Actions bot ID 119853733, crawl 128292352).
Optional browser engine: add query ?browser=kitesurf to any Quick Action URL (Kitesurf).
More recipes live in Browser Run examples.
How to check this on your site
Section titled “How to check this on your site”-
Create a Cloudflare API token with Browser Run - Edit and call one Quick Action (for example
/contentor/screenshot) against a public test URL; confirmsuccess: trueand non-empty output. -
If the target page is a SPA, repeat the same call with
gotoOptions.waitUntilset tonetworkidle2and compare body length or screenshot to the first run (FAQ, Quick Actions timeouts). -
For a multi-page check, start a small
/crawljob with lowlimit, poll untilstatusis terminal, then inspectrecordsforcompletedvsdisallowed/errored. -
If you own the origin, verify
robots.txtallowsCloudflareBrowserRenderingCrawler/1.0for crawl tests and that Bot Management or WAF is not blocking Quick Actions without an allow rule (Automatic request headers). -
You can check automatically in Answerwell (our tool): https://answerwell.org/workspace
Report an error or ask a question
Section titled “Report an error or ask a question”If something on this page looks wrong or you need a detail clarified, email yimasynthetic@gmail.com with the page URL and the exact statement you are asking about.