Skip to content

Allowed domains

Restrict session navigation to an allowlist of domains

Updated View as Markdown

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.

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.

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();
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()

For a full list of session options and configuration fields, check out the API reference for creating a session.

Navigation

Type to search…

↑↓ navigate↵ selectEsc close