Skip to main content
This guide runs a complete document intake. Stagehand downloads an SDS and sample pesticide-label PDF in a Browserbase session. Box stores the files, extracts their compliance fields, and records the review decision.
1

Get your Browserbase API key

Copy your API key from Browserbase settings.
2

Create a Box Server app

Open the Box Developer Console, then create a Server Authentication app with Client Credentials Grant.Enable these application scopes:
  • Read all files and folders stored in Box
  • Write all files and folders stored in Box
  • Manage AI
Authorize the app in your Box enterprise. Copy the client ID, client secret, and enterprise ID for the next step.
Client Credentials Grant creates short-lived access tokens for the app’s service account at runtime. You don’t need an interactive login or a Box Developer Token.
3

Share a Box folder

Find the service account email in the Box app details. Invite that account to the destination folder with the Editor role.Copy the folder ID from its Box URL:
The workflow can access only the content available to this service account.
4

Install the example

Clone the integrations repository and install the Box example:
5

Configure environment variables

Create your local environment file:
Add your Browserbase and Box credentials:
.env
The example includes default SDS and label sources. Override them when you want to process a different pair:
.env
Each source link must start a browser download. Stagehand clicks the link, and the Browserbase Downloads API exposes the resulting file.
6

Run the intake

Start the workflow:
The command prints:
  • A Browserbase Session Inspector URL
  • The cited Box AI answer
  • Extracted metadata, confidence scores, and source references
  • The APPROVED or NEEDS_REVIEW decision
  • Links to the uploaded Box files

Review the workflow

The example uses Stagehand to find and click each document link. Browserbase stores the remote browser downloads, and the workflow retrieves the original bytes through the Downloads API. After it uploads the files, the workflow calls Box AI to:
  • Answer a safety question about the SDS with citations
  • Extract structured SDS fields
  • Extract label fields, including text embedded in the label artwork
  • Return confidence scores and references for review
The compliance check normalizes the EPA registration numbers, compares them, and confirms that the SDS includes a revision date. Any missing or conflicting value produces NEEDS_REVIEW. Finally, the workflow adds these values to each file’s global properties metadata:
  • Extracted compliance fields
  • Browserbase session ID
  • Source URL
  • Document role
  • Compliance status

Troubleshooting

Box AI isn’t ready

Box may need time to index a new file. The example retries readiness, rate-limit, and server responses with bounded exponential backoff before it stops.

The browser opens a file instead of downloading it

Confirm that the source link starts a browser download. Update the source URL and accessible link name in .env, then use the Session Inspector to confirm that Stagehand clicks the expected link.

Box returns a permissions error

Confirm that the enterprise authorized the Server app, the app has the required file and Box AI scopes, and the destination folder grants its service account the Editor role.

Next steps

Browserbase downloads

Learn how to retrieve files from Browserbase sessions.

Stagehand quickstart

Build browser agents with Stagehand and Browserbase.

Box AI structured extraction

Review the Box API fields, OCR support, and response format.

Box Client Credentials Grant

Configure unattended authentication for a Box service account.