Skip to main content
The Downloads API provides granular control over files downloaded during browser sessions. You can list, filter, retrieve, and delete individual downloads.
This API is currently available to select customers. Contact support if you’d like access.
Filenames are returned without the timestamp suffix that Browserbase adds during storage.

List Downloads

List all downloads for a session with optional filtering by filename, MIME type, file size, and creation time.
const API_KEY = process.env.BROWSERBASE_API_KEY!;
const sessionId = "your-session-id";

const response = await fetch(
  `https://api.browserbase.com/v1/downloads?sessionId=${sessionId}`,
  {
    headers: { "x-bb-api-key": API_KEY },
  }
);

const { downloads, total } = await response.json();
console.log(`Found ${total} downloads`);

for (const download of downloads) {
  console.log(`- ${download.filename} (${download.size} bytes)`);
}

Filtering Options

ParameterTypeDescription
sessionIdstringRequired. The session ID to list downloads for.
filenamestringFilter by exact filename match.
mimeTypestringFilter by MIME type (e.g., application/pdf).
minSizenumberMinimum file size in bytes.
maxSizenumberMaximum file size in bytes.
createdAfterstringFilter downloads created after this timestamp (ISO 8601).
createdBeforestringFilter downloads created before this timestamp (ISO 8601).
limitnumberMaximum results to return (1-100, default: 20).
offsetnumberNumber of results to skip for pagination.
Example with filters:
API
const API_KEY = process.env.BROWSERBASE_API_KEY!;
const sessionId = "your-session-id";

// Find PDF files larger than 1KB created in the last hour
const params = new URLSearchParams({
  sessionId,
  mimeType: "application/pdf",
  minSize: "1024",
  createdAfter: new Date(Date.now() - 60 * 60 * 1000).toISOString(),
  limit: "10",
});

const response = await fetch(
  `https://api.browserbase.com/v1/downloads?${params}`,
  {
    headers: { "x-bb-api-key": API_KEY },
  }
);

const { downloads } = await response.json();
console.log(`Found ${downloads.length} matching PDFs`);

Get a Download

Retrieve metadata or file content for a specific download. Use Accept: application/json for metadata, or Accept: application/octet-stream to download the file (default if no Accept header is provided).
import { writeFileSync } from "node:fs";

const API_KEY = process.env.BROWSERBASE_API_KEY!;
const downloadId = "download-uuid";

// Get metadata
const metadataResponse = await fetch(
  `https://api.browserbase.com/v1/downloads/${downloadId}`,
  {
    headers: {
      "x-bb-api-key": API_KEY,
      "Accept": "application/json",
    },
  }
);
const metadata = await metadataResponse.json();
console.log(`File: ${metadata.filename} (${metadata.size} bytes)`);

// Download file content
const fileResponse = await fetch(
  `https://api.browserbase.com/v1/downloads/${downloadId}`,
  {
    headers: {
      "x-bb-api-key": API_KEY,
      "Accept": "application/octet-stream",
    },
  }
);
const buffer = Buffer.from(await fileResponse.arrayBuffer());
writeFileSync(metadata.filename, buffer);

Delete a Download

Remove a download from storage. Returns 204 No Content on success.
const API_KEY = process.env.BROWSERBASE_API_KEY!;
const downloadId = "download-uuid";

const response = await fetch(
  `https://api.browserbase.com/v1/downloads/${downloadId}`,
  {
    method: "DELETE",
    headers: { "x-bb-api-key": API_KEY },
  }
);

if (response.status === 204) {
  console.log("Download deleted");
}

Download Object

Each download contains the following fields:
FieldTypeDescription
idstringUnique identifier for the download.
sessionIdstringThe session ID this download belongs to.
filenamestringThe filename of the downloaded file.
mimeTypestringThe MIME type of the file.
sizenumberFile size in bytes.
checksumstringSHA256 checksum of the file.
createdAtstringTimestamp when the file was downloaded (ISO 8601).