Skip to main content
Inject cookies into a user’s browser session to enable authenticated browsing without interactive login. This endpoint accepts Playwright-format cookie objects and is disabled by default for security.

Endpoint

Authentication

This endpoint requires the CAMOFOX_API_KEY environment variable.
string
required
Bearer token matching the CAMOFOX_API_KEY environment variable:
If CAMOFOX_API_KEY is not set, all requests to this endpoint return 403 Forbidden.

Path parameters

string
required
Unique user identifier. Cookies are scoped to this user’s browser session. All tabs created with this userId will share these cookies.

Request body

object[]
required
Array of Playwright-format cookie objects. Maximum 500 cookies per request.

Response

boolean
true if cookies were imported successfully
string
User ID that received the cookies (normalized to string)
number
Number of cookies imported

Error response

string
Human-readable error message
object[]
When cookie validation fails, this array contains details about invalid cookies:

Security

Why authentication is required

Cookie injection moves the browser from anonymous browsing to authenticated browsing. This endpoint:
  • Is disabled by default (returns 403 if CAMOFOX_API_KEY is not set)
  • Requires a secret Bearer token to prevent unauthorized cookie injection
  • Uses timing-safe comparison to prevent timing attacks on the API key

Setup

1. Generate a secret API key:
2. Set the environment variable before starting the server:
3. Send the key in the Authorization header:

Validation and sanitization

Required fields

Each cookie object must include:
  • name (non-empty string)
  • value (string)
  • domain (non-empty string)
Requests with invalid cookies return 400 Bad Request with details in the invalid array.

Field allowlist

Only these Playwright cookie fields are accepted:
  • name, value, domain, path, expires, httpOnly, secure, sameSite
All other fields are stripped during sanitization.

Limits

  • Maximum 500 cookies per request - returns 400 if exceeded
  • Maximum 512KB request body - enforced by Express
  • No domain filtering - cookies are injected as-is (ensure your cookie domain matches the sites you’ll browse)

Examples

Response:

Multiple cookies

Response:

Error: Missing required fields

Response (400 Bad Request):

Error: Authentication disabled

Error: Invalid Bearer token

Error: Too many cookies

Workflow

  1. Export cookies from your browser using a browser extension (e.g., “cookies.txt” for Chrome/Firefox)
  2. Parse Netscape format into Playwright cookie objects (if using OpenClaw, the plugin does this automatically)
  3. Send cookies to the server with the Bearer token
  4. Create tabs with the same userId - they will inherit the injected cookies
  5. Navigate to authenticated pages - the browser session is now logged in

Use cases

  • Skip interactive login flows on sites like LinkedIn, Amazon, Twitter
  • Preserve authentication state across sessions
  • Automate tasks that require login without exposing credentials
  • Test authenticated workflows with AI agents

Session lifecycle

Cookies are scoped to the user’s browser session:
  • All tabs created with userId share the same cookies
  • Sessions expire after 30 minutes of inactivity (configurable via SESSION_TIMEOUT_MS)
  • Cookies persist until session expires or is explicitly closed via DELETE /sessions/:userId
  • New cookie imports merge with existing cookies (duplicate names are overwritten)

Limitations

  • Cookies are stored in-memory (not persisted to disk)
  • No built-in Netscape format parser - convert to Playwright format first
  • Domain filtering is not enforced - ensure cookie domains match your target sites
  • The endpoint does not validate cookie expiration dates

See also