contextId.
Fetching with a context
Pass acontextId to fetch pages that require a login. Browserbase calls the saved login state a context. Fetch sends only the cookies saved in that context. It follows normal browser cookie rules: each cookie goes only to the domains and paths it belongs to, including across redirects, and Fetch drops expired cookies.
- Node.js
- Python
- cURL
Node.js
- Fetch uses the cookies saved when the browser session ends. Log in with a browser session that uses the context with
persist: true. - Fetch is read-only. Fetch doesn’t write cookies the site sets during a request back to the context.
- Fetch requires a context saved on or after September 1, 2026. To use an older context, run one browser session with that context and
persist: true. The context works with Fetch after that session ends. - Bring-your-own-storage uses your existing role. If your project stores contexts in your own S3 bucket, Fetch reads them with the role you configured for it. Fetch only needs
s3:GetObjecton your contexts bucket, which the BYOS setup guide already grants.
Error handling
Requests with acontextId can return these errors, in the same format as other Fetch errors.
Context not found (400)
Context not found (400)
The context doesn’t exist or belongs to another project.
Context storage access denied (400)
Context storage access denied (400)
Your project stores contexts in your own S3 bucket, and Browserbase couldn’t assume your BYOS role or your KMS key refused to decrypt the context. Check the role’s trust policy, external ID, and KMS key policy.
Context not supported for this project (400)
Context not supported for this project (400)
Your project uses an older context configuration that Fetch can’t read. Contact support to enable it.
Some sites authenticate data requests with tokens that the page’s JavaScript creates per session, such as an
Authorization header. Fetch only sends cookies, so it can’t authenticate those requests. Use a browser session with the saved login for those sites.Proxies
Route Fetch requests through Browserbase’s proxy network or target a specific location.
Fetch
Return page content without an interactive browser session.