# screenshotbase documentation > screenshotbase captures screenshots, PDFs and markdown of any web page or of HTML you send, and returns the result directly, or a hosted URL as JSON when using upload mode. Authenticate every request with your API key via the `apikey` query parameter or request header. Base URL: https://api.screenshotbase.com OpenAPI specification: https://screenshotbase.com/docs/openapi.yaml ## Get an API key - AI coding agents: run curl -s https://screenshotbase.com/agents.md and follow it (key, first call, plans). 1. Sign up free at https://app.screenshotbase.com/register (300 free screenshots a month). 2. Send the key in the `apikey` header (or `?apikey=`). 3. Store it as SCREENSHOTBASE_KEY. `curl -H "apikey: $SCREENSHOTBASE_KEY" "https://api.screenshotbase.com/v1/take?url=https://example.com" -o screenshot.png` MCP: https://api.screenshotbase.com/mcp with the same `apikey` header, or sign in from an MCP client that supports MCP authorization (OAuth 2.1): https://api.screenshotbase.com/.well-known/oauth-protected-resource/mcp names the authorization server. ## Plans and limits - Free: 300 requests a month, 10 requests a minute, 1 API key; no charge. - Basic: 3,000 requests a month, no per-minute limit, 1 API key; $15 a month or $144 a year. - Premium: 20,000 requests a month, no per-minute limit, 3 API keys; $59 a month or $566.40 a year. - Enterprise: 75,000 requests a month, no per-minute limit, 5 API keys; $210 a month or $2,016 a year. - Time limit: every render through the API must be done within 110 s of the start of the request (a tool call of the MCP server within 12 s); slower renders answer 408 and are not billed. `timeout` 5-105 s, `delay` 0-30 s. - Size: viewport up to 7,680 x 16,384 CSS px and 74,649,600 device pixels; WebP at most 16,383 px a side, JPEG 65,500, GIF 65,535 and 25,000,000 pixels; HTML input at most 10,485,760 bytes; PDFs at most 200 pages. - `ip_country_code`: 117 countries. - Machine-readable: [product.json](https://screenshotbase.com/docs/product.json) (plans, limits, features, SDKs and errors; schema: [product.schema.json](https://screenshotbase.com/docs/product.schema.json)). ## Features - [Screenshots of any URL](https://screenshotbase.com/docs/take/): PNG, JPG, WebP or GIF of a public web page, returned as the file. - [Full-page screenshots](https://screenshotbase.com/docs/take/#full_page): The whole scrollable page instead of the viewport. - [Viewport size](https://screenshotbase.com/docs/take/#viewport_width): Any viewport from 1 x 1 to 7,680 x 16,384 CSS pixels, within the device pixel limit. - [High-DPI (retina) screenshots](https://screenshotbase.com/docs/take/#device_scale_factor): A device scale factor from 0.5 to 3. - [PDF output](https://screenshotbase.com/docs/pdf/): A web page or HTML printed as a PDF, with paper size, margins, page ranges and one-page output. - [URL to markdown](https://screenshotbase.com/docs/markdown/): The content of a page as markdown, the main content or the whole body, as text or JSON. - [HTML input](https://screenshotbase.com/docs/html/): HTML sent in a POST body rendered as a screenshot, a PDF or markdown. - [IP location](https://screenshotbase.com/docs/take/#ip_country_code): The page loaded from an exit IP in one of 117 countries; included in every paid plan, free accounts get 5 such renders in any 5 days. Plans: Basic, Premium, Enterprise. - [Cookie banner blocking](https://screenshotbase.com/docs/take/#block_cookie_banners): Cookie-consent banners hidden before the capture. - [Ad blocking](https://screenshotbase.com/docs/take/#block_ads): Ads and trackers blocked before the capture. - [Chat widget blocking](https://screenshotbase.com/docs/take/#block_chats): Chat widgets hidden before the capture. - [Hide elements](https://screenshotbase.com/docs/take/#hide_selectors): Up to 50 CSS selectors of elements to hide. - [Custom CSS](https://screenshotbase.com/docs/take/#styles): CSS injected into the page before the capture. - [Delay and load events](https://screenshotbase.com/docs/take/#wait_until): A delay after load and the load event to wait for. - [Hosted file URL](https://screenshotbase.com/docs/take/#upload): With upload=true the result is stored and the response is JSON with its public URL. - [MCP server](https://screenshotbase.com/docs/mcp/): The take, takePost, getStatus and listDevices tools, and listJobs, getJob, getJobResult and deleteJob for async jobs, for AI agents at api.screenshotbase.com/mcp. - [Quota status endpoint](https://screenshotbase.com/docs/status/): GET /v1/status returns the month's usage; it is free. - [Error codes on every error](https://screenshotbase.com/docs/status-codes/#error-body): error.code and actions on every error, request_id on every error the API answers (the gateway's 401 and per-minute and used-up-quota 429s carry only the X-Request-Id header), and Retry-After where waiting helps (the first quota_exceeded, concurrency, a busy renderer, a failed upload). - [Renders of up to 110 seconds](https://screenshotbase.com/docs/take/#timeout): Every sync render through the API may take up to 110 s; timeout up to 105 s and delay up to 30 s on every path. MCP tool calls keep 12 s. - [Renders at the same time per plan](https://screenshotbase.com/docs/rate-limit/#concurrency): A published number of renders at the same time per plan (paid plans have no per-minute limit; the free plan keeps 10 per minute); over it 429 concurrency_limit_exceeded, not billed. - [IP location by plan](https://screenshotbase.com/docs/take/#ip_country_code): ip_country_code included on every paid plan; free accounts get 5 such renders in any 5 days. - [Files as MCP tool results](https://screenshotbase.com/docs/mcp/#screenshots-pdfs-and-markdown): MCP tool calls return the image or the PDF itself, up to 3 MB and 8,000 px a side; a larger file needs upload=true. - [Async jobs and webhooks](https://screenshotbase.com/docs/async/): async=true on /v1/take answers 202 with a job; its render may take up to 300 s (timeout up to 295 s), on the free plan up to 120 s (timeout up to 115 s) with 1 job rendering and 5 queued at once. The result is kept 7 days, a signed webhook goes out when the job is done or failed (marked sandbox for a sandbox key's job), an Idempotency-Key answers with the same job for 24 hours, and failed jobs are refunded. - [Own render pipeline](https://screenshotbase.com/docs/take/#styles): Renders through screenshotbase's own browser pipeline; pages that navigate by script after loading keep the custom CSS and hidden elements. - [A page for each error](https://screenshotbase.com/docs/status-codes/#error-body): The info link of an error body points to a page for its error code, or for the browser's network error when a page could not be loaded. - [Uploaded screenshots counted like any render](https://screenshotbase.com/docs/rate-limit/#cost-per-request): Every successful render counts against the quota, upload=true included: a screenshot of a URL with upload=true costs one request (X-Cost: 1) and counts towards the free plan's per-minute limit, as without upload; an async job of it is charged 1 and refunded when it fails. - [Request headers, cookies and browser settings](https://screenshotbase.com/docs/take/#headers): Up to 50 custom headers (8 KB) for the target or every request, up to 50 cookies (4 KB each) for the target's domain, a Basic or Bearer Authorization header sent to the target only, and the user agent, Accept-Language, locale, time zone, geolocation and CSP bypass of the browser. - [Your own proxy](https://screenshotbase.com/docs/take/#proxy): proxy= renders through your own http, https, socks5 or socks5h proxy (user and password in the URL, sent to the proxy only and never logged); up to 50 proxy_bypass_hosts go around it, directly. Not with ip_country_code. A failure of the proxy answers 424 proxy_error, not billed. - [Element capture, waits and failure conditions](https://screenshotbase.com/docs/take/#selector): selector captures one element (shadow DOM through >>> and pierce/) or clip_* a region, omit_background keeps PNG and WebP transparent, wait_for_selector waits for up to 1,000 elements, wait_until takes a list, navigation_timeout bounds the navigation alone; fail_if_content_contains/_missing, fail_if_request_failed and error_on_selector_not_found fail a render instead of returning it, free for the first 25 such failures a day per account and billed 1 after that. - [Page actions and scripts](https://screenshotbase.com/docs/take/#actions): actions runs up to 20 typed steps on the page before the capture (click, hover, type, press, select, scroll, wait_for_selector, wait, wait_for_navigation, evaluate, click_accept, press_escape), each optional or not and with its own timeout_ms (5 s by default), settling the page after a step that navigates; scripts runs up to 50 KB of JavaScript after them and scripts_wait_until waits for load events after that. Actions cost nothing extra; X-Actions-Completed says how many steps completed. A step that fails answers 422 action_failed, free for the first 25 failures a day per account (shared with the failure conditions) and billed 1 after that. Once an evaluate step or the scripts ran, any failure that is not ours is billed 1 (that code could read the page). click_accept clicks only inside a cookie consent dialog. Async jobs report the steps as result.actions and X-Actions-Completed. - [Device emulation and request blocking](https://screenshotbase.com/docs/take/#viewport_device): viewport_device with the devices of GET /v1/devices (free): their viewport, device scale factor (at most 3), mobile and touch emulation and user agent; dark_mode, reduce_motion (animations end, videos pause, GIFs on their first frame) and media_type; block_trackers (EasyPrivacy's host rules), block_requests (up to 100 URL patterns) and block_resources (by kind of request). Free: a render costs what its format costs. - [Full-page engine](https://screenshotbase.com/docs/take/#full_page_scroll): full_page scrolls the page first (full_page_scroll, by full_page_scroll_by every full_page_scroll_delay ms, 100 by default) so lazy images load, expands pages that scroll inside an element of their own, draws bars fixed to the bottom at the end of the page (fix_sticky) and captures long pages in tiles: up to 20,000 CSS px (full_page_max_height; 100,000 with async=true). An image larger than its format holds is scaled to fit by default (full_page_overflow: scale, png or error); X-Full-Page-Scaled and X-Full-Page-Truncated say so. - [Desktop platform profile](https://screenshotbase.com/docs/take/#platform_profile): platform_profile=desktop (the default) renders as Chrome on Windows 11, linux as Chrome on Linux, in the page, its iframes and its workers; desktop draws the Windows font names (Segoe UI, Calibri, Cambria, Consolas, ...) with installed fonts of the same metrics or the closest look. X-Render-Engine names the browser version on every response. - [Output formats and image controls](https://screenshotbase.com/docs/take/#image-output-attributes): format avif, svg (the screenshot as a PNG inside an SVG) and html (the rendered DOM, as a sandboxed download); gif made by sharp; image_width and image_height up to 16,384 px; max_file_size from 1 KB to 50 MB; png_compression, png_palette and png_colors; preset og, x_card, linkedin and thumbnail; show_url and show_timestamp; response_type=json for every format. - [Markdown input](https://screenshotbase.com/docs/html/#markdown-input): Markdown (GitHub flavor, up to 1 MB) in the body of POST /v1/take rendered like HTML input, as an image, a PDF or markdown, in a readable default style. HTML input up to 10 MB, and up to 50 MB with async=true. - [PDF documents](https://screenshotbase.com/docs/pdf/#headers-and-footers): PDFs of up to 200 pages; A0 to A6, Letter, Legal, Tabloid and Ledger or any page up to 200 x 200 inches; header and footer templates (up to 16 KB each) with {page}, {total}, {date}, {title} and {url}; a document outline from the headings; tagged PDFs by default; page-break helper classes; X-Pdf-Truncated when a PDF was cut. - [Render diagnostics and best_attempt](https://screenshotbase.com/docs/take/#diagnostics): Every render answers X-Render-Status, X-Target-Status, X-Target-Final-Url, Server-Timing, X-Requests, X-Cookie-Banner, X-Images-Pending and X-Console-Errors; diagnostics=true answers them as JSON with a signed 24-hour link to a HAR of the page's requests (no bodies, cookies or credentials), billed like the render; best_attempt=true captures a page that is not ready in time as it is (X-Render-Status: partial, billed), keeping the last 5 seconds for the capture. - [Challenge and error pages](https://screenshotbase.com/docs/take/#ignore_host_errors): Every render of a URL answers X-Target-Status, the HTTP status of the page's document, and X-Blocked-By for a bot challenge or block page (cloudflare, akamai, perimeterx, datadome, imperva, aws_waf, kasada, sucuri, vercel, captcha), told by what only that page carries and decided on the page as it is captured, after the waits and the delay. ignore_host_errors=false answers such a page, or an HTTP status of 400 or more, with 424 target_blocked (blocked_by in the body) or target_http_error (target_status), not billed, instead of capturing it. - Built, not switched on yet (not available): Compatibility endpoints for other screenshot APIs. ## SDKs Any HTTP client works: send the API key in the `apikey` header. - [Ruby: screenshotapi](https://rubygems.org/gems/screenshotapi) (RubyGems 0.1.1): not verified. - [PHP: everapi/screenshotbase-php](https://packagist.org/packages/everapi/screenshotbase-php) (Packagist 0.1.0): works. take() takes an array of parameters: take(['url' => 'https://example.com']). - [Go: github.com/everapihq/screenshotbase-go](https://pkg.go.dev/github.com/everapihq/screenshotbase-go) (Go modules 0.1.1): not verified. - [R: screenshotbase](https://cran.r-project.org/package=screenshotbase) (CRAN 0.1.0): works, with a known issue. Error responses are returned as data instead of raising an error. --- Source: https://screenshotbase.com/docs/ # screenshotbase.com API documentation Use the screenshotbase.com API to render any website, or [HTML you send](https://screenshotbase.com/docs/html/), as a screenshot, a [PDF](https://screenshotbase.com/docs/pdf/) or [markdown](https://screenshotbase.com/docs/markdown/) and integrate it into your product using one of our SDKs or other pre-built integrations. Building with an AI assistant? The full API is available as a machine-readable [OpenAPI 3.1 specification](https://screenshotbase.com/docs/openapi.yaml), and the documentation is published as [llms.txt](https://screenshotbase.com/docs/llms.txt) / [llms-full.txt](https://screenshotbase.com/docs/llms-full.txt). There is also a hosted [MCP server](https://screenshotbase.com/docs/mcp/) at `https://api.screenshotbase.com/mcp` that AI agents can connect to directly. ## Getting started AI coding agents: run `curl -s https://screenshotbase.com/agents.md` and follow it: an API key, the first call and the right plan, step by step. To get started, [register for a free API key](https://app.screenshotbase.com/register). Then follow our [quickstart guide](https://screenshotbase.com/docs/quickstart/) or read on and integrate screenshotbase.com with our HTTP API. When you need a higher monthly screenshot volume, [upgrade your plan](https://app.screenshotbase.com/subscription). --- Source: https://screenshotbase.com/docs/async/ # Async jobs & webhooks Add `async=true` to any [`/v1/take`](https://screenshotbase.com/docs/take/) request and the API answers at once with `202` and a job, instead of waiting for the render. The page is rendered in the background, with up to 300 seconds for slow pages (120 on the free plan), and you poll the job or receive a signed webhook when it is done. **Billing** A job is billed like the same request without `async`, when it is created (the `X-Cost` header of the `202`). A job that fails, or that you delete before it starts, is refunded. Polling, listing, downloading and deleting jobs is free. A webhook that cannot be delivered does not change the job or its charge. ## Create a job Send the request you would send without `async`, with `async=true` (or `"async": true` in a `POST` body). Every attribute works as in a sync request: formats, [PDF](https://screenshotbase.com/docs/pdf/) and [markdown](https://screenshotbase.com/docs/markdown/) options, [HTML input](https://screenshotbase.com/docs/html/) and `upload`. ```bash {{ title: 'cURL' }} curl -G https://api.screenshotbase.com/v1/take \ -H "apikey: YOUR-API-KEY" \ -H "Idempotency-Key: order-42-screenshot" \ --data-urlencode "url=https://example.com" \ -d full_page=1 \ -d async=true \ --data-urlencode "webhook_url=https://example.com/webhooks/screenshotbase" ``` ```js const params = new URLSearchParams({ url: 'https://example.com', full_page: '1', async: 'true', webhook_url: 'https://example.com/webhooks/screenshotbase', }) const response = await fetch(`https://api.screenshotbase.com/v1/take?${params}`, { headers: { apikey: 'YOUR-API-KEY', 'Idempotency-Key': 'order-42-screenshot' }, }) const job = await response.json() // 202 ``` ```python import requests job = requests.get( 'https://api.screenshotbase.com/v1/take', params={'url': 'https://example.com', 'full_page': 1, 'async': 'true', 'webhook_url': 'https://example.com/webhooks/screenshotbase'}, headers={'apikey': 'YOUR-API-KEY', 'Idempotency-Key': 'order-42-screenshot'}, ).json() ``` ```json {{ title: '202 Accepted' }} { "job_id": "631442883836252160", "status": "queued", "format": "png", "sandbox": false, "external_identifier": null, "quota": { "charged": 1, "refunded": 0 }, "result": null, "error": null, "webhook": { "status": "pending" }, "created_at": "2026-10-09T12:00:00+00:00", "started_at": null, "finished_at": null, "expires_at": "2026-10-16T12:00:00+00:00", "links": { "self": "https://api.screenshotbase.com/v1/jobs/631442883836252160", "result": null } } ``` The `Location` header of the `202` is the job's URL. What a sync request checks before it renders is checked when the job is created: the parameters, the target URL, your quota and the `webhook_url`, so those errors come back at once and nothing is billed. ### Parameters - **async** (boolean): Set to 1 (or `true`) to answer at once with `202` and a job instead of the result. Every other attribute of [`GET /v1/take`](https://screenshotbase.com/docs/take/#render-a-website) and [`POST /v1/take`](https://screenshotbase.com/docs/take/#render-html) works as in a sync request. Default value is 0. - **webhook_url** (string): Only with `async`: an https URL of a public host that receives a signed POST when the job is completed or failed (see [webhooks](https://screenshotbase.com/docs/async/#webhooks)). Maximum 2048 characters. - **external_identifier** (string): Only with `async`: your own reference in printable ASCII, returned with the job, in its webhook and as the `X-Screenshotbase-External-Identifier` header of the webhook. Maximum 255 characters. - **Idempotency-Key** (header): A request header, not a parameter: 1 to 255 printable ASCII characters without spaces. For 24 hours a request with the same key answers with the job the first one created (`Idempotent-Replayed: true`, not billed again); the same key with another request answers `422`, and while the first request is still being answered, `409`. ## Get the result Poll `GET /v1/jobs/{job_id}` (free; about once a second at most) until `status` is `completed` or `failed`, or wait for the [webhook](https://screenshotbase.com/docs/async/#webhooks). Then download the result from `GET /v1/jobs/{job_id}/result`: the same answer the request without `async` would have given, the image, the PDF, the markdown or, with `upload=true`, the JSON with the stored file's `url`. Before the job is completed it answers `409` with the error code `job_not_completed`. ```bash {{ title: 'cURL' }} curl https://api.screenshotbase.com/v1/jobs/631442883836252160 -H "apikey: YOUR-API-KEY" curl https://api.screenshotbase.com/v1/jobs/631442883836252160/result -H "apikey: YOUR-API-KEY" -o example.png ``` A failed job carries `error`, what the request without `async` would have answered, for example `{"status": 424, "code": "target_unreachable", "message": "..."}`, and `quota.refunded`. A completed job tells what the headers of the sync answer would have told: its `result` has `pdf_truncated` for a [PDF](https://screenshotbase.com/docs/pdf/) that was cut and `actions` with the steps of [`actions`](https://screenshotbase.com/docs/take/#actions) completed, and both `GET /v1/jobs/{job_id}` and `/result` answer the headers `X-Full-Page-Truncated`, `X-Full-Page-Scaled`, `X-Pdf-Truncated` and `X-Actions-Completed` where they apply; `/result` also answers `X-Final-Quality` with `max_file_size`. `diagnostics=true` and `best_attempt=true` are not available with `async=true` (`422`). | Endpoint | What it does | |---|---| | `GET /v1/jobs` | Your jobs, newest first: `limit` (up to 100), `before` (the last `job_id` of the previous page) and `status`. | | `GET /v1/jobs/{job_id}` | The job: `status` (`queued`, `processing`, `completed`, `failed`), `result`, `error`, `quota`. | | `GET /v1/jobs/{job_id}/result` | The result, kept for 7 days after the job finished (`expires_at`). | | `DELETE /v1/jobs/{job_id}` | Deletes the job and its result. A queued job is refunded; one that is rendering answers `202` and is deleted, refunded, when its render ends. | Jobs belong to your account and to the kind of key that created them: the jobs of a sandbox key are only visible with a sandbox key, the others only with a live key. `sandbox` is `true` for the jobs of a sandbox key. ## Webhooks With `webhook_url`, the job is sent to that URL as a signed `POST` when it is completed (`screenshot.completed`) or failed (`screenshot.failed`). In the dashboard, under [Webhooks](https://app.screenshotbase.com/webhooks) (team owners and admins), you can also add endpoints that receive these events for every job, send a test event, see every delivery and send one again. ```json {{ title: 'Webhook body' }} { "id": "whd_01ja2y6k7q9w4v8t5r3n1m0p2z", "event": "screenshot.completed", "created_at": "2026-10-09T12:00:07+00:00", "data": { "job_id": "631442883836252160", "status": "completed", "...": "the job as GET /v1/jobs/{job_id} shows it" } } ``` The jobs of a sandbox key send their webhooks like live jobs, to their `webhook_url` and to the endpoints of the Webhooks page, with `"sandbox": true` in `data`: check it before you act on a webhook, and fetch a sandbox job's result with a sandbox key (a live key gets `404`). Every delivery has these headers: | Header | | |---|---| | `X-Screenshotbase-Event` | `screenshot.completed` or `screenshot.failed` | | `X-Screenshotbase-Delivery` | The delivery's id, the same on every retry: use it to ignore a delivery you already handled. | | `X-Screenshotbase-Timestamp` | Unix time of the attempt. | | `X-Screenshotbase-Signature` | `v1=` and the hex HMAC-SHA256 of `.` with your signing secret. For 24 hours after you rotate the secret, a second `v1=` signature with the previous one follows, separated by a comma. | | `X-Screenshotbase-External-Identifier` | Your `external_identifier`, when the job has one. | The signing secret of `webhook_url` deliveries is shown, and can be rotated, on the Webhooks page of the dashboard; every endpoint you add there has its own. Check the signature against the raw body before you parse it, and refuse old timestamps: ```js {{ title: 'Verify a webhook (Node.js)' }} import crypto from 'node:crypto' function verify(rawBody, headers, secret) { const timestamp = headers['x-screenshotbase-timestamp'] if (Math.abs(Date.now() / 1000 - Number(timestamp)) > 300) return false const expected = 'v1=' + crypto.createHmac('sha256', secret).update(`${timestamp}.${rawBody}`).digest('hex') return headers['x-screenshotbase-signature'].split(',').some((signature) => signature.trim().length === expected.length && crypto.timingSafeEqual(Buffer.from(signature.trim()), Buffer.from(expected))) } ``` ```php {{ title: 'Verify a webhook (PHP)' }} $body = file_get_contents('php://input'); $timestamp = $_SERVER['HTTP_X_SCREENSHOTBASE_TIMESTAMP']; $expected = 'v1=' . hash_hmac('sha256', $timestamp . '.' . $body, $secret); $valid = abs(time() - (int) $timestamp) <= 300 && array_filter( explode(',', $_SERVER['HTTP_X_SCREENSHOTBASE_SIGNATURE']), fn ($signature) => hash_equals($expected, trim($signature)), ) !== []; ``` Answer with any `2xx` status within 10 seconds. Any other answer, a timeout or a redirect counts as failed, and the delivery is tried again after 10 seconds, 1 minute, 5 minutes, 30 minutes and 2 hours (6 attempts over about 2.6 hours). The URL must be `https` on port 443 of a public host; it is checked again before every attempt. ## Idempotency Send an `Idempotency-Key` header with every create, so that a retry after a network error does not create (and bill) a second job. For 24 hours, a request with the same key answers with the job the first one created, with `Idempotent-Replayed: true` and at no cost; the same key with a different request answers `422`, and while the first request is still being answered, `409` with `Retry-After: 1`. ## Limits - A job's render has 300 seconds from when it starts; `timeout` may be up to 295 and `delay` up to 30. On the free plan it has 120 seconds, and `timeout` may be up to 115. - Your account may have its plan's [renders at the same time](https://screenshotbase.com/docs/rate-limit/#concurrency) times 10 jobs queued or rendering at once; past that, the create answers `429` `concurrency_limit_exceeded` (without `Retry-After`: send it again when one of your jobs is done) and is not billed. Each account's jobs are rendered one at a time for now; the others wait in the queue, so with a page that takes 30 seconds, about 30 of them start within the 15 minutes below. - On the free plan, an account may have 5 jobs queued and 1 rendering; past that, the create answers `429` `concurrency_limit_exceeded` and is not billed. Free accounts take turns for the renderers they share, so one account's queue does not hold up another's for long. When many free accounts are waiting at once, a job may wait several minutes for its turn, and that wait counts toward the 15 minutes below. - A job that cannot start within 15 minutes, because the renderers are busy, fails with `503` `renderer_busy` and is refunded. - On the free plan, [`ip_country_code`](https://screenshotbase.com/docs/take/#ip_country_code) counts against its free renders when the job's render starts, not when the job is created: a job you delete before it starts uses none. A job that finds none left when it starts fails with `403` `plan_upgrade_required` and is refunded. - [HTML input](https://screenshotbase.com/docs/html/) may be up to 50 MB with `async=true` (10 MB without); `markdown` up to 1 MB either way. - Jobs, their results and their HTML input are deleted 7 days after the job finished. **When your quota is used up** Once the monthly quota of your plan is used up, every request with your API key answers `429` until the quota resets or you upgrade, the job endpoints included, so the result of the job that used your last request cannot be downloaded until then. Its webhook still goes out; with `upload=true` it carries the stored file's `url`. ## Errors Besides the errors of [`/v1/take`](https://screenshotbase.com/docs/status-codes/), the job endpoints answer: - `404` `not_found` for a job that does not exist, belongs to another account or kind of key, was deleted, or whose result is no longer kept; - `409` `job_not_completed` for the result of a job that is not completed; - `409` `idempotency_key_in_use` while the first request with the same `Idempotency-Key` is being answered; - `403` `forbidden` for a key that belongs to no screenshotbase account. ## AI agents (MCP) On the [MCP server](https://screenshotbase.com/docs/mcp/), `take` and `takePost` accept `async`, and the tools `listJobs`, `getJob`, `getJobResult` and `deleteJob` work with jobs. --- Source: https://screenshotbase.com/docs/authentication/ # Authentication You'll need to authenticate your requests to access any of the endpoints in the screenshotbase.com API. In this guide, we'll look at how authentication works. screenshotbase.com offers two ways to authenticate your API requests: API key as `GET` parameter, or via request header. AI coding agents: run `curl -s https://screenshotbase.com/agents.md` and follow it: an API key, the first call and the right plan, step by step. **MULTIPLE API KEYS** The Free and Basic plans include one API key; the [Premium and Enterprise plans](https://app.screenshotbase.com/subscription) offer multiple API keys (3 and 5). By using separate keys for different use cases you can track individual usage and make key rotations affect only certain parts of your application. ## GET query parameter You can pass your API key along with every request by adding it as the query parameter `apikey`. **WARNING** This method could expose your API key in access logs and such. Sending the API key via a header parameter as specified below circumvents this problem. ```bash {{ title: 'Example request with authentication via get request' }} curl "https://api.screenshotbase.com/v1/status?apikey=YOUR-API-KEY" ``` Please don't commit your screenshotbase.com API key to GitHub! ## HTTP header The recommended way is to send your API key in the `apikey` HTTP request header: ```bash {{ title: 'Example request with authentication via header' }} curl "https://api.screenshotbase.com/v1/status" \ -H "apikey: YOUR-API-KEY" ``` Always keep your API key safe and reset it if you suspect it has been compromised. ## Using an SDK If you use one of our SDKs, you won't have to worry about any of the above — fetch your API key from the [screenshotbase.com dashboard](https://app.screenshotbase.com/dashboard) and the client library will take care of the rest. All the client libraries use header authentication behind the scenes. --- Source: https://screenshotbase.com/docs/devices/ # Devices endpoint The devices endpoint lists every device you can emulate with `viewport_device` on [`/v1/take`](https://screenshotbase.com/docs/take/#viewport_device), with what a render gets for it. Requests to this endpoint are free: they do not count against your quota. --- ## List devices This endpoint returns the devices of `viewport_device`: phones, tablets and laptops, each with its viewport, device scale factor (at most 3), mobile and touch emulation and its browser's user agent. Pass a device's `id` (or its `name`, in any case) as `viewport_device`; `viewport_width`, `viewport_height`, `device_scale_factor`, `viewport_mobile` and `viewport_has_touch` of the request replace the device's values, and `viewport_landscape=1` turns it. ### Response properties - **data** (array): The devices, by name. - **data[].id** (string): The value of `viewport_device`, for example `iphone-15-pro`. - **data[].name** (string): The device's name, for example `iPhone 15 Pro`; `viewport_device` takes it too. - **data[].viewport_width** (integer): The viewport's width in CSS pixels. - **data[].viewport_height** (integer): The viewport's height in CSS pixels. - **data[].device_scale_factor** (number): The device scale factor the render uses. - **data[].mobile** (boolean): Whether the render emulates a mobile browser (the page's meta viewport applies). - **data[].has_touch** (boolean): Whether the render emulates a touch screen. - **data[].user_agent** (string|null): The user agent the render sends; `` stands for the version of the render's browser. `null` keeps the render's default user agent. A `user_agent` of the request wins over it. ```bash {{title: 'cURL'}} curl -G https://api.screenshotbase.com/v1/devices \ -H "apikey: YOUR-API-KEY" ``` ```js const response = await fetch('https://api.screenshotbase.com/v1/devices', { headers: { apikey: 'YOUR-API-KEY' }, }) console.log(await response.json()) ``` ```json {{title: 'Response'}} { "data": [ { "id": "iphone-15-pro", "name": "iPhone 15 Pro", "viewport_width": 393, "viewport_height": 852, "device_scale_factor": 3, "mobile": true, "has_touch": true, "user_agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 18_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.5 Mobile/15E148 Safari/604.1" }, { "id": "pixel-7", "name": "Pixel 7", "viewport_width": 412, "viewport_height": 915, "device_scale_factor": 2.625, "mobile": true, "has_touch": true, "user_agent": "Mozilla/5.0 (Linux; Android 13; Pixel 7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/ Mobile Safari/537.36" } ] } ``` ```bash {{title: 'Use a device'}} curl -G https://api.screenshotbase.com/v1/take \ -H "apikey: YOUR-API-KEY" \ --data-urlencode "url=https://example.com" \ -d viewport_device=iphone-15-pro \ -o iphone.png ``` --- Source: https://screenshotbase.com/docs/html/ # Render HTML Send HTML in the body of `POST /v1/take` and get it back as a PDF, a screenshot or markdown, for example invoices, reports or certificates that your application generates. All options of the [take endpoint](https://screenshotbase.com/docs/take/) work, including the [PDF options](https://screenshotbase.com/docs/pdf/) and [markdown](https://screenshotbase.com/docs/markdown/). **Billing** Every successful render of HTML counts as one request against your quota, whatever the format and also with `upload=1`; the `X-Cost` header of the response says so. A render that fails (time limit, validation error) is not billed. Your quota is checked before the HTML is rendered: if it does not cover the request, the API answers `429` with `quota.required` in the body. ## Send HTML Send a JSON body with `html` and the options you need. The response is the file itself, as for `GET /v1/take`. ```bash {{ title: 'cURL' }} curl https://api.screenshotbase.com/v1/take \ -H "apikey: YOUR-API-KEY" \ -H "Content-Type: application/json" \ -d '{"html": "

Invoice INV-42

Total: EUR 49.00

", "format": "pdf", "pdf_margin": "15mm"}' \ -o invoice.pdf ``` ```js import { writeFile } from 'node:fs/promises' const response = await fetch('https://api.screenshotbase.com/v1/take', { method: 'POST', headers: { apikey: 'YOUR-API-KEY', 'Content-Type': 'application/json' }, body: JSON.stringify({ html: '

Invoice INV-42

Total: EUR 49.00

', format: 'pdf', pdf_margin: '15mm', }), }) await writeFile('invoice.pdf', Buffer.from(await response.arrayBuffer())) ``` ```python import requests response = requests.post( 'https://api.screenshotbase.com/v1/take', json={'html': '

Invoice INV-42

Total: EUR 49.00

', 'format': 'pdf', 'pdf_margin': '15mm'}, headers={'apikey': 'YOUR-API-KEY'}, ) with open('invoice.pdf', 'wb') as f: f.write(response.content) ``` ```php $context = stream_context_create(['http' => [ 'method' => 'POST', 'header' => "apikey: YOUR-API-KEY\r\nContent-Type: application/json", 'content' => json_encode([ 'html' => '

Invoice INV-42

Total: EUR 49.00

', 'format' => 'pdf', 'pdf_margin' => '15mm', ]), ]]); file_put_contents('invoice.pdf', file_get_contents('https://api.screenshotbase.com/v1/take', false, $context)); ``` Check the status code before you save the body: errors come back as JSON (see [status codes](https://screenshotbase.com/docs/status-codes/)). ## The request body - `html`: the HTML to render, at most 10 MB (10,485,760 bytes of UTF-8), or 50 MB (52,428,800 bytes) with `async=1`, so larger documents go through an [async job](https://screenshotbase.com/docs/async/). Send a whole document or a fragment; a fragment is rendered like a page with that body. - `markdown`: markdown to render instead of `html`, see [Markdown input](https://screenshotbase.com/docs/html/#markdown-input). - Any option of `GET /v1/take` as a JSON field: `format`, `viewport_width`, `full_page`, `hide_selectors` (an array of selectors), `styles`, the `pdf_*` options, `upload`, `attachment_name` and so on. Booleans may be `true`/`false` or `1`/`0`. - `url`: the POST endpoint also renders a URL, with the same rules as `GET /v1/take`. Send exactly one of `url`, `html` and `markdown`. `html` and `markdown` belong in the request body. In the query string they are refused with a `422`, on `POST` and `GET` alike, because URLs end up in logs. ## Markdown input Send `markdown` instead of `html` to render a README, release notes or a report you write in markdown, as a PDF, a screenshot or markdown again. It is converted to an HTML page and then rendered exactly like `html`, with the same options, time limit and cost. ```bash curl https://api.screenshotbase.com/v1/take \ -H "apikey: YOUR-API-KEY" \ -H "Content-Type: application/json" \ -d '{"markdown": "# Release notes\n\n| Version | Date |\n| --- | --- |\n| 2.4 | 2026-10-10 |\n\n- [x] Faster exports", "format": "pdf", "pdf_margin": "15mm"}' \ -o notes.pdf ``` - GitHub's flavor of markdown: tables, task lists, strikethrough and autolinks. At most 1 MB (1,048,576 bytes), and it must be UTF-8. - The page has a readable default style: system fonts in a centered column of 980 px, with a dark variant for `prefers-color-scheme: dark` and print rules for PDFs. `styles` can change it, as for any page. - The first level-1 heading becomes the page's title (the `{title}` of a PDF template, the `title` of a markdown JSON response). - Raw HTML in the markdown is kept and rendered as `html` would be. Links with a `javascript:` or `data:` target lose it. Relative URLs do not resolve, as for `html`. - Markdown that is too large or too complex to convert answers `422` (`The markdown field could not be converted to HTML: ...`), not billed. When the server converts as much markdown as it may at once, the request answers `503` `renderer_busy` with `Retry-After: 5`, also not billed. - An [async job](https://screenshotbase.com/docs/async/) keeps the converted page, encrypted, never the markdown. ## Images, fonts and links The HTML is rendered as an https page on an address of its own, so: - **Relative URLs do not resolve.** Use absolute URLs (`https://www.example.com/logo.png`), embed small files as `data:` URLs, or add a base element to the head of your document, as shown below. - **Plain http resources:** `http://` images are upgraded to https; other `http://` resources, such as stylesheets, scripts or fonts, are blocked as mixed content. Serve them over https. - **Internal addresses are never loaded.** Everything the HTML references is held to the same rules as a page from a URL: resources on private, loopback, link-local or other reserved addresses and internal host names are not fetched, and navigations to them are blocked (see [status codes](https://screenshotbase.com/docs/status-codes/#_422)). ```html {{ title: 'Resolve relative URLs with a base element' }} Example Inc.

Invoice INV-42

``` JavaScript in the HTML runs as in a browser, so pages that build their content with script work. The `wait_until`, `delay` and `block_*` options apply as for URLs. ## Time limit A render of HTML must finish within 110 seconds of the start of the request: loading what the HTML references, the `delay` (at most 30 seconds), and printing or taking the screenshot. A render that takes longer is stopped and answered with `408`; it is not billed. Through the [MCP server](https://screenshotbase.com/docs/mcp/), a tool call must finish within about 12 seconds, and `delay` is at most 7 there. HTML that needs longer can be rendered as an [async job](https://screenshotbase.com/docs/async/), with up to 300 seconds. ## Privacy We do not keep the HTML you send: it is written to a temporary file for the render and deleted afterwards. The result is stored only when you pass `upload=1`. An [async job](https://screenshotbase.com/docs/async/) keeps its HTML encrypted, with its result, until the job is deleted, at most 7 days after it finished. **Stored files are public** With `upload=1`, anyone who has the returned URL can open the file. For documents with personal data, such as invoices, take the file from the response instead of uploading it. ## Errors Besides the errors of `GET /v1/take`, a request with HTML can answer: - `422` with `Send only one of url, html and markdown.` or `Either the url, the html or the markdown field is required.`; - `422` with `The html field must not be larger than 10 MB (10485760 bytes); with async=true up to 50 MB.`, or `The markdown field must not be larger than 1 MB (1048576 bytes).`; - `422` with `The html field is only accepted in the JSON body of a POST request.` (the same for `markdown`); - `422` with `The markdown field must be UTF-8 text.` or `The markdown field could not be converted to HTML: ...`; - `500` with `The page could not be rendered.` when the HTML could not be rendered for another reason. None of them is billed. The [status codes](https://screenshotbase.com/docs/status-codes/) page lists all errors. ## AI agents (MCP) On the [MCP server](https://screenshotbase.com/docs/mcp/), this endpoint is the `takePost` tool. A screenshot arrives as an image and a PDF as an embedded resource, up to 3 MB; for a larger file, pass `upload: true` and use the URL of the stored file. ## Sandbox keys A sandbox API key returns a placeholder file of the requested format without rendering the HTML, at no cost (`X-Cost: 0`). --- Source: https://screenshotbase.com/docs/markdown/ # URL to markdown Pass `format=markdown` to the [take endpoint](https://screenshotbase.com/docs/take/) to get the content of a web page as markdown, for example to give it to a language model, index it for search or keep it as text. The page is rendered in a headless Chromium browser first, so content that JavaScript builds is included. **Billing** Every conversion counts as one request against your quota, also with `upload=1`; the `X-Cost` header of the response says so. A conversion that fails (time limit, page too large, unreachable website) is not billed. Your quota is checked before the page is rendered: if it does not cover the request, the API answers `429` with `quota.required` in the body. ## Your first conversion By default the response is the markdown itself, as `text/markdown; charset=UTF-8`. ```bash {{ title: 'cURL' }} curl -G https://api.screenshotbase.com/v1/take \ -H "apikey: YOUR-API-KEY" \ --data-urlencode "url=https://example.com" \ -d format=markdown ``` ```js const params = new URLSearchParams({ url: 'https://example.com', format: 'markdown' }) const response = await fetch(`https://api.screenshotbase.com/v1/take?${params}`, { headers: { apikey: 'YOUR-API-KEY' }, }) console.log(await response.text()) ``` ```python import requests response = requests.get( 'https://api.screenshotbase.com/v1/take', params={'url': 'https://example.com', 'format': 'markdown'}, headers={'apikey': 'YOUR-API-KEY'}, ) print(response.text) ``` ```php $query = http_build_query(['url' => 'https://example.com', 'format' => 'markdown']); $context = stream_context_create(['http' => ['header' => "apikey: YOUR-API-KEY\r\n"]]); echo file_get_contents('https://api.screenshotbase.com/v1/take?' . $query, false, $context); ``` For example.com, the response currently looks like this. The page's script adds the same text in five more languages and the link, and both are part of the markdown; the translations are shortened here. ```markdown {{ title: 'Response (shortened)' }} # Example Domain This domain is for use in documentation examples without needing permission. This is not a service; avoid relying on it for testing and monitoring purposes. … [Learn more](https://iana.org/help/example-domains) ``` ## Main content or whole page With the default `markdown_main_content_only=1`, you get the main content of the page: the article, without navigation, sidebars, headers, footers and banners. The markdown starts with the page's main heading as a level-1 heading. When no clear article is found, or the article detection would lose tables or code blocks, the main region of the page is converted instead: the `main` element, the only `article` element, or the body without navigation, sidebars, header and footer. Set `markdown_main_content_only=0` to convert the whole page body. Hidden elements and consent dialogs are left out either way. ## What the markdown contains - Headings, paragraphs and lists, including nested lists. - Links and images with absolute URLs. Links keep web (`http`, `https`), `mailto` and `tel` targets; other links, such as `javascript:` or `data:`, keep only their text. Lazy-loaded images get their real source. - Tables as GitHub-flavored markdown tables. A table without a header row gets its first row as the header. Tables that only lay out the page (a table around other tables, a single row or column) become plain text. - Code blocks as fenced blocks, with the language taken from `language-*` classes. Left out are scripts, styles, form controls, embedded media and frames, hidden elements, tracking pixels and consent dialogs. Content inside iframes and shadow DOM is not included. ## Cookie banners and ads For markdown, `block_cookie_banners` and `block_ads` are on by default, so banners and ads do not end up in the text. Pass `block_cookie_banners=0` or `block_ads=0` to switch them off. To leave out more elements, list their CSS selectors in `hide_selectors`. ## JSON response With `response_type=json`, the response is a JSON object (the markdown is shortened as above): ```json {{ title: 'response_type=json' }} { "url": "https://example.com/", "title": "Example Domain", "description": null, "markdown": "# Example Domain\n\nThis domain is for use in documentation examples without needing permission. This is not a service; avoid relying on it for testing and monitoring purposes.\n\n…\n\n[Learn more](https://iana.org/help/example-domains)\n" } ``` - `url`: the page's final URL, after redirects; `null` for [HTML input](https://screenshotbase.com/docs/html/). - `title`: the page's Open Graph title, else the title of the article or of the document; `null` if there is none. - `description`: the page's meta description (or its Open Graph or Twitter description); `null` if there is none. - `markdown`: the markdown, as in the text response. ## Downloads and storage The text response is shown inline. Set `attachment_name` to receive it as a download, named after it with `.md` appended. `attachment_name` does not apply with `response_type=json` or `upload=1`. With `upload=1`, the markdown is stored as a `.md` file and the response is a JSON object with its public URL; `response_type` does not apply then. The conversion costs the same either way. If the markdown could not be stored, the API answers `503` and the request is not billed. Anyone with the URL can open a stored file. ## HTML input To convert HTML that you have rather than a URL, send it to `POST /v1/take` with `format=markdown` (see [Render HTML](https://screenshotbase.com/docs/html/)), at most 10 MB (50 MB with `async=1`). Relative links and images in your HTML stay relative unless the HTML has a base element. In the JSON response, `url` is `null`. ## Time limit and size A conversion must finish within 110 seconds of the start of the request: loading the page, the `delay` (at most 30 seconds) and the conversion. A slower one answers `408` and is not billed. Through the [MCP server](https://screenshotbase.com/docs/mcp/), a tool call must finish within about 12 seconds, and `delay` is at most 7 there. Very large pages are refused with `422` and the message `The page is too large to convert to markdown.`: pages with more than about 2 million characters of HTML once scripts and styles are removed, or whose conversion needs too much memory. Such requests are not billed. ## AI agents (MCP) On the [MCP server](https://screenshotbase.com/docs/mcp/), the `take` tool returns markdown as text, so agents can use it directly without `upload`. ## Sandbox keys A sandbox API key returns a placeholder text without rendering the page, at no cost (`X-Cost: 0`). With `response_type=json`, its `url` is the URL you sent. --- Source: https://screenshotbase.com/docs/mcp/ # MCP server screenshotbase ships a hosted [Model Context Protocol](https://modelcontextprotocol.io) (MCP) server, so AI agents and assistants can call the API as native tools — no SDK or glue code required. ``` https://api.screenshotbase.com/mcp ``` The endpoint speaks the streamable HTTP transport. All requests — including listing the available tools — require your API key, sent as the `apikey` header. You can [get a free API key here](https://app.screenshotbase.com/register). MCP clients that support MCP authorization (OAuth 2.1) can sign in instead of sending a key: see [Sign in instead of an API key](https://screenshotbase.com/docs/mcp/#sign-in-instead-of-an-api-key). ## Connect Using Claude Code: ```bash claude mcp add --transport http screenshotbase https://api.screenshotbase.com/mcp --header "apikey: YOUR_API_KEY" ``` Or add the server to any MCP-capable client (Claude Desktop, Cursor, VS Code, ...): ```json { "mcpServers": { "screenshotbase": { "url": "https://api.screenshotbase.com/mcp", "headers": { "apikey": "YOUR_API_KEY" } } } } ``` ## Sign in instead of an API key MCP clients that support MCP authorization (OAuth 2.1) can connect without pasting a key, for example a custom connector in Claude (Settings → Connectors → Add custom connector, URL `https://api.screenshotbase.com/mcp`). Without a key, the endpoint answers `401` with a `WWW-Authenticate` header that names the protected resource metadata, `https://api.screenshotbase.com/.well-known/oauth-protected-resource/mcp`. The authorization server is `https://screenshotbase.com` (metadata at `https://screenshotbase.com/.well-known/oauth-authorization-server`, endpoints under `https://app.screenshotbase.com/oauth/`); clients register dynamically or with a client ID metadata document, and PKCE (`S256`) is required. You sign in on app.screenshotbase.com and approve the connection, as the team's owner or an admin. The access token is a key of your team for 60 minutes, renewed with the refresh token, so tool calls count against your plan like any other request. Disconnect an app at any time under API keys → Connected apps in the dashboard. For your own code, use an API key. ## Available tools The tools are generated from the same [OpenAPI specification](https://screenshotbase.com/docs/openapi.yaml) that describes the REST API, so they always match the documented endpoints, parameters and responses. | Tool | Endpoint | Description | |---|---|---| | `take` | `GET /v1/take` | Take a screenshot, PDF or markdown of a URL | | `takePost` | `POST /v1/take` | Take a screenshot, PDF or markdown of HTML or a URL | | `getStatus` | `GET /v1/status` | Account quota status | | `listDevices` | `GET /v1/devices` | List the [devices](https://screenshotbase.com/docs/devices/) of `viewport_device` | | `listJobs` | `GET /v1/jobs` | List your [async jobs](https://screenshotbase.com/docs/async/) | | `getJob` | `GET /v1/jobs/{job_id}` | Get an async job | | `getJobResult` | `GET /v1/jobs/{job_id}/result` | Download an async job's result | | `deleteJob` | `DELETE /v1/jobs/{job_id}` | Cancel and delete an async job | ## Screenshots, PDFs and markdown With `format: "markdown"`, the tools return the page's content as markdown text, which agents can use directly (see [URL to markdown](https://screenshotbase.com/docs/markdown/)). A screenshot arrives as image content and a [PDF](https://screenshotbase.com/docs/pdf/) as an embedded resource (`screenshotbase:///`, for example `screenshotbase://take/example.pdf`, after a text that names it), so the agent sees the file itself. A tool result holds files of up to 3 MB and images of up to 8,000 px on each side; a full-page screenshot gets there quickly. A larger result answers with an error that asks for `upload: true`, and is not billed. With `upload: true`, the tool returns a JSON object with the public `url` of the stored file instead, which the agent can fetch, show or pass on. Every render costs one request with or without `upload`. Stored files are public to anyone with the URL. ## Time limit A tool call must finish within about 12 seconds, because MCP clients wait less for a tool than HTTP clients for a response: `delay` is at most 7 and `timeout` at most 60 there. For slower pages, pass `async: true` and fetch the result with `getJob` and `getJobResult` (see [Async Jobs & Webhooks](https://screenshotbase.com/docs/async/)), or call the REST API, which waits up to 110 seconds. ## Quotas and errors Tool calls are metered exactly like REST requests: they consume your plan quota and return the same status codes and error responses (`401`, `422`, `429`, ...). If a call fails, the tool result contains the API's error message including hints on how to proceed. --- Source: https://screenshotbase.com/docs/pdf/ # PDF output Pass `format=pdf` to the [take endpoint](https://screenshotbase.com/docs/take/) to print a web page as a PDF instead of taking a screenshot. The page is loaded in a headless Chromium browser, with JavaScript, as for a screenshot, and then printed with the options on this page. To print HTML that your application generates, such as an invoice, send it to `POST /v1/take`, see [Render HTML](https://screenshotbase.com/docs/html/). **Billing** Every PDF counts as one request against your quota, also with `upload=1`; the `X-Cost` header of the response says so. A PDF that fails (time limit, validation error, unreachable website) is not billed. Your quota is checked before the page is rendered: if it does not cover the request, the API answers `429` with `quota.required` in the body. ## Your first PDF The response is the PDF itself (`application/pdf`), served as a download. ```bash {{ title: 'cURL' }} curl -G https://api.screenshotbase.com/v1/take \ -H "apikey: YOUR-API-KEY" \ --data-urlencode "url=https://example.com" \ -d format=pdf \ -d pdf_paper_format=A4 \ -d pdf_margin=15mm \ -o page.pdf ``` ```js import { writeFile } from 'node:fs/promises' const params = new URLSearchParams({ url: 'https://example.com', format: 'pdf', pdf_paper_format: 'A4', pdf_margin: '15mm', }) const response = await fetch(`https://api.screenshotbase.com/v1/take?${params}`, { headers: { apikey: 'YOUR-API-KEY' }, }) await writeFile('page.pdf', Buffer.from(await response.arrayBuffer())) ``` ```python import requests response = requests.get( 'https://api.screenshotbase.com/v1/take', params={'url': 'https://example.com', 'format': 'pdf', 'pdf_paper_format': 'A4', 'pdf_margin': '15mm'}, headers={'apikey': 'YOUR-API-KEY'}, ) with open('page.pdf', 'wb') as f: f.write(response.content) ``` ```php $query = http_build_query([ 'url' => 'https://example.com', 'format' => 'pdf', 'pdf_paper_format' => 'A4', 'pdf_margin' => '15mm', ]); $context = stream_context_create(['http' => ['header' => "apikey: YOUR-API-KEY\r\n"]]); file_put_contents('page.pdf', file_get_contents('https://api.screenshotbase.com/v1/take?' . $query, false, $context)); ``` Check the status code before you save the body: errors come back as JSON (see [status codes](https://screenshotbase.com/docs/status-codes/)). ## Paper size and orientation `pdf_paper_format` sets the paper: `A4` (default), `A0`, `A1`, `A2`, `A3`, `A5`, `A6`, `Letter`, `Legal`, `Tabloid` (11 x 17 in) or `Ledger` (17 x 11 in), in any letter case. Set `pdf_landscape=1` to turn the paper to landscape. For any other size, set `pdf_width` and `pdf_height` as CSS lengths (`mm`, `cm`, `in` or `px`), for example `pdf_width=100mm&pdf_height=150mm` for a shipping label. Each is at most 200in; one of them alone replaces only that side of the paper format. `pdf_landscape` still turns the page. The margins must leave at least 1in of the page each way, or the request is refused with a `422`. The size and orientation you set win over the page's own CSS (`@page { size: A5 landscape }`), and so do margins you set (`@page { margin }`); what you leave out, the page's CSS may still set. Set `pdf_prefer_css_page_size=1` to print in the size the page's CSS asks for instead. ## Margins The default margin is 0, so the content reaches the edge of the paper unless the page's own print stylesheet adds space. Set `pdf_margin` to a CSS length in `mm`, `cm`, `in` or `px` (a bare number is px): - `pdf_margin=15mm`: 15mm on every side; - `pdf_margin=10mm 20mm`: 10mm at the top and bottom, 20mm left and right (2 to 4 lengths work as in the CSS margin shorthand); - `pdf_margin_top`, `pdf_margin_right`, `pdf_margin_bottom` and `pdf_margin_left` override a single side. Each side is at most 4in. Other units, such as `em`, are refused with a `422`. ## Print or screen styles By default the page is printed with its print stylesheet (`pdf_media_type=print`), as "Save as PDF" in a browser does. Some sites hide navigation, banners and buttons in print. Set `pdf_media_type=screen` to print the page as it looks on screen instead. Background colors and images are printed by default; set `pdf_print_background=0` to leave them out. `pdf_scale` (0.1 to 2, default 1) scales the rendering, for example `0.8` to fit wide content on the page. ## Page ranges and the 200-page limit A PDF has at most 200 pages. Longer documents end after page 200, and the response says so with the header `X-Pdf-Truncated: pages`. Use `pdf_page_ranges` to pick pages, as in a print dialog: - `pdf_page_ranges=1`: the first page only; - `pdf_page_ranges=1-3,5`: pages 1 to 3 and page 5; - `pdf_page_ranges=8-`: page 8 to the end (at most page 200). Ranges are cut at page 200. A selection with no page among the first 200 (for example `201-210`) is refused with a `422` before anything is rendered. A selection with no page of the rendered document (for example `25-28` for a page that prints on 8 pages) answers `422` with the message `The pdf_page_ranges select no page of the rendered document.`, and is not billed. The response with a PDF that was cut carries `X-Pdf-Truncated`: `pages` when it ends at page 200 while the document went on, `height` when `pdf_fit_one_page` reached the tallest page (200 inches). A PDF that was not cut has no such header. Finding out whether a document of exactly 200 pages goes on takes a second print; when the render's time is too short for it, the PDF comes without the header. An [async job](https://screenshotbase.com/docs/async/) says the same in its status and webhook (`result.pdf_truncated`) and on its result download (the header). A long PDF also takes longer: print one of a hundred pages or more as an [async job](https://screenshotbase.com/docs/async/). ## One long page `pdf_fit_one_page=1` prints the whole page on a single PDF page: as wide as the paper (`pdf_paper_format`, turned by `pdf_landscape`) and as tall as the content. This suits receipts, long articles or pages you want to archive in one piece. The page is at most 200 inches tall (the size PDF viewers accept); anything below that is cut, and the response says so with `X-Pdf-Truncated: height`. `pdf_page_ranges` does not apply. The whole page means the page as it looks on screen at your `viewport_height`, printed: - Sections as tall as the screen (a `100vh` hero, a layout with `min-height: 100vh`) keep the height they have at `viewport_height` (default 800 px). On a printed page they would grow with the page and never fit. - Forced page breaks (`break-before: page`, `page-break-after: always`) are ignored: there is only one page. - The page's own `@page` size and margins are ignored; the margins are `pdf_margin`. ## Headers and footers `pdf_header_template` and `pdf_footer_template` print HTML at the top and bottom of every page, for running titles and page numbers. Send them in the JSON body of a `POST` (at most 16 KB each); in a query string they are refused with a `422`. These placeholders are filled in on every page: | Placeholder | Becomes | |---|---| | `{page}` | the page number | | `{total}` | the number of pages | | `{date}` | the date and time of the print | | `{title}` | the page's title | | `{url}` | the page's URL (`https://html.screenshotbase.invalid/` for HTML input) | ```json { "url": "https://example.com/report", "format": "pdf", "pdf_margin": "20mm 15mm", "pdf_header_template": "
{title}
", "pdf_footer_template": "
Page {page} of {total}
" } ``` A template is laid out across the whole width of the paper with 10px text; set your own sizes and padding with inline styles. It is printed inside the top (or bottom) margin, which is raised to at least 0.5in when it is smaller; give a taller template a larger margin. A template loads nothing: use inline styles and `data:` images. One that loads a style sheet, an `@import` or a web font cannot be printed and answers `422` (not billed). Scripts in a template do not run. ## Outline and tags PDFs are tagged by default: their structure (headings, paragraphs, lists, tables) is written into the file for screen readers, text extraction and search. Set `pdf_tagged=0` for a smaller file; a long, tagged document can be several times larger. Set `pdf_outline=1` to add an outline: the bookmarks a PDF viewer shows in its sidebar, one for each heading (`h1` to `h6`) of the page, nested as the headings are. The outline needs the tags, so `pdf_outline=1` with `pdf_tagged=0` is refused. ## Page breaks Where a page breaks is up to the page's CSS (`break-before`, `break-after`, `break-inside`). Every PDF also knows three helper classes you can put into your HTML: | Class | Effect | |---|---| | `sb-page-break` | a new page after the element | | `sb-page-break-before` | a new page before the element | | `sb-avoid-break` | the element is not split across two pages (if it fits on one) | ```html

Totals

...

Appendix

``` With `pdf_fit_one_page=1` there is only one page: forced breaks, these included, are ignored. ## Time limit A PDF must be rendered within 110 seconds of the start of the request: loading the page, the `delay` (at most 30 seconds), and printing. A render that takes longer is stopped and answered with `408`, the error code `target_timeout` and the message `The target website took too long to load.`; it is not billed. A `timeout` longer than what is left of the 110 seconds is cut to it. Through the [MCP server](https://screenshotbase.com/docs/mcp/), a tool call must finish within about 12 seconds, and `delay` is at most 7 there. If a page runs into the limit, try `wait_until=domcontentloaded` instead of waiting for every resource, or a shorter `delay`. A page that needs longer can be printed as an [async job](https://screenshotbase.com/docs/async/), with up to 300 seconds. ## Store the PDF With `upload=1`, the PDF is stored and the response is a JSON object with its public URL (`{"url": "https://cache.screenshotbase.com/screenshots/..."}`) instead of the file. The PDF costs the same either way. Without `upload=1`, the PDF is returned and not stored. If the PDF was rendered but could not be stored, the API answers `503` with `The file could not be stored. Please try again.`; that request is not billed. Through the [MCP server](https://screenshotbase.com/docs/mcp/), a PDF of up to 3 MB arrives as an embedded resource in the tool result; for a larger one, AI agents pass `upload: true` and use the URL. ## Other parameters The parameters that prepare the page work as for screenshots: `wait_until`, `delay`, `block_cookie_banners`, `block_ads`, `block_chats`, `hide_selectors`, `styles` and `ip_country_code`. `attachment_name` sets the filename of the download (`attachment_name=invoice-42` gives `invoice-42.pdf`). The image options `quality` and `full_page` are ignored for PDFs. ## Sandbox keys A sandbox API key returns a placeholder PDF without rendering the page, at no cost (`X-Cost: 0`). Use it to test your integration; use a live key for the real document. --- Source: https://screenshotbase.com/docs/quickstart/ # Quickstart This guide will get you all set up and ready to use the screenshotbase.com API. We'll cover how to get started using one of our API clients and how to make your first API request. We'll also look at where to go next to find all the information you need to take full advantage of our powerful REST API. Using an AI coding agent? Paste `Run curl -s https://screenshotbase.com/agents.md and follow it to set up screenshotbase for me in this project.` into it, or see [Onboard your agent](https://screenshotbase.com/agents/). Before you can make requests to the screenshotbase.com API, you will need to grab your API key from your dashboard. You find it under [App » Dashboard](https://app.screenshotbase.com/dashboard). ## Choose your client Before making your first API request, you need to pick which API client you will use. The API is plain HTTPS with an API key, so cURL or the HTTP client of your language is all you need; for PHP and other languages there are also [SDKs](https://screenshotbase.com/docs/sdks/). In the following example, you can see what to install for each. ```bash {{ title: 'cURL' }} # cURL is most likely already installed on your machine curl --version ``` ```bash {{ language: 'js' }} # fetch is built into Node.js 18 and newer node --version ``` ```bash {{ language: 'python' }} # The requests HTTP library pip install requests ``` ```bash {{ language: 'php' }} # Install the screenshotbase.com PHP SDK composer require everapi/screenshotbase-php ``` ## Making your first API request After picking your preferred client, you are ready to make your first call to the screenshotbase.com API. Below, you can see how to send a `GET` request to the `/take` endpoint to render a website. ```bash {{ title: 'cURL' }} curl -G "https://api.screenshotbase.com/v1/take?url=https%3A%2F%2Fbbc.com" \ -H "apikey: YOUR-API-KEY" \ -o bbc.png ``` ```js import { writeFile } from 'node:fs/promises' const params = new URLSearchParams({ url: 'https://bbc.com' }) const response = await fetch(`https://api.screenshotbase.com/v1/take?${params}`, { headers: { apikey: 'YOUR-API-KEY' }, }) await writeFile('bbc.png', Buffer.from(await response.arrayBuffer())) ``` ```python import requests response = requests.get( 'https://api.screenshotbase.com/v1/take', params={'url': 'https://bbc.com'}, headers={'apikey': 'YOUR-API-KEY'}, ) open('bbc.png', 'wb').write(response.content) ``` ```php $screenshotbase = new \Screenshotbase\ScreenshotbaseClient('YOUR-API-KEY'); file_put_contents('bbc.png', $screenshotbase->take(['url' => 'https://bbc.com'])); ``` ## What's next? Great, you're now set up with an API client and have made your first request to the API. Here are a few links that might be handy as you venture further into the screenshotbase.com API: - [Grab your API key from the screenshotbase.com dashboard](https://app.screenshotbase.com/dashboard) - [Learn about the different error messages in screenshotbase.com](https://screenshotbase.com/docs/status-codes/) --- Source: https://screenshotbase.com/docs/rate-limit/ # Rate limit & quotas You can use a certain number of requests per month, defined by your plan. You can use every request of that quota; once it is used up, the API returns a `429` HTTP status code (error code `quota_exceeded`, with `quota.resets_at` in the body; the first such answer also has a `Retry-After` header until the quota resets), and you either need to upgrade your plan or wait until your quota resets. Your plan also sets how many renders you can run at the same time ([concurrency](https://screenshotbase.com/docs/rate-limit/#concurrency)). The free plan also has a rate limit of 10 requests per minute. If you exceed it, the API returns a `429` HTTP status code (`rate_limit_exceeded`), and you have to wait until the end of the minute to make more requests; `Retry-After` says how many seconds that is. Paid plans have no per-minute limit. Not every request counts towards your monthly request volume. On a paid plan you can avoid the `429` with optional overage: turn it on with a monthly spending cap on the Billing page of the dashboard. Requests past the quota are then billed at your plan's overage price ([pricing](https://screenshotbase.com/pricing/)) until the cap is reached. Overage is off until you turn it on, and the free plan has none. Not every request counts Only successful calls count against your quota. Errors on our side and validation errors (e.g., a wrong parameter) do not count against your quota or rate limit. The few exceptions, such as the failure conditions past their daily allowance or a `504` whose render still finished, are listed under [status codes](https://screenshotbase.com/docs/status-codes/). ## Cost per request A screenshot, a PDF, a [markdown](https://screenshotbase.com/docs/markdown/) conversion and a render of [HTML input](https://screenshotbase.com/docs/html/) each count as one request. The `X-Cost` header of a successful response tells you how many requests the call counted. A PDF, markdown or a render of HTML input counts the same with and without `upload=1`, and your quota is checked before it is rendered: if the quota does not cover it, the API answers `429` with `quota.required` instead of rendering it. A screenshot counts as one request with and without `upload=1` (`X-Cost: 1` on its JSON response), also against the free plan's per-minute limit; an [async job](https://screenshotbase.com/docs/async/) of it is charged one request and refunded when it fails. A PDF, markdown or a render of HTML input requested with a sandbox API key costs nothing (`X-Cost: 0`). ## Concurrency Every plan is limited by the number of renders it runs at the same time; on paid plans this takes the place of a per-minute limit: | Plan | Renders at the same time | |---|---| | Free | 2 | | Basic | 5 | | Premium | 10 | | Enterprise | 25 | A request that would start one more render answers `429` with the error code `concurrency_limit_exceeded` and `Retry-After: 1`, before anything is rendered, and is not billed: send it again when one of your renders is done. Every render answers with `X-Concurrency-Limit` (your plan's number) and `X-Concurrency-Remaining` (how many more you could start right now). When our renderers are busy, a request can also answer `503` with the error code `renderer_busy` and `Retry-After: 5`, not billed. One account runs at most 8 renders on one of our render servers at a time, so that a single account never takes a whole server; above 8 renders at once (Premium and Enterprise), some requests can answer `503` `renderer_busy` while your plan's number is not reached. Send them again after `Retry-After`; they may go to another server. [Async jobs](https://screenshotbase.com/docs/async/) wait in a queue instead: your account may have its concurrency times 10 jobs queued or rendering at once. ## Response headers We attach specific headers to tell you your current quota and how much you have remaining in the period. The monthly headers are sent on every plan; the per-minute headers are only sent on the free plan. ```json lines X-RateLimit-Limit-Quota-Minute: 5 X-RateLimit-Limit-Quota-Month: 300 X-RateLimit-Remaining-Quota-Minute: 3 X-RateLimit-Remaining-Quota-Month: 199 ``` The minute headers count on the gateway node that answered the request: `X-RateLimit-Limit-Quota-Minute` shows that node's limit (5), and with our two gateway nodes that makes the 10 requests per minute of the free plan. `X-RateLimit-Remaining-Quota-Minute` is what is left on that node. Paid plans have no per-minute limit, so their responses carry no `X-RateLimit-*-Minute` headers; you still receive the monthly `X-RateLimit-*-Month` headers. You can also monitor your quota programmatically with the [status endpoint](https://screenshotbase.com/docs/status/) — requests to it are free. --- Source: https://screenshotbase.com/docs/sdks/ # SDKs screenshotbase.com publishes SDKs for PHP, Ruby, Go and R. The API itself is plain HTTPS with an API key in the `apikey` header, so any HTTP client works as well; the examples in this documentation use the PHP SDK, and `fetch` and `requests` for JavaScript and Python. --- Source: https://screenshotbase.com/docs/status/ # Status endpoint The status endpoint returns information about your current quota and the plan of your account. Requests to this endpoint do not count against your quota or rate limit. --- ## Check API status This status endpoint returns information about your current quota and the plan of your account. ### Response properties - **account_id** (integer): The ID of the account the API key belongs to. - **account_id_str** (string): The same id as `account_id`, as a string for JavaScript clients, whose numbers lose precision above 2^53. - **quotas** (object): Contains information about your request quota, split into a `month` and a `grace` bucket. - **quotas.month** (object): Your regular monthly request quota. Resets at the start of each billing month. - **quotas.grace** (object): A temporary grace quota that keeps your integration running while a subscription payment is still being processed. All values are 0 unless a grace allowance is currently active. - **plan** (object): The plan of the account: `name`, `interval`, `price_id`, `free`, `custom`, `status` (of the subscription, e.g. `active`), `renews_at`, `scheduled` (a plan change that starts later, or `null`), `upgrade_url` (`null` for a custom plan) and `plans_url` (every plan as JSON). Use it to check that an upgrade took effect. Each quota bucket contains the same three fields: - **total** (integer): The total number of requests included in this bucket. - **used** (integer): The number of requests you have already used in this bucket. - **remaining** (integer): The number of requests left in this bucket (`total - used`). ```bash {{title: 'cURL'}} curl -G https://api.screenshotbase.com/v1/status \ -H "apikey: YOUR-API-KEY" ``` ```js const response = await fetch('https://api.screenshotbase.com/v1/status', { headers: { apikey: 'YOUR-API-KEY' }, }) console.log(await response.json()) ``` ```python import requests response = requests.get( 'https://api.screenshotbase.com/v1/status', headers={'apikey': 'YOUR-API-KEY'}, ) print(response.json()) ``` ```php $client = new \Screenshotbase\ScreenshotbaseClient('YOUR-API-KEY'); $client->status(); ``` ```json {{title: 'Response'}} { "account_id": 313373133731337, "account_id_str": "313373133731337", "quotas": { "month": { "total": 300, "used": 72, "remaining": 228 }, "grace": { "total": 0, "used": 0, "remaining": 0 } }, "plan": { "name": "free", "interval": "month", "price_id": "price_1AbCdEfGhIjKlMnOpQrStUvW", "free": true, "custom": false, "status": "active", "renews_at": "2026-11-01T00:00:00+00:00", "scheduled": null, "upgrade_url": "https://app.screenshotbase.com/upgrade?utm_source=agent&utm_campaign=status&team=313373133731337", "plans_url": "https://api.screenshotbase.com/v1/agent/plans" } } ``` --- Source: https://screenshotbase.com/docs/status-codes/ # Request status codes You can tell if your request was successful by checking the status code when receiving an API response. If a response comes back unsuccessful, you can use the error type and error message to figure out what has gone wrong and do some rudimentary debugging (before contacting support). A successful request will be returned with status code `200`. Every response carries an `X-Request-Id` header, and the errors the API answers also carry it in the body as `request_id`. If an error is not explained here, send us that id with your request at support@screenshotbase.com and we can look it up. ## Error body Every error is JSON with a human-readable `message`, a machine-readable `error.code` (listed below), `actions` with links that help (upgrade, docs) and, for errors the API answers, the `request_id`. A `401` for a missing or invalid API key and the `429`s of the per-minute limit and of a used-up quota come from our gateway: they have the `X-Request-Id` header but no `request_id` in the body. Validation errors also carry an `errors` object that names each parameter. Where waiting helps, a `Retry-After` header says how many seconds to wait. An unexpected `500` carries no code, only the `request_id`, and so does the `503` "This request is still being rendered" (`Retry-After: 1`). The `info` line links a page that explains the error and what to do about it: the page of the browser's network error when a website could not be loaded (for example [ERR_CONNECTION_REFUSED](https://screenshotbase.com/errors/err-connection-refused/)), otherwise the page of the `error.code` (for example [invalid_parameters](https://screenshotbase.com/errors/invalid-parameters/)). All of them are listed under [errors](https://screenshotbase.com/errors/). ```json { "message": "The target website could not be loaded (ERR_CONNECTION_REFUSED).", "error": { "code": "target_unreachable", "message": "The target website could not be loaded (ERR_CONNECTION_REFUSED)." }, "actions": { "docs": "https://screenshotbase.com/docs/openapi.yaml" }, "info": "For more information, see documentation: https://screenshotbase.com/errors/err-connection-refused/", "request_id": "3f1c9a52-6d0e-4b7a-9c1e-2b8f5d4a7e10" } ``` --- ## Status codes Here is a list of the different categories of status codes returned by the screenshotbase.com API. Use these to understand if a request was successful. - **200**: A 200 status code indicates a successful response: the page was captured as the target answered it, whatever its HTTP status. A 404 or 500 page of the target, a login wall, or a bot challenge page is captured and billed like any other page, as is the error page the browser shows for it. The response says what the target answered: `X-Target-Status` is the HTTP status of its page, and `X-Blocked-By` names who served a bot challenge or block page (for example `cloudflare`); with `ignore_host_errors=0` such pages fail with a `424` instead (see below). - **202**: A 202 status code answers a request with `async=true`: the body is the job, which is rendered in the background (see [Async Jobs & Webhooks](https://screenshotbase.com/docs/async/)). - **400**: A 400 status code indicates that the hostname of the target website could not be resolved (DNS failure), error code `target_unresolvable`. Check that the URL you passed actually exists. A `POST` whose body the API cannot read also answers 400, error code `invalid_parameters`: JSON that does not parse or is not an object, JSON sent as a form (`curl -d` without the header `Content-Type: application/json`), or a body that is neither JSON nor a form (such as `text/plain`). Requests answered with 400 are not billed. - **401**: A 401 status code indicates that your API key is missing or invalid. A missing key returns the message `No API key found in request` (error code `missing_api_key`); an invalid key returns `Unauthorized` (error code `invalid_api_key`). - **403**: A 403 status code indicates that your request was refused: the API key belongs to a different everapi product (error code `key_not_allowed_for_product`), the request came from a referrer that is not on your API key's whitelist (error code `referrer_not_allowed`), or `ip_country_code` was sent without a plan that includes it (error code `plan_upgrade_required`). Every paid plan includes `ip_country_code`; a free account can make 5 renders with it in any 5 days, and the message names when the next one is available. An [async job](https://screenshotbase.com/docs/async/) requested with a key that belongs to no screenshotbase account answers 403 with the error code `forbidden`. Requests answered with 403 are not billed. - **404**: A 404 status code indicates that a requested endpoint does not exist, or that an [async job](https://screenshotbase.com/docs/async/) does not exist, belongs to another account, was deleted, or its result is no longer kept (error code `not_found`). - **405**: A 405 status code (error code `method_not_allowed`) indicates an HTTP method the endpoint does not support, and the `Allow` header names those it does: `/v1/take` accepts `GET`, and `POST` with a JSON body. A `HEAD` request to `/v1/take` answers 405 without rendering anything and is not billed. - **408**: A 408 status code (error code `target_timeout`) indicates that the target website took too long to load within the configured `timeout`, or that the render did not finish in its time limit: 110 seconds from the start of the request for every render, a screenshot, a PDF, [markdown](https://screenshotbase.com/docs/markdown/) including its conversion, or a render of [HTML input](https://screenshotbase.com/docs/html/), whatever the `timeout` (see [PDF time limit](https://screenshotbase.com/docs/pdf/#time-limit)). A tool call of the [MCP server](https://screenshotbase.com/docs/mcp/) has about 12 seconds. A less strict `wait_until` value, such as `domcontentloaded`, or a shorter `delay` often helps; a page that needs longer can be rendered as an [async job](https://screenshotbase.com/docs/async/), with up to 300 seconds. A render that runs out of time during its [`actions`](https://screenshotbase.com/docs/take/#actions) names the step (`... during actions.3 (wait_for_selector)`). Requests answered with 408 are not billed, unless an `evaluate` step or the `scripts` ran before, or a wait of yours ran out (`wait_for_selector`, or a step of `actions`): those count like the failure conditions, the first 25 a day free, then billed 1. - **409**: A 409 status code answers the result of an [async job](https://screenshotbase.com/docs/async/) that is not completed (error code `job_not_completed`), or a request whose `Idempotency-Key` is still being answered for an earlier request (error code `idempotency_key_in_use`, `Retry-After: 1`). - **422**: A validation error has occurred (error code `invalid_parameters`). Parameter validation failures return a JSON response with an `errors` object describing which parameter failed and why, for example `The delay field must not be greater than 30.`, a `quality` outside 0 to 100, a viewport outside its [bounds](https://screenshotbase.com/docs/take/#size-limits), more than 50 `hide_selectors`, `webhook_url` without `async=true`, or an `Idempotency-Key` sent again with a different request. An image larger than its format holds (a WebP taller than 16,383 px, say) answers with the error code `output_too_large_for_format` and a message that names the limit; `format=png` or a smaller page or viewport works (see [size limits](https://screenshotbase.com/docs/take/#size-limits)). A target URL that answers with a file instead of a web page, a PDF (`Content-Type: application/pdf`) or a download (`Content-Disposition: attachment`, or a type the browser does not display, such as `application/zip`), answers with the error code `target_not_renderable` and a message that names the type, for example `The target URL answered with a file (application/pdf), not a web page, so it cannot be rendered.`, as soon as the target's answer arrives. Markdown output of a page that rendered without any text or image to convert (an empty page, or content only in iframes or shadow DOM) answers with the error code `empty_content`; the same request with `format=png` shows what the browser got. URL-safety rejections carry the error code `target_blocked_private_range` and a `message` instead of an `errors` object: `URLs targeting localhost are not allowed.`, `URLs targeting private or reserved IP ranges are not allowed.` or `URLs targeting internal host names are not allowed.` (a URL that is not http or https, `Only http and https URLs are allowed.`, a URL on port 0 or on a port browsers block, such as 22 or 25, `URLs on port 0 or on a port browsers block (such as 22 or 25) are not allowed.`, and a `url` over 8,192 characters, `The url must not be longer than 8192 characters.`, are `invalid_parameters`). The API refuses URLs whose host is, or resolves to, a loopback, private, link-local (including cloud metadata), carrier-grade NAT or other reserved IPv4 or IPv6 address, and internal host names such as localhost, `*.local`, `*.internal` or single-label names. The same rules apply to every redirect and every resource the page loads: such resources are not fetched, and if the page itself redirects to such an address, the request fails with this status. With `ip_country_code`, the error code `geo_target_refused` means that the proxy network we load pages through for that country will not load this website (its policy for the site); another country, or the same request without `ip_country_code`, may work. Such a render does not count towards the free account's renders with `ip_country_code`. The failure conditions of a request answer 422 too: `selector_not_found` when no element matches [`selector`](https://screenshotbase.com/docs/take/#selector) within 5 seconds and `error_on_selector_not_found=1`, and `content_condition_failed` when the page shows a text of `fail_if_content_contains` or lacks one of `fail_if_content_missing`. A step of [`actions`](https://screenshotbase.com/docs/take/#actions), or the `scripts`, that cannot do what it says answers `action_failed`, naming the step by its index and type (`The step actions.2 (click) failed: ...`); mark a step `optional` to go on without it. They tell you something about the page, so the first 25 such failures a day per account are free and each one after that is billed like a render. Once an `evaluate` step or the `scripts` ran, any failure of that render (whatever its status, but a `500`, a failure of our own proxies and `geo_proxy_unavailable`) is billed one request, since that code could read the page. With [`proxy`](https://screenshotbase.com/docs/take/#proxy), the error code `proxy_not_allowed` means that your proxy is on a private, reserved or internal network (or resolves to one), which renders never connect to. For a PDF, `The pdf_page_ranges select no page of the rendered document.` means that none of the pages in `pdf_page_ranges` exists in the printed document. For markdown, `The page is too large to convert to markdown.` (error code `page_too_large`) means that the page has too much HTML, or its conversion needs too much memory; with `format=html` the same code means that the page's HTML is larger than 20 MiB. With [`max_file_size`](https://screenshotbase.com/docs/take/#max_file_size), the error code `max_file_size_unreachable` means that no encoding of the image fits, not even at the lowest quality, with the fewest colors and at a quarter of its size: raise `max_file_size`, or ask for a smaller image or another format. For [HTML and markdown input](https://screenshotbase.com/docs/html/) (`POST /v1/take`), the `errors` object can say `Send only one of url, html and markdown.`, `Either the url, the html or the markdown field is required.`, `The html field must not be larger than 10 MB (10485760 bytes); with async=true up to 50 MB.`, `The markdown field must not be larger than 1 MB (1048576 bytes).`, `The markdown field must be UTF-8 text.`, `The markdown field could not be converted to HTML: ...` or `The html field is only accepted in the JSON body of a POST request.` (also on `GET`, and the same for `markdown`). Requests answered with 422 are not billed, except the failure conditions past their daily allowance. - **424**: A 424 status code (error code `target_unreachable`) indicates that the target website could not be loaded: the render depends on it, and it failed. The message includes the underlying network error, e.g. `The target website could not be loaded (ERR_CONNECTION_FAILED).`; a connection that could not be established at all is reported as `ERR_CONNECTION_FAILED`. With [`proxy`](https://screenshotbase.com/docs/take/#proxy), the error code `proxy_error` means that your proxy could not be used (it could not be reached, refused the credentials or did not answer as a proxy) or could not connect to the website; the `info` link names the network error. With [`fail_if_request_failed`](https://screenshotbase.com/docs/take/#fail_if_request_failed), the error code `request_failed` means that a request of the page whose URL matches one of its patterns failed, with a network error (named in the message) or an HTTP status of 400 or more. Like the other failure conditions, the first 25 a day per account are free and each one after that is billed like a render. With `ignore_host_errors=0`, a target that answers a bot challenge or block page fails with the error code `target_blocked` (the body's `blocked_by` names who served it, as `X-Blocked-By` does), and one that answers an HTTP status of 400 or more with `target_http_error` (the body's `target_status`), instead of a capture of that page. Requests answered with 424 are not billed, except `request_failed` past the daily allowance of failure conditions. These failures were answered with `502` until October 2026; the `error.code` values are the same. A `502` never reached a client with its body: Cloudflare, in front of the API, replaces every `502` and `504` body with its own page. - **429**: A 429 status code indicates that you have hit a limit of your plan; it is not billed. For more [please upgrade your plan](https://app.screenshotbase.com/subscription). - `quota_exceeded`: your monthly quota is used up. Every request of your quota can be used: the request that uses the last one is answered, the next one gets this status. On the request that first finds the quota used up, `Retry-After` is the number of seconds until the quota resets (`quota.resets_at`); after that our gateway answers every request with this `429` without `Retry-After`, so read `quota.resets_at` in the body. A PDF, markdown, and any render of HTML input, is checked against your quota before the page is rendered: if the quota does not cover it, the response carries `quota.required`, the number of requests the call would have cost. - `grace_quota_exceeded`: the grace quota of an unpaid invoice is used up; it lasts until the invoice is paid, so there is no `Retry-After`. - `rate_limit_exceeded`: the free plan's limit of requests per minute (see [rate limit](https://screenshotbase.com/docs/rate-limit/)); `Retry-After` is the time until the next full minute. - `concurrency_limit_exceeded`: every render your plan may run at the same time is running (see [concurrency](https://screenshotbase.com/docs/rate-limit/#concurrency)); `Retry-After: 1`. Send the request again when one of your renders is done. An account may also have its concurrency times 10 [async jobs](https://screenshotbase.com/docs/async/) queued or rendering at once; past that the create answers this code without `Retry-After`: send it again when one of your jobs is done. - **500**: A 500 status code indicates an internal server error: the page could not be rendered for a reason not listed here. Such requests are not billed. Let us know at support@screenshotbase.com, with the `request_id` of the response. For [HTML input](https://screenshotbase.com/docs/html/), the error code is `render_failed` and the message `The page could not be rendered.`; other unexpected errors have no code. - **502**: A 502 status code comes from a gateway in front of the API, never from a render: Cloudflare's own HTML error page when it could not get an answer from our servers in time, for example while they restart. It has no JSON body and no `error.code`; send the request again after a few seconds. A website that could not be loaded answers `424` (see above). - **503**: A 503 status code indicates that a result requested with `upload=1` was rendered but could not be stored (error code `storage_unavailable`, `The file could not be stored. Please try again.`), or that every render slot of our servers is taken, or your account already runs 8 renders on that server (error code `renderer_busy`). Both carry `Retry-After: 5`; the request is not billed, send it again after that. With `ip_country_code`, the error code `geo_proxy_unavailable` (`Retry-After: 5`) means that the proxy network has no capacity for that country right now: send the request again later, or try another country; it is not billed and does not count towards the free account's renders with `ip_country_code`. A 503 with `Retry-After: 1` and the message `This request is still being rendered` means that an earlier attempt of the same request, with the same `X-Request-Id`, is still rendering. This response is not billed, but the earlier attempt is billed when it finishes, although its result does not reach you. A request you send again is a new render and is billed separately. - **504**: A 504 status code indicates that our gateway stopped waiting for the render before it finished. It can be Cloudflare's own HTML error page, without a JSON body or `error.code`. The render may still finish and be billed, although its result does not reach you; a request you send again is a new render and is billed separately. To avoid it, make the render faster: a shorter `delay`, a smaller page, or a less strict `wait_until`. --- --- Source: https://screenshotbase.com/docs/take/ # Take endpoint On this page, we’ll dive into the take endpoint you can use to render a website, or your own HTML, as an image, a PDF or markdown. AI coding agents: run `curl -s https://screenshotbase.com/agents.md` and follow it: an API key, the first call and the right plan, step by step. --- ## Render a website This endpoint renders a website and returns a screenshot, with `format=pdf` a PDF, or with `format=markdown` the page's content as markdown. The [PDF output](https://screenshotbase.com/docs/pdf/) and [URL to markdown](https://screenshotbase.com/docs/markdown/) guides explain these formats with examples. ### Required attributes - **url** (string): The URL of the website you want to render, as you would open it in a browser: it is requested as sent, with percent-escapes, credentials and the fragment (`#/route`, `#:~:text=`) kept, and an internationalized host name in its punycode form. Only public http and https URLs are rendered: addresses in private or reserved networks, internal host names, and port 0 and the ports browsers block (such as 22 or 25) are refused with a `422` (see [status codes](https://screenshotbase.com/docs/status-codes/#_422)). Maximum 8,192 characters. ### Optional attributes - **format** (string): The format of the file returned. Supported: jpg, jpeg, png, gif, webp, avif, svg (jpeg is treated as an alias for jpg), pdf, markdown and html. A gif is a single-frame image of at most 256 colors, made from a PNG capture: flat colors and text stay sharp, gradients show bands. An avif is at most 16,384 px on each side. An svg is the screenshot as a PNG inside an SVG of its size (no vectors), at most 16,384 px on each side. With html, the response is the rendered page's HTML (its DOM once it is ready, at most 20 MiB), served as a download in a sandbox; it costs one request, like markdown. With pdf, the page is printed as a PDF (see the [PDF attributes](https://screenshotbase.com/docs/take/#pdf-attributes) below); with markdown, its content is returned as markdown (see the [markdown attributes](https://screenshotbase.com/docs/take/#markdown-attributes) below). Default value is png. - **quality** (integer): The quality of the image returned, between 0 and 100. Applies to jpg, webp and avif; png, gif and svg accept it and ignore it (`max_file_size` may lower it, see `X-Final-Quality`). Default value is 80. - **full_page** (boolean): To take the screenshot of the full page, set full_page=1. The page is scrolled down first so that lazy-loaded images and content load (`full_page_scroll`), a page that scrolls inside an element of its own is expanded, and up to 20,000 CSS px of it are captured (100,000 with `async=1`, see `full_page_max_height`). Not used for PDFs, which follow their paper size, or for markdown. Default value is 0. - **viewport_width** (integer): The width of the browser viewport in pixels, between 1 and 7,680. The browser's viewport is the window area where you can see the website. Default value is 1280. - **viewport_height** (integer): The height of the browser viewport in pixels, between 1 and 16,384. The browser's viewport is the window area where you can see the website. Together with `viewport_width` and `device_scale_factor` it is limited to 74,649,600 device pixels (see [size limits](https://screenshotbase.com/docs/take/#size-limits)). Default value is 800. - **device_scale_factor** (number): The device scale factor (device pixel ratio) used when rendering the page. Use 2 to emulate a retina/high-DPI display: the viewport size stays the same, but the returned image contains twice as many pixels in each dimension. Must be between 0.5 and 3. Default value is 1. - **full_page_scroll** (boolean): With `full_page`, the page is scrolled down before the capture, so that lazy-loaded images and content load, then back to the top. It stops at the end of the page, at `full_page_max_height` or when the time limit of the render needs the rest. Set it to 0 to capture the page as it is after loading. Default value is 1. - **full_page_scroll_delay** (integer): Milliseconds to wait after each scroll step, between 0 and 5000. Default value is 100. - **full_page_scroll_by** (integer): CSS pixels per scroll step, between 100 and 16384. By default the viewport's height. - **full_page_max_height** (integer): The most of the page captured, in CSS pixels, between 1 and 20000 (up to 100,000 with `async=true`). By default the maximum. A longer page is cut there and the response carries `X-Full-Page-Truncated: true`. - **full_page_scroll_container** (string): A CSS selector of the element the page scrolls in, for pages laid out as an app shell, whose `html` and `body` are as tall as the window. It is expanded to its content before the capture. Without it the largest such element is found by itself. Maximum 255 characters. - **fix_sticky** (boolean): Bars fixed to the bottom of the window are drawn at the end of the full page instead of in the middle of the image, and sticky elements where the page puts them. Default value is 1. - **freeze_viewport_units** (boolean): Keeps elements sized in viewport units (`vh`, `svh`, `dvh` and the like) at the window's size during the capture. Default value is 0. - **full_page_overflow** (string): What happens to a full page larger than its format holds (see [size limits](https://screenshotbase.com/docs/take/#size-limits)): `scale` captures it smaller to fit and the response carries `X-Full-Page-Scaled` with the scale, `png` returns it as a PNG, `error` answers `422` with the error code `output_too_large_for_format` (not billed), also for a page taller than `full_page_max_height`. Default value is scale. - **ip_country_code** (string): The country code (ISO 3166-1 alpha-2) to use for the IP address when taking the screenshot. This allows you to simulate requests from different countries. Must be a lowercase code from the [supported country list](https://screenshotbase.com/docs/take/#supported-countries) below — the value is case-sensitive, so use `us`, not `US`. Included in every paid plan. A free account can make 5 renders with `ip_country_code` in any 5 days (a rolling window; a render counts when it starts, failed ones too, except those our proxy network refuses); after that the request answers `403` with the error code `plan_upgrade_required` and the time the next one is available, and is not billed. When the proxy network will not load the website, the request answers `422` with the error code `geo_target_refused`; when it has no capacity for the country, `503` with `geo_proxy_unavailable` and `Retry-After: 5`. Neither is billed. - **viewport_device** (string): A device to emulate, by its id from [GET /v1/devices](https://screenshotbase.com/docs/devices/) (or its name). The render gets the device's viewport, device scale factor (at most 3), mobile and touch emulation and its browser's user agent. `viewport_width`, `viewport_height`, `device_scale_factor`, `viewport_mobile` and `viewport_has_touch` replace the device's values when you send them. Example: `viewport_device=iphone-15-pro` - **viewport_mobile** (boolean): Whether to emulate a mobile browser. Set to 1 to enable, 0 to disable. Default value is the device's, or 0. - **viewport_has_touch** (boolean): Whether to emulate a touch screen. Set to 1 to enable, 0 to disable. Default value is the device's, or 0. - **viewport_landscape** (boolean): Whether to turn the device to landscape (its width and height swapped). Default value is 0. - **dark_mode** (boolean): Set to 1 to render the page with `prefers-color-scheme: dark`, 0 for light. Not set: the browser's default (light). - **reduce_motion** (boolean): Set to 1 to render the page with `prefers-reduced-motion: reduce` and hold it still: animations and transitions end, videos pause and GIFs show their first frame. Default value is 0. - **media_type** (string): The CSS media type of a screenshot or markdown: `screen` or `print`. PDFs use `pdf_media_type`. - **block_trackers** (boolean): Whether to block known trackers (the host rules of EasyPrivacy). Default value is 0. - **block_requests** (array): URL patterns of requests to block; `*` stands for any characters and a pattern matches the whole URL. At most 100 patterns of at most 2048 characters each. Example: `block_requests[]=*.woff2&block_requests[]=https://ads.example.com/*` - **block_resources** (array): Kinds of requests to block, comma separated: document (iframes), stylesheet, image, media, font, script, texttrack, xhr, fetch, prefetch, eventsource, manifest, ping, other. Example: `block_resources=image,font` - **proxy** (string): Your own proxy for the render, as `scheme://user:password@host:port`. The scheme is `http`, `https` (TLS to the proxy), `socks5` (host names resolve on our side) or `socks5h` (host names resolve at the proxy). Without a port: 80 for http, 443 for https, 1080 for socks5 and socks5h. The user name and password go to the proxy only and are never logged; percent-encode `@`, `:` and `/` in them. A proxy on a private or internal network answers `422` with the error code `proxy_not_allowed`; a proxy that cannot be reached, refuses the credentials or cannot connect to the website answers `424` with `proxy_error`. Neither is billed. Cannot be combined with `ip_country_code`. Maximum 2,048 characters. Example: `socks5h://user:password@proxy.example.com:1080` - **proxy_bypass_hosts** (array): Hosts loaded directly instead of through `proxy`: a host name or IP address, or `*.` and a domain for every host below it. You can pass several by using the parameter multiple times, with or without `[]` after the name; a single value is one host. At most 50 items of at most 255 characters each. Example: `proxy_bypass_hosts=*.cdn.example.com&proxy_bypass_hosts=fonts.example.com` - **delay** (integer): The delay in seconds to wait before taking the screenshot, the PDF or the markdown. Minimum value is 0, maximum value is 30, for every format and for HTML input (at most 7 through the [MCP server](https://screenshotbase.com/docs/mcp/)). Default value is 0. - **timeout** (integer): The timeout in seconds for the page load. Minimum value is 5, maximum value is 105. Default value is 60. Every render must finish within 110 seconds of the start of the request, whatever this value: a longer timeout is cut to what is left (see [time limit](https://screenshotbase.com/docs/pdf/#time-limit)). Through the [MCP server](https://screenshotbase.com/docs/mcp/), `timeout` is at most 60 and a tool call must finish within about 12 seconds. - **wait_until** (string): Determines when the screenshot should be taken based on page load state. Supported values (case-insensitive): - `load`: Waits for the load event (entire page and all resources loaded) - `domcontentloaded`: Waits for HTML document to be loaded and parsed - `networkidle0`: Waits until there are no active network connections for 500ms - `networkidle2`: Waits until there are no more than two active network connections for 500ms A list of up to 4 of them, comma separated (`wait_until=load,networkidle0`), waits for all. Default value is load. - **platform_profile** (string): `desktop` renders as Chrome on Windows 11 does: its user agent, platform and client hints, and the Windows font names (Segoe UI, Calibri, Cambria, Consolas, ...) drawn with installed fonts of the same metrics or the closest look. `linux` renders as Chrome on Linux, with the renderer's own fonts. The response header `X-Render-Engine` names the browser version. Default value is desktop. - **selector** (string): A selector of the element to capture instead of the viewport (images only): CSS, `>>>` to cross into shadow roots (`#app >>> .chart`) or `pierce/` (`pierce/.chart`). The element is waited for up to 5 seconds. Without one the viewport is captured, or the render fails with 422 `selector_not_found` (the first 25 a day free, then billed 1) when `error_on_selector_not_found` is true. Cannot be combined with `full_page` or the `clip_*` parameters. Maximum 1000 characters. - **selector_scroll_into_view** (boolean): Whether to scroll the element of `selector` into view before capturing it. Set to 1 to enable, 0 to disable. Default value is 1. - **error_on_selector_not_found** (boolean): Whether a `selector` that matches nothing fails the render (422 `selector_not_found`, the first 25 a day free, then billed 1) instead of capturing the viewport. Default value is 0. - **clip_x** (integer): The left edge of the region to capture, in CSS pixels of the page (images only). Minimum value is 0, maximum value is 100000. Default value is 0. - **clip_y** (integer): The top edge of the region to capture, in CSS pixels of the page. Minimum value is 0, maximum value is 100000. Default value is 0. - **clip_width** (integer): The width of the region to capture. With `clip_height` the image is that region of the page. Minimum value is 1, maximum value is 7680. Cannot be combined with `full_page` or `selector`. - **clip_height** (integer): The height of the region to capture. `clip_width` x `clip_height` x `device_scale_factor`² must be at most 74,649,600 device pixels. Minimum value is 1, maximum value is 16384. - **omit_background** (boolean): Whether to capture without the browser's white background, so that a page without a background of its own comes out transparent. PNG and WebP only; other formats ignore it. Default value is 0. - **wait_for_selector** (string): A selector (CSS, `>>>`, `pierce/`) to wait for before capturing, within `timeout`. A wait that runs out answers 408 `target_timeout` (the first 25 a day free, then billed 1). Maximum 1000 characters. - **wait_for_selector_count** (integer): How many elements must match `wait_for_selector`, at least. Minimum value is 1, maximum value is 1000. Default value is 1. - **navigation_timeout** (integer): The timeout in seconds of the navigation alone (until `wait_until`); `timeout` stays the timeout of the other waits. A value longer than what is left of the render's time limit is cut to it. Minimum value is 1, maximum value is 105. - **fail_if_content_contains** (array): Texts that fail the render when the page shows any of them (422 `content_condition_failed`, the first 25 a day free, then billed 1). Case and white space do not count. At most 20 texts of 1000 characters; repeat the parameter for more than one: `fail_if_content_contains[]=Access denied&fail_if_content_contains[]=captcha`. - **fail_if_content_missing** (array): Texts that fail the render when the page does not show one of them (422 `content_condition_failed`, the first 25 a day free, then billed 1). At most 20 texts of 1000 characters. - **fail_if_request_failed** (array): URL patterns: the render fails (424 `request_failed`, the first 25 a day free, then billed 1) when a request of the page whose URL matches one of them failed with a network error or an HTTP status of 400 or more. A pattern matches the whole URL, `*` standing for any characters: `https://cdn.example.com/*`, `*.css`. At most 20 patterns of 1000 characters. - **actions** (string): Steps to run on the page before it is captured, in order: a list of at most 20 step objects, best sent in the JSON body of a POST (in a GET as one JSON string). Each has a `type` and the fields of its type: `click`, `hover` (`selector`); `type` (`selector`, `text`: fills the field); `press` (`key`); `select` (`selector`, `values`); `scroll` (`selector`, or `x` and/or `y`); `wait_for_selector` (`selector`, `state`: attached, visible or hidden, `count`); `wait` (`duration_ms`); `wait_for_navigation` (`wait_until`); `evaluate` (`code`, at most 10 KB); `click_accept` (clicks the accept button of a cookie consent dialog); `press_escape`. Every step takes `optional` (skip it instead of failing) and `timeout_ms` (default 5000; `wait_for_selector` and `wait_for_navigation` wait within `timeout`). A step that cannot do what it says answers 422 `action_failed` naming the step by its index and type (the first 25 a day free, then billed 1); once an `evaluate` step or the `scripts` ran, any failure that is not ours is billed 1, since that code could read the page. `X-Actions-Completed` says how many steps completed (an async job also as `result.actions`). Actions cost nothing extra, and their texts are never logged. - **scripts** (string): JavaScript to run in the page after the actions, as the body of an async function. A script that throws answers 422 `action_failed`; once they ran, any failure that is not ours is billed 1. At most 50 KB (51,200 bytes). - **scripts_wait_until** (array): Only with `scripts`: the events to wait for after them (one, or a list such as `load,networkidle0`). - **block_cookie_banners** (boolean): Whether to block cookie banners on the page. Set to 1 to enable, 0 to disable. Default value is 0, or 1 for markdown. - **block_ads** (boolean): Whether to block ads on the page. Set to 1 to enable, 0 to disable. Default value is 0, or 1 for markdown. - **block_chats** (boolean): Whether to block chat widgets on the page. Set to 1 to enable, 0 to disable. Default value is 0. Hides the widgets of Intercom, LiveChat, Zendesk, Tawk.to, HubSpot, Drift, Crisp, Tidio, Freshchat, Olark, Zoho SalesIQ, Gorgias, Chatwoot, Help Scout, JivoChat, Smartsupp, Salesforce, Facebook Messenger and Shopify Inbox. - **hide_selectors** (array): An array of CSS selectors to hide on the page. Elements matching these selectors will be hidden using CSS display: none and visibility: hidden. You can pass multiple selectors by using the parameter multiple times, with or without `[]` after its name; a single value is one selector. At most 50 selectors of at most 255 characters each. Example: `hide_selectors=.cookie-banner&hide_selectors=#newsletter-popup` Any CSS selector works, quoted attribute selectors and escapes included (`[data-testid="banner"]`, `.md\:hidden`). Each selector applies on its own: one the browser cannot parse is skipped, and the others still apply. Elements inside iframes or shadow DOM are not reached. - **styles** (string): Custom CSS styles to inject into the page before taking the screenshot. This allows you to modify the page's appearance using any valid CSS. You should urlencode this value. Maximum 10,000 characters, valid UTF-8. Example: `body { background-color: red !important; }` The CSS also applies on pages whose Content-Security-Policy blocks inline styles. `@import` rules load their style sheets; one that fails to load, or that the page's Content-Security-Policy refuses, is skipped, and the rest of the CSS still applies. - **upload** (boolean): When set to 1, the file is stored on our CDN (markdown as a `.md` file) and the response is a JSON object containing its public `url` instead of the file itself. Without it, the result is only sent back to you and not stored. A render costs the same with and without it. It takes a boolean such as 1, 0, true or false; anything else answers `422`. Default value is 0. - **attachment_name** (string): The filename (without extension) used for the downloaded file. The file extension is appended automatically based on the chosen format (`.md` for markdown, which is returned inline unless you set this). Not used for JSON responses (`upload=1`, or markdown with `response_type=json`). `/`, `\` and control characters in the name are replaced by `_`. Maximum 255 characters. - **diagnostics** (boolean): When set to 1, the response is the render's diagnostics as JSON instead of the file: the status (`ok`, `partial`, `failed`), the target's HTTP status and final URL, the time of each stage, request, console and network counts, whether a cookie banner was on screen, and a signed link, valid 24 hours, to a HAR of the page's requests (no bodies, cookies or credentials). Billed like the same request without it; not available with `async=1`. Every render answers the headers `X-Render-Status`, `X-Target-Status`, `X-Target-Final-Url`, `Server-Timing`, `X-Requests`, `X-Cookie-Banner`, `X-Images-Pending` and `X-Console-Errors`. Default value is 0. - **best_attempt** (boolean): When set to 1, a page that does not finish loading in time is captured as it is instead of failing: the response carries `X-Render-Status: partial` and is billed. A target that sends nothing of its page (or only a redirect) still fails with 408, not billed. Default value is 0. - **ignore_host_errors** (boolean): When set to 0, a target that answers with a bot challenge or block page (Cloudflare, Akamai, PerimeterX, DataDome, Imperva, AWS WAF, Kasada, Sucuri, Vercel or a CAPTCHA wall) or with an HTTP error status fails the request with 424 (`target_blocked` with `blocked_by`, or `target_http_error` with `target_status`), not billed, instead of capturing that page. Every render of a URL answers `X-Target-Status` and, for a challenge or block page, `X-Blocked-By`. Default value is 1. - **headers** (array): Extra request headers, each as `Name: value`, at most 50 and 8 KB together. Sent to the origin of the url only, unless headers_scope is all. Hop-by-hop headers, Host, Proxy-*, Content-Length and Expect are refused; use cookies (for Cookie, Set-Cookie and Cookie2), authorization, user_agent and accept_language instead of those headers. With headers, cookies or authorization the site needs a valid certificate, and ip_country_code an https url. Example: `headers[]=X-Api-Key: abc&headers[]=X-Tenant: 7` - **headers_scope** (string): Which requests get the headers: target (the origin of the url) or all (every request of the page, third parties included). Default value is target. - **cookies** (array): Cookies for the url, each as a Set-Cookie value: `session=abc; Path=/; Secure; HttpOnly`. At most 50 cookies of at most 4 KB each. A Domain must be the url's host or a parent domain of it. - **authorization** (string): An Authorization header (Basic or Bearer) for the origin of the url only, sent with the first request. Example: `Basic dXNlcjpwYXNz` - **user_agent** (string): The user agent of the browser. Maximum 512 characters. - **time_zone** (string): The time zone of the browser, such as Europe/Berlin. - **locale** (string): The locale of the browser, such as de-DE. - **accept_language** (string): The languages of the Accept-Language header, such as `de-DE,de;q=0.9`. Maximum 256 characters. - **geolocation_latitude** (number): Latitude of the position the page's geolocation returns (https pages only), with geolocation_longitude. - **geolocation_longitude** (number): Longitude of that position, with geolocation_latitude. - **geolocation_accuracy** (number): Accuracy of that position in meters. - **bypass_csp** (boolean): Whether to ignore the page's Content-Security-Policy. Default value is 0. ### PDF attributes These attributes apply to `format=pdf` only; other formats ignore them. - **pdf_paper_format** (string): The paper size: A0, A1, A2, A3, A4, A5, A6, Letter, Legal, Tabloid (11 x 17 in) or Ledger (17 x 11 in), case-insensitive. `pdf_width` and `pdf_height` set any other size. Default value is A4. - **pdf_landscape** (boolean): Set to 1 to print in landscape orientation. Default value is 0. - **pdf_margin** (string): The margin of every page as a CSS length in mm, cm, in or px (a bare number is px), for example `15mm`. Two to four lengths set the sides as in the CSS margin shorthand: `10mm 20mm` is 10mm at the top and bottom and 20mm left and right. At most 4in per side. Default value is 0. - **pdf_margin_top** (string): The top margin as a CSS length; overrides `pdf_margin` for this side. `pdf_margin_right`, `pdf_margin_bottom` and `pdf_margin_left` work the same way. - **pdf_print_background** (boolean): Whether background colors and images are printed. Default value is 1. - **pdf_media_type** (string): `print` uses the page's print stylesheet, like "Save as PDF" in a browser; `screen` prints the page as it looks on screen. Default value is print. - **pdf_scale** (number): The scale of the page rendering, between 0.1 and 2. Default value is 1. - **pdf_page_ranges** (string): The pages to include, such as `1-3,5,8-` (`8-` means page 8 to the end). A PDF has at most 200 pages: ranges are cut at page 200, and longer documents end there (the response then carries `X-Pdf-Truncated: pages`). - **pdf_fit_one_page** (boolean): Set to 1 to print the whole page on a single PDF page as wide as the paper and as tall as the content, at most 200 inches; anything below is cut (`X-Pdf-Truncated: height`). `pdf_page_ranges` does not apply. Default value is 0. - **pdf_width** (string): The page width as a CSS length in mm, cm, in or px, for example `210mm`, instead of the paper format's; at most 200in. `pdf_height` sets the height the same way. The margins must leave at least 1in of the page each way. - **pdf_prefer_css_page_size** (boolean): Set to 1 to print in the page size the page's own CSS sets (`@page { size: A5 }`). Without it, the paper, size and orientation you set win over the page's CSS, and so do the margins you set. Default value is 0. - **pdf_header_template** (string): HTML printed at the top of every page, at most 16 KB, in the JSON body of a POST only. `{page}`, `{total}`, `{date}`, `{title}` and `{url}` are replaced. Laid out across the paper's width at 10px; the top margin is raised to at least 0.5in. Use inline styles and `data:` images: a template that loads a style sheet or a web font answers 422. `pdf_footer_template` prints at the bottom of every page the same way. - **pdf_outline** (boolean): Set to 1 to add a document outline (bookmarks) built from the page's headings. Default value is 0. - **pdf_tagged** (boolean): Whether the PDF is tagged (its structure for screen readers and text extraction); 0 writes a smaller file. Default value is 1. ### Image size and output attributes These attributes apply to images (jpg, png, gif, webp, avif and svg); a render with any of them is captured losslessly and encoded once at the end. - **image_width** (integer): The width of the returned image in pixels, between 1 and 16,384. Alone, the height follows the aspect ratio; together with `image_height` the image is scaled to cover both and cropped from the top. Images only. - **image_height** (integer): The height of the returned image in pixels, between 1 and 16,384 (see `image_width`). - **max_file_size** (integer): The most bytes the image may have, between 1024 and 52428800. jpg, webp and avif lower their quality first (the `X-Final-Quality` header names the quality used), png and gif their colors; then the image gets smaller, down to a quarter of its size. If nothing fits, the answer is 422 `max_file_size_unreachable`, not billed. - **png_compression** (integer): The zlib compression level of png (and the PNG inside an svg), between 0 and 9. Default value is 6. - **png_palette** (boolean): With 1, png and svg get a palette of at most 256 colors: much smaller for pages of flat colors and text. Default value is 0. - **png_colors** (integer): The most colors of the palette, between 2 and 256 (implies `png_palette`). - **preset** (string): Sets the parameters of a common image that the request does not set itself: `og` (1200 x 630), `x_card` (1200 x 600) and `linkedin` (1200 x 627), each a jpg of at most 300,000 bytes, and `thumbnail` (a 1280 x 800 page as a 400 x 250 jpg of at most 50,000 bytes). - **show_url** (boolean): With 1, a strip on top of the image shows the page's URL (after redirects). Default value is 0. - **show_timestamp** (boolean): With 1, the strip on top of the image shows the time of the capture (UTC). Default value is 0. ### Markdown attributes These attributes apply to `format=markdown` only. - **markdown_main_content_only** (boolean): With 1, only the main content of the page is converted: the article, without navigation, sidebars, headers, footers and banners. With 0, the whole page body. Default value is 1. - **response_type** (string): `text` returns the markdown as `text/markdown`; `json` returns a JSON object with `url`, `title`, `description` and `markdown`. Does not apply with `upload=1`. For every other format, `json` stores the file as `upload=1` does and answers `url`, `width`, `height`, `bytes` and `format` (width and height are null for pdf and html); it is billed as the file would be. Default value is text. ### Size limits Parameters outside their range, such as a `quality` above 100 or more than 50 `hide_selectors`, answer `422` with an `errors` object before anything is rendered. Parameters sent empty (`quality=`) or as `null` in a JSON body take their default. Parameters the API does not know, misspelled ones included, are ignored: the request is rendered (and billed) without them, so check the spelling if an option seems to have no effect. The viewport is limited to 74,649,600 device pixels: `viewport_width` x `viewport_height` x `device_scale_factor`², which is 3,840 x 2,160 at `device_scale_factor` 3, or 7,680 x 9,720 at 1. An image can be larger than its format holds. Measured in device pixels (the viewport, or the whole page with `full_page`, times `device_scale_factor`), a WebP is at most 16,383 px on each side, an AVIF or SVG at most 16,384 px, a JPEG at most 65,500 px, and a GIF at most 65,535 px and 25 megapixels in all. PNG has no limit of its own, but a capture of more than about 500 megapixels fails in the browser. A viewport capture larger than its format holds answers `422` with the error code `output_too_large_for_format` and a message that names the limit; the request is not billed. Use `format=png`, or a smaller viewport. A `full_page` capture is scaled to fit its format instead, and the response carries `X-Full-Page-Scaled` with the scale (`full_page_overflow=scale`, the default); `full_page_overflow=png` returns a PNG instead and `full_page_overflow=error` answers the `422`. At most 20,000 CSS px of the page are captured (100,000 with `async=1`; `full_page_max_height`) and at most 16,384 CSS px of its width; a longer or wider page is cut there and the response carries `X-Full-Page-Truncated: true`. A full page we encode again after the capture (`format=avif`, `gif` or `svg`, `image_width`/`image_height`, `max_file_size`, `show_url`/`show_timestamp`, `png_*` or a `preset`) is at most about 33.5 megapixels in device pixels (1,280 x 26,214 at `device_scale_factor` 1), other full pages at most about 134 megapixels; a larger one is scaled to that the same way. `full_page` scrolls the page down first, so that lazy-loaded images and content load, then captures it in one piece. A page laid out as an app shell, whose `html` and `body` are as tall as the window with the content scrolling inside an element of its own, is expanded to its content first (`full_page_scroll_container` names the element when the largest one is not it). Bars fixed to the bottom of the window are drawn at the end of the page (`fix_sticky`). ### Response By default, the response body is the file itself, served as a download: the image (`image/png`, `image/jpeg`, `image/gif`, `image/webp`, `image/avif` or `image/svg+xml`), the PDF (`application/pdf`) or the page's HTML (`text/html`, with `Content-Security-Policy: sandbox`). Markdown is returned as `text/markdown; charset=UTF-8`, or as JSON with `response_type=json`; any other format with `response_type=json` is stored and answered as JSON with its `url`, `width`, `height`, `bytes` and `format`. If you pass `upload=1`, the result is stored and you receive a JSON object with its public URL instead. With `async=1` the request answers `202` at once with a job, and the result is rendered in the background (up to 300 seconds); see [Async Jobs & Webhooks](https://screenshotbase.com/docs/async/). Successful responses include the following headers, also with `upload=1`. - **X-Cost** (integer): The number of requests this call counted against your quota: 1 for a screenshot, a PDF or markdown, 0 for a PDF, markdown or a render of HTML input requested with a sandbox API key. - **X-Execution-Time** (number): Server-side processing time in milliseconds. - **X-Concurrency-Limit** (integer): The renders your plan may run at the same time (see [concurrency](https://screenshotbase.com/docs/rate-limit/#concurrency)). - **X-Concurrency-Remaining** (integer): The renders your plan may start right now, besides this one. - **X-Render-Engine** (string): The browser and its version that rendered, such as `chromium/154.0.8037.97`, on every response, errors included. It changes when we update the browser. - **X-Target-Status** (integer): The HTTP status of the target page's document, after its redirects, on every render of a URL (errors included). A page of the target with a status of 400 or more is captured like any other unless `ignore_host_errors=0`. - **X-Full-Page-Truncated** (string): `true` when a `full_page` capture was cut at `full_page_max_height` (or 16,384 CSS px of width). - **X-Full-Page-Scaled** (string): The scale a `full_page` capture was taken at to fit its format, such as `0.7991`. - **X-Pdf-Truncated** (string): Only for a PDF that was cut: `pages` when it ends at the 200-page limit while the document goes on, `height` when `pdf_fit_one_page` reached 200 inches (see [PDF output](https://screenshotbase.com/docs/pdf/#page-ranges-and-the-200-page-limit)). - **X-Final-Quality** (integer): With `max_file_size`: the quality a jpg, webp or avif ended at to fit. - **X-Actions-Completed** (string): With `actions`: the steps completed of the steps sent, such as `3/4`, on every response of the render, errors included. - **X-Render-Status** (string): How the render went: `ok`, `partial` (`best_attempt=1` captured a page that was not ready in time) or `failed`, on every response of a render, errors included. With it come `X-Target-Final-Url` (the page's URL after redirects), `Server-Timing` (the milliseconds of each stage), `X-Requests` (the page's requests: total, finished, failed, pending, blocked), `X-Cookie-Banner` (`none`, `hidden` or `visible`), `X-Images-Pending` and `X-Console-Errors`. `diagnostics=1` answers them as JSON, with a link to a HAR of the page's requests. - **X-Blocked-By** (string): Only for a bot challenge or block page: who served it (`cloudflare`, `akamai`, `perimeterx`, `datadome`, `imperva`, `aws_waf`, `kasada`, `sucuri`, `vercel`, or `captcha` for a CAPTCHA wall). The page is captured and billed unless `ignore_host_errors=0`, which answers `424` `target_blocked` instead. Every response, errors included, carries an `X-Request-Id` header: the id of the request in our logs. Include it when you contact support about a request. Every render must finish within 110 seconds of the start of the request; a slower one answers `408` and is not billed. A page that needs longer can be rendered as an [async job](https://screenshotbase.com/docs/async/). Error responses are returned as JSON with an `error.code` and the `request_id` — see the [status codes](https://screenshotbase.com/docs/status-codes/) page for the full list of error codes and messages. ```bash {{title: 'cURL'}} curl -G "https://api.screenshotbase.com/v1/take?url=https%3A%2F%2Fbbc.com" \ -H "apikey: YOUR-API-KEY" \ -o bbc.png ``` ```js import { writeFile } from 'node:fs/promises' const params = new URLSearchParams({ url: 'https://bbc.com' }) const response = await fetch(`https://api.screenshotbase.com/v1/take?${params}`, { headers: { apikey: 'YOUR-API-KEY' }, }) await writeFile('bbc.png', Buffer.from(await response.arrayBuffer())) ``` ```python import requests response = requests.get( 'https://api.screenshotbase.com/v1/take', params={'url': 'https://bbc.com'}, headers={'apikey': 'YOUR-API-KEY'}, ) open('bbc.png', 'wb').write(response.content) ``` ```php // composer require everapi/screenshotbase-php $screenshotbase = new \Screenshotbase\ScreenshotbaseClient('YOUR-API-KEY'); file_put_contents('bbc.png', $screenshotbase->take(['url' => 'https://bbc.com'])); ``` ```bash {{title: 'PDF (cURL)'}} curl -G https://api.screenshotbase.com/v1/take \ -H "apikey: YOUR-API-KEY" \ --data-urlencode "url=https://example.com" \ -d format=pdf \ -d pdf_margin=15mm \ -o page.pdf ``` ```bash {{title: 'Markdown (cURL)'}} curl -G https://api.screenshotbase.com/v1/take \ -H "apikey: YOUR-API-KEY" \ --data-urlencode "url=https://example.com" \ -d format=markdown \ -d response_type=json ``` ```json {{title: 'Response (upload=1)'}} { "url": "https://cache.screenshotbase.com/screenshots/1337/01JA2Y6K7Q9W4V8T5R3N1M0P2Z.png" } ``` ```json {{title: 'Error response'}} { "message": "The target website took too long to load.", "error": { "code": "target_timeout", "message": "The target website took too long to load." }, "request_id": "3f1c9a52-6d0e-4b7a-9c1e-2b8f5d4a7e10" } ``` --- ## Render HTML This endpoint renders HTML (or markdown) that you send in a JSON body, instead of a URL, and returns it as a screenshot, a PDF or markdown. The [Render HTML guide](https://screenshotbase.com/docs/html/) covers markdown input, images, fonts, links and privacy. ### Required attributes - **html** (string): The HTML to render, at most 10 MB (10,485,760 bytes of UTF-8), with `async=1` 50 MB. It is rendered as an https page whose relative URLs do not resolve: use absolute URLs, a base element or `data:` URLs. Only accepted in the request body. Instead of `html` (or `url`) you can send `markdown`. - **markdown** (string): Markdown to render instead of `html`, at most 1 MB (1,048,576 bytes of UTF-8), in GitHub's flavor (tables, task lists, strikethrough, autolinks). It is rendered as an HTML page with a readable default style, which `styles` can change. Raw HTML in the markdown is kept; relative URLs do not resolve. Only accepted in the request body. ### Optional attributes Every attribute of [`GET /v1/take`](https://screenshotbase.com/docs/take/#render-a-website) works as a JSON field, for example `format`, `viewport_width`, `hide_selectors` (an array), the [PDF attributes](https://screenshotbase.com/docs/take/#pdf-attributes), the [markdown attributes](https://screenshotbase.com/docs/take/#markdown-attributes) and `upload`, as well as `async` for an [async job](https://screenshotbase.com/docs/async/). Instead of `html` you can also send `url` or `markdown`; send exactly one of them. With `url`, the request works like [`GET /v1/take`](https://screenshotbase.com/docs/take/#render-a-website) with the same options. ### Response The same as for `GET /v1/take`: the file, or a JSON object with its public `url` when `upload` is true. Every successful render of HTML counts as one request, also with `upload`, and includes the `X-Cost` and `X-Execution-Time` headers. It must finish within 110 seconds of the start of the request; a slower render answers `408` and is not billed. ```bash {{title: 'cURL'}} curl https://api.screenshotbase.com/v1/take \ -H "apikey: YOUR-API-KEY" \ -H "Content-Type: application/json" \ -d '{"html": "

Invoice INV-42

", "format": "pdf", "upload": true}' ``` ```js const response = await fetch('https://api.screenshotbase.com/v1/take', { method: 'POST', headers: { apikey: 'YOUR-API-KEY', 'Content-Type': 'application/json' }, body: JSON.stringify({ html: '

Invoice INV-42

', format: 'pdf', upload: true }), }) console.log(await response.json()) ``` ```python import requests response = requests.post( 'https://api.screenshotbase.com/v1/take', json={'html': '

Invoice INV-42

', 'format': 'pdf', 'upload': True}, headers={'apikey': 'YOUR-API-KEY'}, ) print(response.json()) ``` ```php $context = stream_context_create(['http' => [ 'method' => 'POST', 'header' => "apikey: YOUR-API-KEY\r\nContent-Type: application/json", 'content' => json_encode(['html' => '

Invoice INV-42

', 'format' => 'pdf', 'upload' => true]), ]]); var_dump(json_decode(file_get_contents('https://api.screenshotbase.com/v1/take', false, $context), true)); ``` ```json {{title: 'Response (upload: true)'}} { "url": "https://cache.screenshotbase.com/screenshots/1337/01JA2Y6K7Q9W4V8T5R3N1M0P2Z.pdf" } ``` --- ## Supported countries The `ip_country_code` parameter accepts the following lowercase ISO 3166-1 alpha-2 country codes. The value is case-sensitive — uppercase codes are rejected with a `422` validation error. ```text {{title: 'Supported ip_country_code values'}} ae, al, am, ar, at, au, az, ba, bd, be, bg, bh, bn, bo, br, bw, by, ca, cg, ch, cl, cm, cn, co, cr, cy, cz, de, dk, do, dz, ec, ee, eg, es, fi, fr, gb, ge, gh, gr, gt, hk, hr, hu, id, ie, il, im, in, iq, is, it, jm, jo, jp, ke, kg, kh, kr, kw, kz, la, li, lk, lt, lu, lv, ma, md, mk, mm, mo, mw, mx, my, mz, ng, nl, no, nz, om, pa, pe, ph, pk, pl, pr, pt, py, qa, ro, rs, ru, sa, sc, se, sg, si, sk, sl, th, tj, tm, tn, tr, tw, tz, ua, us, uy, uz, ve, vn, za, zm, zw ```