Skip to main content
public preview

This is a proposed contract. No concrete public host or key-issuer URL is published. Every command and response is illustrative.

Browser API contract guide

How to evaluate a browser API for AI agents.

An agent browser API needs two contracts. One controls compute lifecycle. The other controls browser execution. A provider may expose one or both.

Legba publishes a proposed REST lifecycle contract. It publishes no concrete public host or key-issuer URL. It publishes no concrete public browser endpoint.

The docs do not document Playwright protocol. They do not document CDP endpoints. They do not document Puppeteer WebSockets. No drop-in compatibility is currently claimed.

Written byLegbaReviewed byAakash HarishSecurity Research Contributor, LegbaReviewed 2026-09-01 · Updated 2026-09-01

The short version

The browser is easy. The contract is hard.

A browser API has two control planes.

Browser infrastructure looks simple from application code. An agent requests a browser. It performs browser work. Then the application releases resources.

That sequence hides two independent contracts. The lifecycle contract provisions and terminates compute. The browser contract carries automation commands. These contracts often use different protocols.

REST commonly controls lifecycle resources. WebSockets commonly carry browser commands. CDP is one browser-control protocol. Playwright also defines its own protocol.

A returned URL proves only documented access. It does not prove automation compatibility. The URL scheme and semantics matter. Authentication requirements also matter.

SourcesLegba API documentationLegba Instances APIPlaywright BrowserTypePuppeteer connect function

Understand Legba's current preview boundary.

Legba labels its API documentation a proposed public preview. No concrete public host or key-issuer URL is published. No concrete public callable endpoint is published.

The preview models REST instance creation, listing, and termination. Those shapes are illustrative, not a live integration contract.

Illustrative responses include an access_url. The preview does not define an automation protocol. That omission remains a real boundary.

Current docs never promise Playwright compatibility. They never publish a Playwright WebSocket. They never publish a CDP endpoint. They never publish a Puppeteer WebSocket.

  • Treat every endpoint as preview material.
  • Wait for a concrete assigned host.
  • Treat authentication as a proposed shape.
  • Read the instance lifecycle reference.
  • Do not infer browser protocols.
  • Recheck documentation before production adoption.

SourcesLegba API documentationLegba API quickstartLegba Instances APILegba API authentication

Map the complete browser lifecycle.

Most browser failures occur between obvious steps. Creation can succeed before readiness. Connection can succeed before navigation. Work can finish before cleanup.

A reliable contract defines every transition. Each transition needs success evidence. Each transition also needs failure evidence. Ownership must remain unambiguous.

The matrix separates lifecycle stages. It avoids vendor-specific endpoint assumptions. Apply it to every shortlisted provider. Record unknowns instead of guessing.

A lifecycle matrix for agent browser infrastructure.
FactorRequired contractSuccess evidenceFailure question
ProvisionCreate one isolated browser resource.Receive a stable resource identifier.How are rejected requests represented?
ReadinessKnow when browser work may begin.Observe an explicit ready state.How are startup delays surfaced?
ConnectObtain a documented browser connection contract.Complete one authenticated connection.Which protocol and versions apply?
ExecuteOpen pages and perform browser actions.Complete one representative agent task.Which timeouts govern browser commands?
ObserveCapture enough evidence for diagnosis.Review one failed task afterward.Which artifacts survive disconnection?
TerminateRelease browser and infrastructure resources.Confirm the resource no longer runs.What happens after client failure?

Evaluate the contract before the demo.

A polished demonstration proves one happy path. Production requires a stable written contract. That contract spans more than browser commands. It includes ownership, limits, and cleanup.

The matrix turns vague platform claims into questions. Every answer needs published evidence. A sales answer can guide testing. It should not replace documentation.

Use the matrix before implementation starts. Missing mandatory answers should block migration. Optional unknowns can remain tracked. Their uncertainty should remain priced.

A contract matrix for browser API evaluation.
FactorRequired answerWhy it mattersCurrent Legba status
Lifecycle interfaceCreate, inspect, and terminate resources.Agents need deterministic resource ownership.A draft REST lifecycle is documented.
Browser protocolName the exact automation protocol.Client libraries depend on protocol compatibility.No automation protocol is documented.
Connection authenticationDefine browser-channel authentication requirements.REST credentials may not authorize WebSockets.Only a proposed REST API-key shape is documented.
State boundaryDefine cookies, storage, and context isolation.State reuse changes security and reliability.No Playwright or Puppeteer state contract exists.
Artifact ownershipDefine logs, traces, screenshots, and downloads.Operators need evidence after failures.Review current canonical docs directly.
Cleanup behaviorDefine disconnect and termination separately.Client exit may leave resources running.Draft REST destruction is documented.
Error modelPublish statuses and structured error responses.Agents need deterministic recovery paths.A draft REST error structure is documented.

Keep interface layers separate.

A browser API may expose several interfaces. REST can manage infrastructure resources. Playwright protocol carries Playwright commands. CDP carries Chromium debugging commands.

Puppeteer commonly connects through a browser WebSocket. Its ConnectOptions define supported connection inputs. A browserWSEndpoint identifies the existing browser. Browser ownership remains a separate concern.

Playwright's native connection has version constraints. Client and server major versions must match. Minor versions must match too. Patch versions can differ safely.

Playwright CDP connections are Chromium-only. Official docs call them lower fidelity. Advanced Playwright features may work differently. Native Playwright protocol remains the preferred path.

Connection labels describe different technical contracts.
FactorTypical purposeCompatibility requirementKey limitation
REST lifecycleProvision and terminate infrastructure resources.Follow the provider's HTTP contract.It may expose no browser protocol.
Playwright protocolAttach Playwright to a browser server.Match client and server major-minor versions.A Playwright WebSocket is required.
CDPAttach through Chrome DevTools Protocol.Use a documented CDP endpoint.Playwright supports Chromium only.
Puppeteer connectionAttach Puppeteer to an existing browser.Pass valid ConnectOptions.Disconnection does not terminate browsers.

State deserves its own contract.

Browser state includes cookies and local storage. It may also include authentication headers. Reusing that state can reduce repeated logins. It also expands credential exposure.

Playwright contexts isolate independent browser sessions. Closing a context closes its pages. Puppeteer contexts also isolate cookies and storage. Their exact APIs still differ.

Provider-side state adds another layer. A provider may persist profiles across instances. It may scope them to organizations. Those behaviors need explicit documentation.

Legba proposes REST API-key authentication. No public key-issuer URL is documented. The browser-channel authentication contract remains undocumented. Never infer it from the preview.

  • Keep API keys server-side.
  • Separate REST and browser credentials.
  • Create one state boundary per task.
  • Document any reusable state explicitly.
  • Define deletion and expiration behavior.
  • Test cross-task state isolation.

SourcesLegba API authenticationPlaywright BrowserContextPuppeteer browser management

Design failure handling before scale.

Agents encounter partial failures constantly. Infrastructure can exist before browser readiness. Browser commands can timeout during active instances. Client processes can stop before cleanup.

A strong API distinguishes these failures. It exposes structured error codes. It records the affected resource identifier. It makes retry safety understandable.

Legba proposes structured REST errors and common HTTP statuses. These illustrate lifecycle recovery. Browser-protocol failures remain outside current documentation.

Observation must survive the failing client. Ask where logs and artifacts live. Ask when they become available. Ask how long they remain accessible.

Failure classes need different recovery actions.
FactorLikely ownerRecovery actionRequired evidence
Provisioning failureThe lifecycle API owns this stage.Retry only documented safe requests.Capture status and structured error details.
Readiness timeoutThe provider defines readiness semantics.Inspect resource status before replacement.Record timestamps and resource identifiers.
Connection failureThe browser protocol owns attachment.Validate endpoint, credentials, and versions.Capture the protocol-level failure.
Task failureThe application owns browser decisions.Collect artifacts before cleanup.Preserve browser and application logs.
Cleanup failureLifecycle ownership must remain explicit.Reconcile resources through the lifecycle API.Confirm final termination state.

Evaluate one complete contract.

Start with one representative agent task. Include normal authentication and state. Include normal artifacts and failure paths. Avoid a polished toy demonstration.

Write acceptance criteria before connecting anything. Name the required browser protocol. Name the required lifecycle operations. Name the required cleanup evidence.

Legba's preview docs support contract review today. They do not support a public self-serve integration. They do not support Playwright or Puppeteer compatibility claims. Wait for a concrete host and published protocol.

Review canonical documentation before implementation. Preview contracts can change. Keep version and host assumptions configurable internally. Do not publish guessed endpoints.

  1. 01

    Choose one representative task.

    Include login, navigation, output, and cleanup. Preserve normal failure conditions.

  2. 02

    Write the required contracts.

    Separate lifecycle, browser protocol, and state. Assign an owner each.

  3. 03

    Verify published compatibility.

    Require exact protocol and version documentation. Record every remaining unknown.

  4. 04

    Exercise partial failures.

    Interrupt connection and task execution. Confirm cleanup and diagnostic evidence.

  5. 05

    Recheck preview documentation.

    Confirm a concrete host and contract exist. Update assumptions before implementation.

SourcesLegba API documentationLegba API quickstartLegba Instances APILegba API authenticationLegba API errors

FAQs.

What is a browser API?
It exposes programmable browser infrastructure. Lifecycle and browser control may differ. Always identify both contracts.
Does Legba document a browser API?
Legba publishes a proposed REST lifecycle. It publishes no concrete public host or automation protocol.
Does Legba support Playwright today?
Current docs make no Playwright compatibility claim. No Playwright WebSocket is documented. Do not infer support.
Does Legba expose CDP today?
Current docs publish no CDP endpoint. The access_url does not prove CDP. Wait for explicit documentation.
Does Legba support Puppeteer today?
Current docs make no Puppeteer compatibility claim. No Puppeteer WebSocket is documented. Do not infer support.
Why separate lifecycle and connection?
They control different resources. Disconnection may leave infrastructure running. Separate ownership prevents leaked capacity.
How should teams evaluate providers?
Use one complete production-shaped task. Test connection, state, failures, artifacts, and cleanup. Require published protocol evidence.

References

  1. 01
  2. 02
  3. 03
  4. 04
  5. 05
  6. 06
    Playwright BrowserTypeMicrosoft Playwright
  7. 07
    Playwright BrowserContextMicrosoft Playwright
  8. 08
  9. 09
    Puppeteer ConnectOptionsGoogle Puppeteer
  10. 10

Keep exploring