Skip to main content
Use link-cli mpp pay to request a browser session, approve the payment in Link, and connect with Stagehand, Playwright, or Puppeteer. You don’t need a Browserbase account or API key. Install Link CLI with Node.js:
If Link isn’t connected, start the login flow:
Open the verification URL, sign in, and approve the connection. Wait for authentication to finish before requesting a payment. Add a payment method in Link if needed. If an existing connection doesn’t include the payment_methods.agentic scope, use link-cli auth upgrade with the same options to add it.

Inspect the payment challenge

Make an unauthenticated request to see the price before paying:
cURL
Browserbase returns 402 Payment Required with payment challenges in the WWW-Authenticate header. Link CLI uses the challenge with method="stripe", which specifies the merchant, amount, and currency. This request doesn’t create a session or make a payment. This example requests 250 minutes for 0.50 USD, the minimum purchase. Increase estimatedMinutes to buy more time. Run link-cli mpp pay with the same session request:
The CLI reads the amount and currency from the payment challenge and creates the spend request for you. The --context explains the purchase in Link’s approval screen and must be at least 100 characters. Open the approval URL returned by the CLI and review the amount before approving. Follow the CLI’s continuation instructions to finish the request. After approval, Link CLI retrieves a one-time Shared Payment Token and sends it to Browserbase in an MPP payment credential. When calling the CLI from an agent, invoke the returned _next.pay_argv command and argument array directly. Set its JSON header to Content-Type: application/json, preserving capitalization, and keep the original --approved-challenge, method, and body. See Stripe’s Link CLI guide for details. After a successful payment, Browserbase returns session details including:
Keep the sessionId for status checks and the connectUrl for browser access. Treat the connection URL as a credential: anyone with it can connect while the session is active.

Connect to the session

Set BROWSERBASE_CONNECT_URL in your environment to the connectUrl from the response. Choose a browser library, install it, and save its example as browser.mjs.
Stagehand runs in your Node.js process and connects to the paid browser session over CDP.
Node.js
Run the example:

Expected output

The script prints Example Domain.

Manage the session

Set SESSION_ID to the returned sessionId. You can check the remaining browser time without another payment:
cURL

Cleanup

When you’re finished, terminate the session:
cURL

Further reading

See the Link CLI documentation for approval and Shared Payment Tokens.

MPP overview

Review pricing, prerequisites, and how the payment flow works.

x402 quickstart

Create browser sessions using x402 payments.