Run your JavaScript in the page, then capture the result
Some pages only show what you need after something happens. This is the parameter for making that something happen.
scriptsscripts_wait_untilbypass_cspclickhovercurl --fail-with-body "https://api.pagecapture.dev/v1/take" \
-H "X-Access-Key: $PAGECAPTURE_KEY" \
-H "Content-Type: application/json" \
--data '{"url":"https://example.com","format":"jpg","scripts":"document.querySelectorAll('"'"'dialog[open]'"'"').forEach((node) => node.close())"}' \
-o capture.jpgVerified 2026-08-13 by running the published code against a fixture.
Configure it in the playgroundWhat it does
- Evaluates each entry in the page context, in order, wrapped in an async function so `await` works.
- Waits for the navigation state named by `scripts_wait_until` first, so a script that touches the DOM does not race the parser.
- Fails loudly and specifically: a script that throws returns `request_not_valid` naming the index that threw, rather than a generic capture failure.
What it does not do
- Does not run in Node. There is no `require`, no filesystem, no environment and no CDP access — only what a page script has.
- Does not let a script navigate away. If the URL changes, the capture stops with `script_triggers_redirect`, because the artifact would no longer be of the page you asked for.
- Does not get its own timeout. A script that never resolves is ended by the job's `timeout`, and that failure is not billed.
Every limit on this page is the one the API enforces
These rows are read from the same parameter table that validates your request. Nothing here is transcribed, so a number cannot drift from the behaviour it describes.
| Parameter | Type | Default | Range | Endpoints | Cache key |
|---|---|---|---|---|---|
scriptsJavaScript executed in the page context, in order. | string[] | — | — | /v1/take, /v1/animate | In |
scripts_wait_untilNavigation state to reach before running scripts. | enum | load | — | /v1/take, /v1/animate | In |
bypass_cspBypass the page Content Security Policy. Opt-in and recorded. | boolean | false | — | /v1/take, /v1/animate | In |
clickSelector clicked before capturing. | string | — | — | /v1/take, /v1/animate | In |
hoverSelector hovered before capturing. | string | — | — | /v1/take, /v1/animate | In |
How it behaves next to the rest of the request
scripts_wait_untilNavigation state to reach before running scripts.
Defaults to `load`. Use `domcontentloaded` when your script only needs the DOM and the page has heavy assets, or `networkidle` when it depends on data that arrives by XHR.
clickSelector clicked before capturing.
For a single interaction, `click` is smaller and safer than a script — and it fails by default when the selector is missing, which a script would not.
bypass_cspBypass the page Content Security Policy. Opt-in and recorded.
Pages with a strict CSP can refuse injected execution. Turning this on changes the security posture of the render, so it is opt-in and recorded on the request.
Errors this option can produce
request_not_validHTTP 400The request is not valid.
script_triggers_redirectHTTP 400A custom script navigated the page away from the requested URL.
timeout_errorHTTP 500 · retryableThe capture did not complete within the allowed time.
None of them is billable. No error code in the catalog is.
Related capabilities
All capabilities100 successful captures a month, every feature unlocked, no card.
Get an API keyPageCapture Engineering · reviewed by PageCapture API maintainers · Verified 2026-08-13 by running the published code against a fixture.