Browserbase enables navigation policies per project. Contact support@browserbase.com to turn them on. Until then, the navigation policies API returns
404 and sessions ignore riskPolicyId.How Browserbase decides a navigation
Browserbase checks each navigation’s host in this order:- Domain overrides. If an override covers the host, its decision applies. An override for
example.comalso coverswww.example.comand every other subdomain. When several overrides cover a host, the most specific one wins, soallowondocs.example.combeatsblockonexample.com. - Categories. Otherwise, Browserbase classifies the host into one or more categories. Each category takes its rule from
allowedCategoriesorblockedCategories, ordefaultDecisionif the policy has no rule for it. If Browserbase can’t classify the host, or part of its classification has no Browserbase category, that part counts as unknown and takesunknownDomainBehavior. The strictest result wins: if the policy blocks any of the host’s categories, Browserbase blocks the navigation.
defaultDecision: "block" only allows a host when the policy allows all of its categories. Add an allow override for sites you always need.
If Browserbase can’t reach a decision in time, for example because classification is unavailable, it blocks the navigation. Overrides don’t need classification, so they keep working.
What a policy checks
A policy applies to navigations:- page loads in the top frame, including links, form submissions, and
page.goto() - iframes
- popups and
window.open() - tabs opened with a URL, such as
Target.createTarget - each hop of a redirect
fetch and XHR calls, and WebSockets. It also doesn’t check pages that don’t load from the network, such as about:blank, data:, and blob: URLs.
When the policy blocks a navigation:
- Top frame: the page lands on
https://www.browserbase.com/navigation-blocked.page.goto()doesn’t throw, so checkpage.url()to detect a block. - Iframe: the frame fails to load with
net::ERR_BLOCKED_BY_CLIENT. The rest of the page keeps loading.
Service workers and Contexts
A site’s service worker can answer a navigation without it ever reaching the network. In a policy-bound session that loads a Context, pages skip their service workers, so the policy checks every navigation. Sites that depend on a service worker, such as for offline support, run without it in these sessions.Create a policy
Policies belong to the project of the API key that creates them. Fields you omit take these defaults: enabled,defaultDecision: "block", unknownDomainBehavior: "block", no category rules, and no overrides.
- Node.js
- Python
- cURL
Node.js
id. Browserbase stores domains lowercase without a trailing dot.
Bind a policy to a session
Pass the policy’s ID asbrowserSettings.riskPolicyId when you create a session. The policy must belong to the session’s project and be enabled; otherwise session creation fails with 400.
- Node.js
- Python
- cURL
Node.js
browser.newContext() fails with CDP command Target.createBrowserContext is not allowed. In Playwright, open pages on the session’s default context instead:
Node.js Playwright
Edit, disable, or delete a policy
A session keeps the policy as it was when the session started. Edits, disables, and deletes apply only to sessions that start afterwards.- Edit with
PATCH /v1/navigation-policies/{id}. Omitted fields keep their values. Lists such asdomainOverridesreplace the stored list rather than appending to it. - Disable by setting
enabledtofalse. New sessions can’t bind a disabled policy. It stays editable, and you can re-enable it. - Delete with
DELETE /v1/navigation-policies/{id}.
Categories
A host can belong to more than one category.
Related guides
Allowed domains
Restrict a session to a fixed list of domains.
Contexts
Reuse cookies and site data across sessions.