Skip to content

Commit 0de7bfc

Browse files
authored
Update screenshot-endpoint.mdx (#24505)
add auth example
1 parent 64c51ea commit 0de7bfc

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

src/content/docs/browser-rendering/rest-api/screenshot-endpoint.mdx

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ The `/screenshot` endpoint renders the webpage by processing its HTML and JavaSc
1111

1212
## Basic usage
1313

14+
### Capture a screenshot from HTML
15+
1416
<Tabs syncKey="workersExamples"> <TabItem label="curl">
1517

1618
Sets the HTML content of the page to `Hello World!` and then takes a screenshot. The option `omitBackground` hides the default white background and allows capturing screenshots with transparency.
@@ -56,6 +58,31 @@ For more options to control the final screenshot, like `clip`, `captureBeyondVie
5658

5759
## Advanced usage
5860

61+
### Capture a screenshot of an authenticated page
62+
63+
Some webpages require authentication before you can view their content. To capture a screenshot of these pages, you must provide valid session cookies. The following example navigates to a page that requires login. By providing a valid cookie in the `cookies` array, Browser Rendering will be able to access the secure content in order to capture the screenshot.
64+
65+
```bash
66+
curl -X POST 'https://api.cloudflare.com/client/v4/accounts/<accountId>/browser-rendering/screenshot' \
67+
-H 'Authorization: Bearer <apiToken>' \
68+
-H 'Content-Type: application/json' \
69+
-d '{
70+
"url": "https://example.com/protected-page",
71+
"cookies": [
72+
{
73+
"name": "session_id",
74+
"value": "your-session-cookie-value",
75+
"domain": "example.com",
76+
"path": "/"
77+
}
78+
]
79+
}' \
80+
--output "authenticated-screenshot.png"
81+
```
82+
83+
84+
### Navigate and capture a full-page screenshot
85+
5986
Navigate to `https://cloudflare.com/`, changing the page size (`viewport`) and waiting until there are no active network connections (`waitUntil`) or up to a maximum of `4500ms` (`timeout`). Then take a `fullPage` screenshot.
6087

6188
```bash

0 commit comments

Comments
 (0)