Skip to content

Browser API ​

Cognipeer exposes two browser-oriented surfaces under the client API:

  • browser profiles and browser sessions for direct Playwright-backed automation,
  • the same Browser Use toolset over the Model Context Protocol, published through the MCP module as the Browser internal service.

Browser Profiles ​

Browser profiles are reusable containers. They own shared defaults such as session configuration, artifact bucket selection, and default model/runtime metadata.

Create Browser ​

http
POST /api/client/v1/browser/browsers

Request ​

json
{
  "name": "research-browser",
  "defaultSessionConfig": {
    "headless": true,
    "viewport": { "width": 1440, "height": 900 },
    "idleTimeoutMs": 120000
  }
}

List / Get / Update / Delete Browser ​

  • GET /api/client/v1/browser/browsers
  • GET /api/client/v1/browser/browsers/:idOrKey
  • PATCH /api/client/v1/browser/browsers/:idOrKey
  • DELETE /api/client/v1/browser/browsers/:idOrKey

Browser Sessions ​

Browser sessions are the direct automation surface. A session always belongs to a browser profile.

Create Session ​

http
POST /api/client/v1/browser/sessions

Request ​

json
{
  "browserId": "brw_123",
  "name": "akbank-research"
}

List / Get Sessions ​

  • GET /api/client/v1/browser/sessions
  • GET /api/client/v1/browser/sessions/:sessionId

List Session Events ​

http
GET /api/client/v1/browser/sessions/:sessionId/events?limit=50&skip=0

Run Browser Action ​

http
POST /api/client/v1/browser/sessions/:sessionKey/actions

Example Action ​

json
{
  "type": "goto",
  "url": "https://www.akbank.com",
  "waitUntil": "networkidle"
}

Extract Content ​

http
POST /api/client/v1/browser/sessions/:sessionKey/extract
json
{
  "selector": "h1",
  "mode": "text",
  "multiple": true
}

Snapshot ​

http
GET /api/client/v1/browser/sessions/:sessionKey/snapshot

Screenshot / PDF ​

  • GET /api/client/v1/browser/sessions/:sessionKey/screenshot/live
  • POST /api/client/v1/browser/sessions/:sessionKey/screenshot
  • POST /api/client/v1/browser/sessions/:sessionKey/pdf

The screenshot POST saves to the session's artifact bucket and returns { artifact, eventId } (201). Pass "inline": true to also get the image back as a base64 content block, plus a structured summary with url, width and height. Add "persist": false to skip saving it (200; persist: false requires inline: true). With inline, a save that was asked for but failed (no artifact bucket, for example) answers persisted: false instead of artifact.

http
POST /api/client/v1/browser/sessions/:sessionKey/screenshot
{ "fullPage": true, "inline": true, "persist": false }

The browser_screenshot agent tool shows the image to the model directly; its persist: true option also saves it.

Find Text / Diagnostics / Export Profile ​

  • GET /api/client/v1/browser/sessions/:sessionKey/find?text=…&limit=… — locate visible text and get a durable target for each hit, cheaper than a full snapshot.
  • GET /api/client/v1/browser/sessions/:sessionKey/diagnostics — console messages, failed requests and the last dialog the session saw.
  • GET /api/client/v1/browser/sessions/:sessionKey/profile — export this session's cookies + origin storage, ready to attach as a browser profile.

Close / Delete Session ​

  • DELETE /api/client/v1/browser/sessions/:sessionKey
  • DELETE /api/client/v1/browser/sessions/by-id/:sessionId

Signed-In Profiles ​

  • PUT /api/client/v1/browser/browsers/:idOrKey/profile — attach a Playwright storageState so new sessions start authenticated. Body is either the raw export or { "storageState": …, "fileName": "profile.json" }. Encrypted at rest; the response is a summary only and the payload is never readable back.
  • DELETE /api/client/v1/browser/browsers/:idOrKey/profile

Browser Flows ​

A flow is a recorded, replayable step list — discovery once, deterministic execution afterwards.

  • POST /api/client/v1/browser/flows — create (steps may be supplied directly)
  • GET /api/client/v1/browser/flows — list, filterable by status, browserId, search
  • GET|PATCH|DELETE /api/client/v1/browser/flows/:idOrKey
  • POST /api/client/v1/browser/flows/record — turn a driven session into a flow
  • POST /api/client/v1/browser/flows/:idOrKey/run — replay it and wait for the result
  • GET /api/client/v1/browser/flow-runs — run history, filterable by flowId and status
  • GET /api/client/v1/browser/flow-runs/:runId

Declared outputs ​

A flow may declare the shape of the JSON it returns, in outputs:

json
{ "name": "amount", "source": "{{step.amountText}}", "type": "number", "required": true }

source is a template over {{step.<captureAs>}} and {{input.<name>}}; a lone placeholder passes the captured value through as-is, anything else renders to a string. type (string | number | boolean | json) is an optional cast: omit it to return the value exactly as captured. A cast that fails leaves the field out rather than returning NaN, and a required field that does not resolve fails the run even when every step succeeded.

With nothing declared, run.outputs is the raw captureAs map. Either way the raw map is also returned as run.captures. Changing steps or outputs bumps the flow's version; a run records the version it executed.

Replay into your own session (authoring) ​

POST /api/browser/flows/:idOrKey/steps/run is a dashboard API only. It runs a slice of the flow against a session the caller already holds, instead of opening one; the flow editor's ▶ uses it.

json
{ "sessionKey": "bs_…", "from": 2, "to": 5, "inputs": { "reference": "EXP-1" }, "captures": { "total": "42" } }

from defaults to the first step, to (exclusive) to the end. captures carries what an earlier slice read so {{step.x}} still resolves. It returns { results, captures, failedStepIndex?, errorMessage? } and records no run. Inputs bind leniently here: a required input with no value yet leaves its placeholder in the payload rather than refusing, which is what makes a half-built flow replayable. A real run still refuses.

A step's action uses the same schema as a live action, with one added rule: a stored ref is rejected. A ref is valid only for the snapshot that produced it, so a persisted one resolves to nothing on the next run and burns the step's whole timeout finding that out. Use role + name, testId, label, placeholder, text or selector.

A failed run still returns 200 with run.status: "failed" — the request succeeded and the caller gets a complete, inspectable answer including failedStepIndex and per-step results.

Browser over MCP ​

A browser is published over MCP from the MCP module, not from the browser itself: create an MCP server with source type Internal service, provider Browser and the browser to publish (internalConfig: { provider: "browser", instanceKey: "<browserKey>" }). The dashboard API (POST /api/mcp) creates it; the client API's POST /api/client/v1/mcp does not create internal servers (see MCP servers). The server is then reached on the usual MCP endpoints (/api/client/v1/mcp/:serverKey/…, see the MCP Servers API), with the MCP module's tool toggles, renames, guardrail binding, logs and hubs. A browser server is token-only: creating or updating it, or a composite with a browser member, with accessMode: "public" answers 400. The former per-browser endpoints (/api/client/v1/browser/:browserKey/mcp/sse and /mcp/message) have been removed.

Sessions are explicit, so they work over streamable HTTP and SSE alike, from a composite server and from an agent binding:

  1. browser_open_session opens a session on the published browser and returns its sessionKey.
  2. Every page tool takes that sessionKey as a required argument. A key opened through another MCP server, on another browser, or outside MCP (the dashboard, an agent run) is answered as not found.
  3. browser_close closes the session. A session left open is closed by the browser's idle timeout.

Browser MCP Toolset ​

Besides browser_open_session, the server exposes the Browser Use-compatible tools:

  • browser_navigate, browser_history (back / forward / reload)
  • browser_click, browser_hover, browser_type, browser_press
  • browser_select, browser_check, browser_upload, browser_scroll
  • browser_wait, browser_tabs
  • browser_snapshot (accessibility tree with [ref=…] markers), browser_find, browser_extract
  • browser_diagnostics (console, failed requests, last dialog)
  • browser_screenshot, browser_pdf
  • browser_list_flows, browser_run_flow (no sessionKey: a flow runs in a session of its own)
  • browser_close

The list is derived from the same definitions the Browser Use system tool binds, so the MCP and agent surfaces cannot drift apart.

Relationship To Cognipeer Agents ​

Standalone browser agent management has been removed. If you want a Cognipeer-managed agent to browse autonomously:

  1. create or reuse a browser profile,
  2. attach the Browser Use system tool to the agent in Cognipeer,
  3. invoke that agent through the normal agents / responses surface.

The agent addresses elements by the ref values in browser_snapshot's output. Those are valid only until the next snapshot — every action result also returns resolvedTarget, the durable role/name form, which is what a flow step stores. Where a flow already exists for the task, browser_run_flow replays it without a model in the loop.

For external runtimes or custom orchestrators, use the browser session API directly or publish the browser as a Browser internal-service MCP server.

Studio · Pulse · Console · Agent SDK and more — the Cognipeer documentation hub