Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
129 changes: 129 additions & 0 deletions docs/browser-cloud-api-reference.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
---
id: browser-cloud-api-reference
title: API Reference - TestMu AI Browser Cloud
hide_title: true
sidebar_label: API Reference
description: REST API reference for TestMu AI Browser Cloud. Planned endpoints for sessions, context, profiles, files, extensions, quick actions, and tunnels.
keywords:
- browser cloud api
- rest api browser cloud
- browser cloud endpoints
- api reference
url: https://www.testmuai.com/support/docs/browser-cloud-api-reference/
site_name: TestMu AI
slug: browser-cloud-api-reference/
canonical: https://www.testmuai.com/support/docs/browser-cloud-api-reference/
---

import BrandName, { BRAND_URL } from '@site/src/component/BrandName';

<script type="application/ld+json"
dangerouslySetInnerHTML={{ __html: JSON.stringify({
"@context": "https://schema.org",
"@type": "BreadcrumbList",
"itemListElement": [{
"@type": "ListItem",
"position": 1,
"name": "TestMu AI",
"item": BRAND_URL
},{
"@type": "ListItem",
"position": 2,
"name": "Support",
"item": `${BRAND_URL}/support/docs/`
},{
"@type": "ListItem",
"position": 3,
"name": "Browser Cloud",
"item": `${BRAND_URL}/support/docs/what-is-browser-cloud/`
},{
"@type": "ListItem",
"position": 4,
"name": "API Reference",
"item": `${BRAND_URL}/support/docs/browser-cloud-api-reference/`
}]
})
}}
></script>

# API Reference (Coming Soon)

The REST API will expose all TestMu AI Browser SDK capabilities over HTTP, making
<BrandName /> Browser Cloud accessible from any programming language. In the meantime, the [TestMu AI Browser SDK quickstart](/support/docs/launch-first-session/) provides full access to all these capabilities from Node.js.

Here's a preview of the planned endpoint structure:

## Planned Endpoints

```
Sessions
POST /v1/sessions Create a session
GET /v1/sessions List sessions
GET /v1/sessions/:id Get session details
GET /v1/sessions/:id/live Get live session details
DELETE /v1/sessions/:id Release a session
DELETE /v1/sessions Release all sessions

Context
GET /v1/sessions/:id/context Get full context
PUT /v1/sessions/:id/context Set full context
GET /v1/sessions/:id/context/cookies Get cookies
PUT /v1/sessions/:id/context/cookies Set cookies
DELETE /v1/sessions/:id/context Clear context

Profiles
GET /v1/profiles List profiles
POST /v1/profiles Create/save profile
GET /v1/profiles/:id Get profile
PUT /v1/profiles/:id Update profile
DELETE /v1/profiles/:id Delete profile

Files
POST /v1/sessions/:id/files Upload file
GET /v1/sessions/:id/files List files
GET /v1/sessions/:id/files/:path Download file
GET /v1/sessions/:id/files/archive Download all (zip)
DELETE /v1/sessions/:id/files/:path Delete file
DELETE /v1/sessions/:id/files Delete all files

Extensions
POST /v1/extensions Register extension
GET /v1/extensions List extensions
GET /v1/extensions/:id Get extension
DELETE /v1/extensions/:id Delete extension

Quick Actions
POST /v1/scrape Scrape a URL
POST /v1/screenshot Screenshot a URL
POST /v1/pdf Generate PDF from URL

Tunnel
POST /v1/tunnel/start Start tunnel
POST /v1/tunnel/stop Stop tunnel
GET /v1/tunnel/status Get tunnel status
```

<nav aria-label="breadcrumbs">
<ul className="breadcrumbs">
<li className="breadcrumbs__item">
<a className="breadcrumbs__link" target="_self" href={BRAND_URL}>
Home
</a>
</li>
<li className="breadcrumbs__item">
<a className="breadcrumbs__link" target="_self" href={`${BRAND_URL}/support/docs/`}>
Support
</a>
</li>
<li className="breadcrumbs__item">
<a className="breadcrumbs__link" target="_self" href="/support/docs/what-is-browser-cloud/">
Browser Cloud
</a>
</li>
<li className="breadcrumbs__item breadcrumbs__item--active">
<span className="breadcrumbs__link">
API Reference
</span>
</li>
</ul>
</nav>
214 changes: 214 additions & 0 deletions docs/browser-cloud-context.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,214 @@
---
id: browser-cloud-context
title: Reusing Context & Auth - TestMu AI Browser Cloud
hide_title: true
sidebar_label: Transfer Cookies & Storage
description: Extract and inject browser state across sessions to preserve login and user data in TestMu AI Browser Cloud.
keywords:
- browser cloud context
- session context
- browser authentication
- cookies persistence
- session state management
url: https://www.testmuai.com/support/docs/browser-cloud-context/
site_name: TestMu AI
slug: browser-cloud-context/
canonical: https://www.testmuai.com/support/docs/browser-cloud-context/
---

import BrandName, { BRAND_URL } from '@site/src/component/BrandName';

<script type="application/ld+json"
dangerouslySetInnerHTML={{ __html: JSON.stringify({
"@context": "https://schema.org",
"@type": "BreadcrumbList",
"itemListElement": [{
"@type": "ListItem",
"position": 1,
"name": "TestMu AI",
"item": BRAND_URL
},{
"@type": "ListItem",
"position": 2,
"name": "Support",
"item": `${BRAND_URL}/support/docs/`
},{
"@type": "ListItem",
"position": 3,
"name": "Browser Cloud",
"item": `${BRAND_URL}/support/docs/what-is-browser-cloud/`
},{
"@type": "ListItem",
"position": 4,
"name": "Context & Auth",
"item": `${BRAND_URL}/support/docs/browser-cloud-context/`
}]
})
}}
></script>

# Transfer Cookies and Storage Between Sessions

Extract and inject browser state - cookies, localStorage, and sessionStorage - across sessions to preserve login and user data without re-authenticating.


## Why You Need This

Your agent needs to stay logged in across sessions. Without a way to preserve
authentication state, every new session starts from scratch - your agent has to
repeat the login flow each time. That wastes time, risks triggering security
alerts from frequent logins, breaks on MFA prompts, and burns LLM tokens if
your agent uses AI to navigate login pages.

The Context Service solves this. It captures everything the browser remembers
about a user's session - login cookies, user preferences in localStorage,
shopping cart data in sessionStorage - and lets you inject that state into a
new session. Your agent logs in once, saves the context, and skips login
entirely in every future session.

```typescript
interface SessionContext {
cookies?: Cookie[];
localStorage?: Record<string, Record<string, string>>;
sessionStorage?: Record<string, Record<string, string>>;
}
```

## Before You Begin

You need an active session with a connected page before you can extract or
inject context. If you have not set that up yet, see
[Connect to a session](/support/docs/connect-to-session/).


## Framework Agnostic

The Context Service auto-detects whether you pass a Puppeteer `Page` or a
Playwright `Page`/`BrowserContext`. The same API works with both - you never
need to specify which adapter you're using.


## Extracting Context

Get all browser state from a page:

```typescript
const context = await client.context.getContext(page);

context.cookies; // Array of cookies
context.localStorage; // { "origin": { "key": "value" } }
context.sessionStorage; // { "origin": { "key": "value" } }
```

Or extract individual parts:

```typescript
const cookies = await client.context.getCookies(page);
const localStorage = await client.context.getLocalStorage(page);
const sessionStorage = await client.context.getSessionStorage(page);
```


## Injecting Context

Set browser state on a new page:

```typescript
await client.context.setContext(page, {
cookies: [
{ name: 'session_id', value: 'abc123', domain: '.example.com', path: '/' }
],
localStorage: {
'https://example.com': { theme: 'dark', lang: 'en' }
},
});
```

Or set individual parts:

```typescript
await client.context.setCookies(page, cookies);
await client.context.setLocalStorage(page, localStorageData);
await client.context.setSessionStorage(page, sessionStorageData);
```


## Clearing Context

```typescript
await client.context.clearContext(page); // Clear everything
await client.context.clearCookies(page); // Just cookies
await client.context.clearStorage(page); // localStorage + sessionStorage
```


## Example: Transfer Login Between Sessions

The most common use case - log in once, reuse the auth state:

```typescript
// Session 1: Log in and capture
const session1 = await client.sessions.create({ adapter: 'puppeteer', ... });
const browser1 = await client.puppeteer.connect(session1);
const page1 = (await browser1.pages())[0];

await page1.goto('https://app.example.com/login');
await page1.type('#email', 'user@example.com');
await page1.type('#password', 'password');
await page1.click('#login-button');
await page1.waitForNavigation();

const savedContext = await client.context.getContext(page1);
await browser1.close();
await client.sessions.release(session1.id);

// Session 2: Skip login entirely
const session2 = await client.sessions.create({ adapter: 'puppeteer', ... });
const browser2 = await client.puppeteer.connect(session2);
const page2 = (await browser2.pages())[0];

await client.context.setContext(page2, savedContext);
await page2.goto('https://app.example.com/dashboard');
// Already logged in!
```


## How It Works

- **Puppeteer:** Uses CDP `Network.getAllCookies` / `Network.setCookie` for cookies, and `page.evaluate()` for localStorage/sessionStorage
- **Playwright:** Uses `context.cookies()` / `context.addCookies()` for cookies, and `page.evaluate()` for storage
- Framework detection is automatic based on the page object's available methods


## Context vs Profiles

The Context Service transfers state **within a single script run** (in memory).
If you need state to persist **across separate script runs** (on disk), use the
[Profiles for persistent state](/support/docs/browser-cloud-profiles/) instead.



<nav aria-label="breadcrumbs">
<ul className="breadcrumbs">
<li className="breadcrumbs__item">
<a className="breadcrumbs__link" target="_self" href={BRAND_URL}>
Home
</a>
</li>
<li className="breadcrumbs__item">
<a className="breadcrumbs__link" target="_self" href={`${BRAND_URL}/support/docs/`}>
Support
</a>
</li>
<li className="breadcrumbs__item">
<a className="breadcrumbs__link" target="_self" href="/support/docs/what-is-browser-cloud/">
Browser Cloud
</a>
</li>
<li className="breadcrumbs__item breadcrumbs__item--active">
<span className="breadcrumbs__link">
Context & Auth
</span>
</li>
</ul>
</nav>
Loading