Endpoint
Authentication
This endpoint requires theCAMOFOX_API_KEY environment variable.
Bearer token matching the
CAMOFOX_API_KEY environment variable:CAMOFOX_API_KEY is not set, all requests to this endpoint return 403 Forbidden.
Path parameters
Unique user identifier. Cookies are scoped to this user’s browser session. All tabs created with this
userId will share these cookies.Request body
Array of Playwright-format cookie objects. Maximum 500 cookies per request.
Response
true if cookies were imported successfullyUser ID that received the cookies (normalized to string)
Number of cookies imported
Error response
Human-readable error message
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_KEYis 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:Validation and sanitization
Required fields
Each cookie object must include:name(non-empty string)value(string)domain(non-empty string)
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
Limits
- Maximum 500 cookies per request - returns
400if 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
Basic cookie import
Multiple cookies
Error: Missing required fields
Error: Authentication disabled
Error: Invalid Bearer token
Error: Too many cookies
Workflow
- Export cookies from your browser using a browser extension (e.g., “cookies.txt” for Chrome/Firefox)
- Parse Netscape format into Playwright cookie objects (if using OpenClaw, the plugin does this automatically)
- Send cookies to the server with the Bearer token
- Create tabs with the same
userId- they will inherit the injected cookies - 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
userIdshare 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