> ## Documentation Index
> Fetch the complete documentation index at: https://docs.browserbase.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Managing files

> How Browserbase Agents work with files, and retrieve downloads.

Agents work with real files, not just page content. Each run gets a sandboxed file workspace where the Agent can read and write files, process documents it downloads, and produce output. This is what lets an Agent fetch a PDF, read a spreadsheet, or pull a report rather than only scraping text from a page.

For the broader tool set, see [How it works](https://docs.browserbase.com/platform/agents/how-it-works.md). For the API that returns files, see the [Downloads API](https://docs.browserbase.com/platform/browser/files/downloads.md).

## What the Agent can do with files

* **Read and write files** in its sandboxed workspace during a run.
* **Process downloaded content** such as PDFs and spreadsheets.
* **Produce output files** like CSVs or spreadsheets from data it gathers.
* **Extract small inline tables** directly from a page when the data is compact.

The Agent decides when files are the fastest path. A run that needs to compare figures across a downloaded report, for example, may download the file and process it rather than reading the page.

## Retrieving files the Agent downloads

When the Agent downloads a file during a run, Browserbase stores it against the run's browser session. Retrieve it with the [Downloads API](https://docs.browserbase.com/platform/browser/files/downloads.md) using the `sessionId` from the run.

First, get the run's `sessionId` from [Get a run](https://docs.browserbase.com/reference/api/get-a-run.md). Then list the downloads for that session with [List downloads](https://docs.browserbase.com/reference/api/list-downloads.md):

> [tab] Node.js
>
> ```typescript Node.js theme={null}
> const response = await fetch(
>   `https://api.browserbase.com/v1/downloads?sessionId=${sessionId}`,
>   {
>     headers: { "x-bb-api-key": process.env.BROWSERBASE_API_KEY! },
>   },
> );
>
> const { downloads } = await response.json();
> console.log(downloads);
> ```

> [tab] Python
>
> ```python Python theme={null}
> import os
> import requests
>
> response = requests.get(
>     "https://api.browserbase.com/v1/downloads",
>     headers={
>         "x-bb-api-key": os.environ["BROWSERBASE_API_KEY"],
>     },
>     params={
>         "sessionId": session_id,
>     },
> )
>
> downloads = response.json()["downloads"]
> print(downloads)
> ```

> [tab] cURL
>
> ```bash cURL theme={null}
> curl "https://api.browserbase.com/v1/downloads?sessionId=$SESSION_ID" \
>   --header "x-bb-api-key: $BROWSERBASE_API_KEY"
> ```

Fetch a single file by ID with [Get a download](https://docs.browserbase.com/reference/api/get-a-download.md). You can also filter the list by `filename`, `mimeType`, or size. See the [Downloads](https://docs.browserbase.com/platform/browser/files/downloads.md) guide for the full workflow.

## Use cases

Files unlock the document-heavy tasks that scripts struggle with:

* **Document fetching**: SOC2 reports, authorization forms, and transaction documents from vendor and provider sites.
* **Government and real estate records**: tax documents and property records that download as PDFs.
* **Data export**: gather records across pages, then write a single spreadsheet as output.

## Limitations

The file workflow is still growing. Plan around these limits:

> [!WARNING]
>
> * **You can't upload files to an Agent yet.** The Agent works with files it creates or downloads during the run.
> * **Large, paginated tabular data can't be reliably exported inline.** Trigger a download and retrieve the file through the [Downloads API](https://docs.browserbase.com/platform/browser/files/downloads.md) instead of asking the Agent to extract a large table.
> * **Large files (over 1 MB) should flow through downloads,** not inline extraction. The Agent can extract small `<table>` elements directly, but bigger payloads belong in a download.

## Next steps

> [card] [Downloads API](https://docs.browserbase.com/platform/browser/files/downloads.md)
>
> Retrieve files an Agent downloads during a run

> [card] [How it works](https://docs.browserbase.com/platform/agents/how-it-works.md)
>
> The execution loop, built-in tools, and run lifecycle

> [card] [Integrating Agents](https://docs.browserbase.com/platform/agents/integrate-api-sdk.md)
>
> Trigger runs and track them from your application

> [card] [List downloads](https://docs.browserbase.com/reference/api/list-downloads.md)
>
> API reference for listing a session's downloads


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.