Every API here is available over the APIs.io API and to AI agents over MCP.
openapi: 3.2.0
info:
title: Browser Use Public API v4 Sessions API
summary: Browser Use agent runs API (v4)
version: 4.0.0
servers:
- url: https://api.browser-use.com/api/v4
description: Production server
tags:
- name: Sessions
paths:
/sessions:
get:
tags:
- Sessions
summary: List Sessions
description: 'List the project''s V4 sessions — one row per session (its most recent
run), most-recent first.
A session is a conversation: follow-up runs reuse the same
public_session_id, so GET /api/v4/runs would list one row per RUN. This
collapses to one row per SESSION directly in Postgres with DISTINCT ON, so a
chatty session with 100 runs is still a single row (no scan amplification),
and selects only the slim columns the session list needs — never the heavy
per-run text/token/cost fields.
Keyset-paginated on the latest run''s (created_at, id): pass `next_cursor`
back as `cursor` to page. Offset/COUNT was dropped — it doesn''t scale on
projects with many sessions.'
operationId: list_sessions_sessions_get
security:
- APIKeyHeader: []
parameters:
- name: limit
in: query
required: false
schema:
type: integer
maximum: 100
minimum: 1
description: Max sessions per page (max 100).
default: 20
title: Limit
description: Max sessions per page (max 100).
- name: cursor
in: query
required: false
schema:
anyOf:
- type: string
- type: 'null'
description: Keyset cursor from a prior response.
title: Cursor
description: Keyset cursor from a prior response.
responses:
'200':
description: Successful Response
content:
application/json:
schema:
$ref: '#/components/schemas/SessionListResponse'
'403':
description: Zero Data Retention is enabled on the project (V4 unsupported).
'400':
description: Malformed pagination cursor.
'422':
description: Validation Error
content:
application/json:
schema:
$ref: '#/components/schemas/HTTPValidationError'
/sessions/{session_id}/purge:
post:
tags:
- Sessions
summary: Purge Session
description: 'Purge V4 session data; return 202 while active work or uploads defer deletion.
Redacts DB records and deletes S3 objects (bcode state, workspace files,
recordings, downloads, staging uploads) for every run in the session. Same
cleanup the ZDR cron performs, but on-demand; outstanding upload grants defer physical deletion. V4
analog of the V2 POST /sessions/{id}/purge. Surfaces shared with a still-live
sibling run are deferred by the same guards the cron uses.'
operationId: purge_session_sessions__session_id__purge_post
security:
- APIKeyHeader: []
parameters:
- name: session_id
in: path
required: true
schema:
type: string
format: uuid
title: Session Id
responses:
'204':
description: Successful Response
'202':
description: Purge pending active work or outstanding uploads.
'403':
description: Project is not ZDR-enabled.
'404':
description: Session not found.
'422':
description: Validation Error
content:
application/json:
schema:
$ref: '#/components/schemas/HTTPValidationError'
/sessions/{session_id}:
get:
tags:
- Sessions
summary: Get Session
description: 'Session detail — the same slim shape as one GET /sessions row (its
latest run). Doubles as the busy/idle poll for a conversation (POLL rate
bucket): slim columns only, indexed public_session_id lookup, never the
heavy result/token fields.'
operationId: get_session_sessions__session_id__get
security:
- APIKeyHeader: []
parameters:
- name: session_id
in: path
required: true
schema:
type: string
format: uuid
title: Session Id
responses:
'200':
description: Successful Response
content:
application/json:
schema:
$ref: '#/components/schemas/SessionInfo'
'403':
description: Zero Data Retention is enabled on the project (V4 unsupported).
'404':
description: Run, session, workspace, or profile not found.
'422':
description: Validation Error
content:
application/json:
schema:
$ref: '#/components/schemas/HTTPValidationError'
patch:
tags:
- Sessions
summary: Update Session
description: 'Rename a session.
`session_title` is denormalized onto every run in the session (the session
list reads the latest run), so a rename writes them all in one UPDATE. Null
clears the name and the UI falls back to the opening task — it does NOT
re-run title generation, which only fills rows where the title IS NULL and
so would silently overwrite the clear.'
operationId: update_session_sessions__session_id__patch
security:
- APIKeyHeader: []
parameters:
- name: session_id
in: path
required: true
schema:
type: string
format: uuid
title: Session Id
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/SessionUpdateRequest'
responses:
'200':
description: Successful Response
content:
application/json:
schema:
$ref: '#/components/schemas/SessionInfo'
'403':
description: Zero Data Retention is enabled on the project (V4 unsupported).
'404':
description: Run, session, workspace, or profile not found.
'422':
description: Validation Error
content:
application/json:
schema:
$ref: '#/components/schemas/HTTPValidationError'
delete:
tags:
- Sessions
summary: Delete Session
description: 'Delete a session: it disappears from the session lists and can no longer
be opened or continued.
Soft delete (mirrors V2''s `is_archived`): the runs, events and usage records
stay in place so billing and analytics keep reconciling, and ZDR purge is the
only thing that ever destroys V4 content. Idempotent — deleting twice is a
no-op 204.
An in-flight run is cancelled first, and pending queued messages are
cancelled too; otherwise the drain would dispatch a follow-up run whose
`session_archived_at` is NULL and resurrect the session. Cancel is forwarded
to CP before anything is written (and outside the queue lock, per the
enqueue path''s ordering), so a CP failure (502) leaves the session visible
rather than hiding a run that is still burning credits.'
operationId: delete_session_sessions__session_id__delete
security:
- APIKeyHeader: []
parameters:
- name: session_id
in: path
required: true
schema:
type: string
format: uuid
title: Session Id
responses:
'204':
description: Successful Response
'403':
description: Zero Data Retention is enabled on the project (V4 unsupported).
'404':
description: Run, session, workspace, or profile not found.
'502':
description: The request could not be forwarded to the control plane.
'503':
description: The run is finishing; retry the cancel after Retry-After seconds.
'422':
description: Validation Error
content:
application/json:
schema:
$ref: '#/components/schemas/HTTPValidationError'
/sessions/{session_id}/cost-cap:
patch:
tags:
- Sessions
summary: Update Session Cost Cap
description: Update the active run cap without starting another run.
operationId: update_session_cost_cap_sessions__session_id__cost_cap_patch
security:
- APIKeyHeader: []
parameters:
- name: session_id
in: path
required: true
schema:
type: string
format: uuid
title: Session Id
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/SessionCostCapRequest'
responses:
'200':
description: Successful Response
content:
application/json:
schema:
$ref: '#/components/schemas/SessionCostCapResponse'
'403':
description: Zero Data Retention is enabled on the project (V4 unsupported).
'404':
description: Run, session, workspace, or profile not found.
'422':
description: Validation Error
content:
application/json:
schema:
$ref: '#/components/schemas/HTTPValidationError'
/sessions/{session_id}/cost:
get:
tags:
- Sessions
summary: Get Session Cost
description: 'Everything this session has cost so far, split by source.
A run''s `total_cost_usd` is its LLM (and web-search) charge only. Browser
time and proxy bandwidth are metered against the session''s browser, which
outlives any one run — so this is the endpoint for the session''s full cost.
These are recorded usage costs, not an invoice total: promotional waivers
and credits are applied downstream in billing, so a session run under a
promotion can report cost here that was never charged.
Costs keep moving after a run reports `finished`: LLM calls settle up to
about 90 seconds later, and the browser accrues time and proxy traffic
until it stops.'
operationId: get_session_cost_sessions__session_id__cost_get
security:
- APIKeyHeader: []
parameters:
- name: session_id
in: path
required: true
schema:
type: string
format: uuid
title: Session Id
responses:
'200':
description: Successful Response
content:
application/json:
schema:
$ref: '#/components/schemas/SessionCostResponse'
'403':
description: Zero Data Retention is enabled on the project (V4 unsupported).
'404':
description: Run, session, workspace, or profile not found.
'422':
description: Validation Error
content:
application/json:
schema:
$ref: '#/components/schemas/HTTPValidationError'
/sessions/{session_id}/queue:
post:
tags:
- Sessions
summary: Queue Session Message
description: 'Send a message to a session. If the session is busy it waits on the queue
and runs as the next turn; if idle it drains immediately.
`interrupt=true` cancels the session''s active run so this message takes effect
now instead of waiting for the current turn (no-op when the session is idle).'
operationId: queue_session_message_sessions__session_id__queue_post
security:
- APIKeyHeader: []
parameters:
- name: session_id
in: path
required: true
schema:
type: string
format: uuid
title: Session Id
- name: X-V4-Queue-Deduplicate
in: header
required: false
schema:
anyOf:
- type: string
- type: 'null'
title: X-V4-Queue-Deduplicate
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/QueueMessageRequest'
responses:
'200':
description: Successful Response
content:
application/json:
schema:
$ref: '#/components/schemas/QueuedMessage'
'402':
description: The project has no credits available, or the authenticating API key has reached its recorded monthly total-spend soft stop.
content:
application/json:
schema:
$ref: '#/components/schemas/APIKeySpendLimitError'
'403':
description: Zero Data Retention is enabled on the project (V4 unsupported).
'404':
description: Run, session, workspace, or profile not found.
'429':
description: The session message queue is full.
'422':
description: Validation Error
content:
application/json:
schema:
$ref: '#/components/schemas/HTTPValidationError'
get:
tags:
- Sessions
summary: List Session Queue
description: 'List open messages, recently delivered queued messages, and steering cutoffs.
Includes live dispatch claims so clients can restore an accepted queued
message after a refresh without briefly losing its waiting state.
Consumed QUEUE rows are returned too, capped at the most recent
_DELIVERED_QUEUE_HISTORY, plus up to _AGENCY_DELIVERED_QUEUE_HISTORY compact
Agency choice and generation receipts so inbox state survives refresh. A message absorbed mid-run is announced by a
`queued_input_injected` event carrying only its input id, so the chat has no
other source for the text to render. The cap bounds this response because
clients poll it while a run is active; a session with more delivered
follow-ups than the cap renders its oldest injected bubbles without text.
The latest consumed interrupt bridges the primary-write/read-replica gap
before its replacement run appears; clients discard it once that run is
visible. Compact per-source cutoffs preserve every historical interrupted
transcript boundary without returning every historical steering message and
its attachments.'
operationId: list_session_queue_sessions__session_id__queue_get
security:
- APIKeyHeader: []
parameters:
- name: session_id
in: path
required: true
schema:
type: string
format: uuid
title: Session Id
responses:
'200':
description: Successful Response
content:
application/json:
schema:
$ref: '#/components/schemas/QueueListResponse'
'403':
description: Zero Data Retention is enabled on the project (V4 unsupported).
'404':
description: Run, session, workspace, or profile not found.
'422':
description: Validation Error
content:
application/json:
schema:
$ref: '#/components/schemas/HTTPValidationError'
/sessions/{session_id}/queue/{message_id}:
get:
tags:
- Sessions
summary: Get Session Queue Message
description: Read one queued message including terminal handoff states.
operationId: get_session_queue_message_sessions__session_id__queue__message_id__get
security:
- APIKeyHeader: []
parameters:
- name: session_id
in: path
required: true
schema:
type: string
format: uuid
title: Session Id
- name: message_id
in: path
required: true
schema:
type: integer
title: Message Id
responses:
'200':
description: Successful Response
content:
application/json:
schema:
$ref: '#/components/schemas/QueuedMessage'
'403':
description: Zero Data Retention is enabled on the project (V4 unsupported).
'404':
description: Run, session, workspace, or profile not found.
'422':
description: Validation Error
content:
application/json:
schema:
$ref: '#/components/schemas/HTTPValidationError'
delete:
tags:
- Sessions
summary: Cancel Queued Message
description: Remove a still-pending queued message; 409 once the drain has claimed it.
operationId: cancel_queued_message_sessions__session_id__queue__message_id__delete
security:
- APIKeyHeader: []
parameters:
- name: session_id
in: path
required: true
schema:
type: string
format: uuid
title: Session Id
- name: message_id
in: path
required: true
schema:
type: integer
title: Message Id
responses:
'200':
description: Successful Response
content:
application/json:
schema:
$ref: '#/components/schemas/QueuedMessage'
'403':
description: Zero Data Retention is enabled on the project (V4 unsupported).
'404':
description: Run, session, workspace, or profile not found.
'409':
description: The message is no longer pending and cannot be cancelled.
'422':
description: Validation Error
content:
application/json:
schema:
$ref: '#/components/schemas/HTTPValidationError'
/sessions/{session_id}/share:
get:
tags:
- Sessions
summary: Get Session Share
description: The session's share link (active or not); null if never shared.
operationId: get_session_share_sessions__session_id__share_get
security:
- APIKeyHeader: []
parameters:
- name: session_id
in: path
required: true
schema:
type: string
format: uuid
title: Session Id
responses:
'200':
description: Successful Response
content:
application/json:
schema:
anyOf:
- $ref: '#/components/schemas/SessionShareInfo'
- type: 'null'
title: Response Get Session Share Sessions Session Id Share Get
'404':
description: Run, session, workspace, or profile not found.
'422':
description: Validation Error
content:
application/json:
schema:
$ref: '#/components/schemas/HTTPValidationError'
post:
tags:
- Sessions
summary: Create Session Share
description: 'Enable sharing: reactivates the session''s existing share (stable token,
so a link that was toggled off keeps working when re-enabled) or creates
one on first use.'
operationId: create_session_share_sessions__session_id__share_post
security:
- APIKeyHeader: []
parameters:
- name: session_id
in: path
required: true
schema:
type: string
format: uuid
title: Session Id
responses:
'200':
description: Successful Response
content:
application/json:
schema:
$ref: '#/components/schemas/SessionShareInfo'
'403':
description: Zero Data Retention is enabled on the project (V4 unsupported).
'404':
description: Run, session, workspace, or profile not found.
'422':
description: Validation Error
content:
application/json:
schema:
$ref: '#/components/schemas/HTTPValidationError'
put:
tags:
- Sessions
summary: Update Session Share
description: Toggle the session's share link on/off.
operationId: update_session_share_sessions__session_id__share_put
security:
- APIKeyHeader: []
parameters:
- name: session_id
in: path
required: true
schema:
type: string
format: uuid
title: Session Id
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/SessionShareUpdateRequest'
responses:
'200':
description: Successful Response
content:
application/json:
schema:
$ref: '#/components/schemas/SessionShareInfo'
'403':
description: Zero Data Retention is enabled on the project (V4 unsupported).
'404':
description: Run, session, workspace, or profile not found.
'422':
description: Validation Error
content:
application/json:
schema:
$ref: '#/components/schemas/HTTPValidationError'
components:
schemas:
QueuedMessage:
properties:
id:
type: integer
title: Id
sessionId:
type: string
format: uuid
title: Sessionid
runId:
anyOf:
- type: string
format: uuid
- type: 'null'
title: Runid
mode:
type: string
enum:
- queue
- interrupt
title: Mode
status:
type: string
enum:
- pending
- dispatching
- consumed
- cancelled
- superseded
- failed
title: Status
text:
type: string
title: Text
attachedFileIds:
anyOf:
- items:
type: string
format: uuid
type: array
- type: 'null'
title: Attachedfileids
createdAt:
type: string
format: date-time
title: Createdat
type: object
required:
- id
- sessionId
- runId
- mode
- status
- text
- createdAt
title: QueuedMessage
description: One message on a session's queue (a v4_session_input row).
SessionInfo:
properties:
sessionId:
type: string
format: uuid
title: Sessionid
workspaceId:
anyOf:
- type: string
format: uuid
- type: 'null'
title: Workspaceid
latestRunId:
type: string
format: uuid
title: Latestrunid
task:
type: string
title: Task
title:
anyOf:
- type: string
- type: 'null'
title: Title
status:
type: string
enum:
- queued
- dispatching
- running
- completed
- failed
- cancelled
title: Status
createdAt:
type: string
format: date-time
title: Createdat
updatedAt:
type: string
format: date-time
title: Updatedat
type: object
required:
- sessionId
- workspaceId
- latestRunId
- task
- title
- status
- createdAt
- updatedAt
title: SessionInfo
description: 'Lightweight metadata for one V4 session (its most recent run).
Deliberately slim — just what a session list needs (open the conversation,
show a label + status + time). The heavy per-run fields (result, error,
token/cost totals) live on RunSummary and aren''t repeated here.'
SessionCostCapResponse:
properties:
sessionId:
type: string
format: uuid
title: Sessionid
maxCostUsd:
type: string
title: Maxcostusd
type: object
required:
- sessionId
- maxCostUsd
title: SessionCostCapResponse
SessionShareUpdateRequest:
properties:
isActive:
type: boolean
title: Isactive
type: object
required:
- isActive
title: SessionShareUpdateRequest
APIKeySpendLimitError:
properties:
detail:
anyOf:
- type: string
- $ref: '#/components/schemas/APIKeySpendLimitDetail'
title: Detail
type: object
required:
- detail
title: APIKeySpendLimitError
description: FastAPI wraps endpoint errors in a top-level ``detail`` field.
SessionCostResponse:
properties:
sessionId:
type: string
format: uuid
title: Sessionid
numRuns:
type: integer
title: Numruns
llmCostUsd:
type: string
title: Llmcostusd
searchCostUsd:
type: string
title: Searchcostusd
browserCostUsd:
type: string
title: Browsercostusd
proxyCostUsd:
type: string
title: Proxycostusd
proxyUsedMb:
type: string
title: Proxyusedmb
totalCostUsd:
type: string
title: Totalcostusd
type: object
required:
- sessionId
- numRuns
- llmCostUsd
- searchCostUsd
- browserCostUsd
- proxyCostUsd
- proxyUsedMb
- totalCostUsd
title: SessionCostResponse
description: 'Everything a session cost, split by what it was spent on.
Recorded usage, not an invoice total — promotional waivers and credits are
applied downstream in billing.
Browser time and proxy bandwidth are metered against the session''s browser,
which outlives any single run, so they have no per-run number — only
`RunSummary.total_cost_usd`, the LLM (and web search) charge, does.
All amounts are fixed-6-decimal strings for the same reason as
`RunSummary.total_cost_usd`: JS clients lose precision on float.'
QueueListResponse:
properties:
queue:
items:
$ref: '#/components/schemas/QueuedMessage'
type: array
title: Queue
steeringCutoffs:
items:
$ref: '#/components/schemas/SteeringCutoff'
type: array
title: Steeringcutoffs
type: object
required:
- queue
title: QueueListResponse
SessionCostCapRequest:
properties:
maxCostUsd:
anyOf:
- type: number
exclusiveMinimum: 0.0
- type: string
pattern: ^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$
title: Maxcostusd
additionalProperties: false
type: object
required:
- maxCostUsd
title: SessionCostCapRequest
description: Set the maximum spend for the active run in a session.
APIKeySpendLimitDetail:
properties:
code:
type: string
title: Code
default: api_key_monthly_spend_limit_reached
message:
type: string
title: Message
cap:
type: number
title: Cap
spent:
type: number
title: Spent
type: object
required:
- message
- cap
- spent
title: APIKeySpendLimitDetail
description: Machine-readable 402 detail shared by run and browser creation.
SessionShareInfo:
properties:
id:
type: string
format: uuid
title: Id
shareToken:
type: string
title: Sharetoken
sessionId:
type: string
format: uuid
title: Sessionid
isActive:
type: boolean
title: Isactive
viewCount:
type: integer
title: Viewcount
createdAt:
type: string
format: date-time
title: Createdat
shareUrl:
type: string
title: Shareurl
type: object
required:
- id
- shareToken
- sessionId
- isActive
- viewCount
- createdAt
- shareUrl
title: SessionShareInfo
description: A session's public share-link state (share modal reads/writes this).
QueueMessageRequest:
properties:
text:
type: string
minLength: 1
title: Text
interrupt:
type: boolean
title: Interrupt
default: false
attachedFileIds:
anyOf:
- items:
type: string
format: uuid
type: array
maxItems: 20
- type: 'null'
title: Attachedfileids
additionalProperties: false
type: object
required:
- text
title: QueueMessageRequest
description: 'Send a message to a session. If the session is busy the message waits on
the queue and runs as the next turn; if idle it runs immediately.
Set `interrupt` to make it take effect now: the session''s active run is
cancelled and this message drains straight after. Interrupt is a no-op when
the session is already idle, and BEST-EFFORT when busy — if the cancel can''t
be delivered, the message stays queued and runs after the current turn.'
ValidationError:
properties:
loc:
items:
anyOf:
- type: string
- type: integer
type: array
title: Location
msg:
type: string
title: Message
type:
type: string
title: Error Type
type: object
required:
- loc
- msg
- type
title: ValidationError
HTTPValidationError:
properties:
detail:
items:
$ref: '#/components/schemas/ValidationError'
type: array
title: Detail
type: object
title: HTTPValidationError
SessionUpdateRequest:
properties:
title:
anyOf:
- type: string
maxLength: 255
- type: 'null'
title: Title
type: object
title: SessionUpdateRequest
description: 'Rename a session. Null clears the user-set name, so the UI falls back to
the session''s opening task.'
SteeringCutoff:
properties:
sourceRunId:
type: string
format: uuid
title: Sourcerunid
createdAt:
type: string
format: date-time
title: Createdat
type: object
required:
- sourceRunId
- createdAt
title: SteeringCutoff
description: 'Earliest accepted steer for one interrupted source run.
The queue endpoint returns these compact boundaries separately from message
rows so a remount can keep every interrupted transcript frozen without
re-sending the full historical steering-message payload.'
SessionListResponse:
properties:
sessions:
items:
$ref: '#/components/schemas/SessionInfo'
type: array
title: Sessions
nextCursor:
anyOf:
- type: string
- type: 'null'
title: Nextcursor
hasMore:
type: boolean
title: Hasmore
default: false
type: object
required:
- sessions
title: SessionListResponse
description: 'One entry per session (the session''s most recent run), most-recent first.
A V4 session is a conversation: every follow-up run reuses the same
public_session_id. GET /api/v4/runs returns one row per RUN, so callers that
want a list of distinct *sessions* (e.g. the recent-sessions panel) should
use this instead of de-duplicating runs client-side.'
securitySchemes:
APIKeyHeader:
type: apiKey
in: header
name: X-Browser-Use-API-Key