Skip to content
Documentation centerManual · v1.3.83

Tools and automation

Automation with Playwright and Puppeteer

Connect your scripts to a profile browser using the local API’s CDP endpoint.

v1.3.833 min readLeer en español ↗

Prepare your environment

API and CDP automation is included in Pro and Max; on other plans the API replies that your plan does not include it. Keep Mantis open and signed in on the same PC where the script runs. First prepare and test a profile through the interface.

  1. Request GET /v1/perfiles/abiertos to see the ones already open, including the ones you opened, or GET /v1/perfiles?q=<part of the name> to find one. Routes accept its id or its exact name.
  2. Start it with POST /v1/perfiles/:id/start and use automation.wsEndpoint from the response. If it is already open, it returns that same browser and does not open another one.
  3. Connect Playwright or Puppeteer to that endpoint; reuse the profile context to keep its cookies and settings.
  4. When finished, disconnect your tool and stop the profile if your task should close it.
Automation panel with API indicator and examplesAutomation panel with API indicator and examples
Real interface · Example data The “API active” indicator confirms everything is ready. The tabs show Python and Node examples; “Copy example” copies them.

Python with Playwright

Install dependencies with pip install requests playwright. This example connects to the Chromium launched by Mantis and stops the profile when finished; replace PROFILE_ID with your chosen id.

Python example
import requests
from playwright.sync_api import sync_playwright

API = "http://127.0.0.1:3848/v1"
PROFILE_ID = "REPLACE_WITH_PROFILE_ID"

def api(method, path):
    response = requests.request(method, API + path, timeout=120)
    response.raise_for_status()
    return response

started = api("POST", f"/perfiles/{PROFILE_ID}/start").json()
try:
    with sync_playwright() as p:
        browser = p.chromium.connect_over_cdp(
            started["automation"]["wsEndpoint"]
        )
        context = browser.contexts[0]
        page = context.new_page()
        page.goto("https://example.com")
        print(page.title())
        page.close()
finally:
    api("POST", f"/perfiles/{PROFILE_ID}/stop")

Node.js with Puppeteer

Install puppeteer-core and save this example as an .mjs file. Use a Node version with fetch. disconnect closes the automation connection; /stop closes the profile.

Node.js example
import puppeteer from "puppeteer-core";

const API = "http://127.0.0.1:3848/v1";
const PROFILE_ID = "REPLACE_WITH_PROFILE_ID";
async function api(path, method = "GET") {
  const response = await fetch(API + path, { method });
  if (!response.ok) {
    throw new Error(response.status + ": " + await response.text());
  }
  return response;
}

const started = await (await api(
  "/perfiles/" + PROFILE_ID + "/start", "POST"
)).json();
let browser;
try {
  browser = await puppeteer.connect({
    browserWSEndpoint: started.automation.wsEndpoint,
    defaultViewport: null,
  });
  const page = await browser.newPage();
  await page.goto("https://example.com");
  console.log(await page.title());
  await page.close();
} finally {
  if (browser) await browser.disconnect();
  await api("/perfiles/" + PROFILE_ID + "/stop", "POST");
}

Working with multiple sessions

  • Assign one profile per task and avoid two scripts controlling the same one at once.
  • Limit how many you open at once by RAM, CPU and connection: each profile is a real browser.
  • Keep the fingerprint in Mantis; do not override it from the script if you want to keep the profile’s identity.
  • With an AI (Claude, ChatGPT, Codex…): in Automation click Copy instructions for an AI and paste them along with what you want it to do. They explain how to find your open profiles and connect without opening another browser.
  • Selenium or other tools need a Chromium/CDP-compatible integration (debuggerAddress with the port returned by /start).

Cookies and storage

Necessary: used when you choose a language, sign in or buy. Disabling them affects those features; you can clear them through your browser.

Optional first-party statistics: daily totals by page and campaign, retained for 180 days. No stored IP addresses or visitor identifiers (if you arrive from an ad, a hashed code of your connection for 7 days to attribute the signup in the app). These first-party statistics are not sent to Google. The campaign is remembered only in this tab if you accept. You can reject or withdraw your choice here; website features remain available.

Google receives technical data (IP address, browser and ad click), verified signups and confirmed purchases (order reference, amount and currency). We send no emails, passwords or browser profile data. Ad personalization requires the additional option below. We use no enhanced conversions. Its tag loads only if you accept this option.

Allows ads on Google, YouTube, Facebook and Instagram based on your website visits and interactions. Includes the Google measurement above and the Meta pixel for visits, downloads, verified signups and confirmed purchases. Meta receives IP address, browser, advertising identifiers and website events; never emails, passwords or browser profile data. You can withdraw permission here.

Only with this option, TikTok receives visits, downloads, verified signups and confirmed purchases through its pixel and Events API. Includes IP address, browser, ad identifiers, order reference, amount and currency; never emails, passwords or browser profile data. This permission is independent of Google and Meta and can be withdrawn here.

Read the full policy