For AI agents: a documentation index is available at /llms.txt
Skip to main content

Log In and Reuse Sessions

Log in once and reuse that authenticated state across many browser sessions without re-entering credentials.

Prerequisites

Steps

Authenticated sessions work in two phases: first you save the login state into a named profile, then you reuse that profile across future sessions.

Use the REST API to manage browser sessions without a persistent connection.

View Full Code on GitHub

1. Create a profile session

Start a profile-creation session. The response contains a WebSocket URL to connect a CDP client for the login flow:

curl -X POST \
"https://production-sfo.browserless.io/profile?token=YOUR_API_TOKEN_HERE" \
-H "Content-Type: application/json" \
-d '{ "name": "my-profile" }'

The response includes a connect WebSocket URL and a stop URL:

{
"id": "<session-id>",
"name": "my-profile",
"connect": "wss://production-sfo.browserless.io/session/connect/<id>?token=...",
"stop": "https://production-sfo.browserless.io/session/<id>?token=..."
}

2. Log in and save the profile

Use a CDP client (Puppeteer or Playwright) to connect to the connect URL, complete the login, and call Browserless.saveProfile. See the Puppeteer tab for a complete code example.

3. Use the saved profile

Once saved, append ?profile=my-profile to any Browserless request to start with the authenticated state pre-loaded:

curl -X POST \
"https://production-sfo.browserless.io/screenshot?token=YOUR_API_TOKEN_HERE&profile=my-profile" \
-H "Content-Type: application/json" \
-d '{ "url": "https://app.example.com/dashboard" }' \
--output dashboard.png

Next steps