---
title: "Allowed domains"
description: "Restrict session navigation to an allowlist of domains"
image: "https://help.agent.mq/og.svg"
---

> Documentation Index
> Fetch the complete documentation index at: https://help.agent.mq/llms.txt
> Use this file to discover all available pages before exploring further.

# Allowed domains

Allowed domains let you restrict which websites a session can navigate to. If you pass one or more domains, Browsers blocks top-level page navigations to any domain not on the list. This keeps automated sessions focused and prevents unintended navigation.

> **Note**
>
> This feature is experimental and its behavior may change in future releases.

## Restricting navigation

Use the `allowedDomains` field in `browserSettings` when creating a session to specify which domains are permitted. Below are examples in both Node.js and Python SDKs.

### Node.js

```typescript SDK
  import Browsers from "@agentmq/browsers";

  const browsers = new Browsers({ apiKey: process.env.AGENTMQ_TOKEN! });

  async function createSession() {
    const session = await browsers.sessions.create({
      browserSettings: {
        allowedDomains: ["example.com", "docs.example.com"],
      },
    });
    console.log(`Session URL: https://agent.mq/sessions/${session.id}`);
    return session;
  }

  const session = createSession();
```

### Python

```python SDK
  from agentmq.browsers import Browsers
  import os

  browsers = Browsers(api_key=os.environ["AGENTMQ_TOKEN"])

  def createSession():
      session = browsers.sessions.create(
          browser_settings={
              "allowedDomains": ["example.com", "docs.example.com"],
          },
      )
      print(f"Session URL: https://agent.mq/sessions/{session.id}")
      return session

  session = createSession()
```

> **Note**
>
> **Limitations:**
>
> * **Subdomain matching:** Adding `example.com` also permits `www.example.com`, `a.b.example.com`, and any other subdomain. You do not need to list subdomains separately.
> * **Top-frame navigation only:** Browsers checks top-frame navigations. It does not block iframe/subframe loads or in-page resource requests (images, scripts, XHR, etc.).
> * **HTTP(S) domains only:** Browsers does not apply the allowlist to navigations to `about:blank`, `chrome://`, `file://`, and similar URLs.

For a full list of session options and configuration fields, check out the [API reference for creating a session](/browsers/api).

Source: https://help.agent.mq/browsers/security/allowed-domains/index.mdx
