Open docs
CLI Guide

Give a sandbox one drive

Make a short-lived sandbox token, hand it to a cloud sandbox or job, and use or mount the drive inside it.

To let a cloud sandbox, container or GPU job use a drive, give it a sandbox token instead of an API key. A sandbox token reaches one drive, or one folder of it, for a short time. Extend it while the job runs, and revoke it when the job is done.

What a token can do

A sandbox tokenDetails
Reaches one driveOptionally only one folder and its subfolders. Requests for any other drive, folder or file are refused.
Has one access levelread (list, read and grep files) or read_write (also upload, replace, edit and write bytes, delete files, and create, rename or delete folders inside its scope).
Lasts 5 minutes to 12 hours1 hour by default. Never longer than the API key that made it.
Never writes agent instruction filesFiles and folders named AGENTS.md, CLAUDE.md, GEMINI.md, SKILL.md, copilot-instructions.md, .cursorrules, .windsurfrules, .github, .claude, .codex, .cursor, .vscode and .agents stay read-only to it. A read_write token cannot be made for a folder inside one of those folders.

A sandbox token cannot move files, create folder trees with flashdrive folder ensure, delete a folder with everything in it, or make file links. It cannot make, list, extend or revoke tokens.

Make a token

You can make a read_write token if your API key has Read / Write permission or your workspace role can change content.

flashdrive sandbox-token create --drive DRIVE_ID --folder FOLDER_ID \
  --access read --ttl-seconds 3600 --name render-job --out token.txt
OptionUse
--drive, --folderThe drive, and optionally the folder (with its subfolders) the token reaches. Default: the selected drive, whole.
--access read or read_writeDefault read.
--ttl-seconds N300 to 43,200 seconds, default 3,600.
--name NAMEA label you will recognize later, up to 120 characters.
--out FILESave the token to a new file only you can read. The file must not exist yet.
--printShow the token once in the output instead.

Choose exactly one of --out and --print. The token is shown only once. Never paste it into a prompt, a command line, a log or a repository; code that hands it to a sandbox should read it from the --out file.

You can also make tokens from the Python SDK, or ask a connected assistant to make one with the MCP tool create_sandbox_token (it needs the Give sandboxes drive access permission; see assistant permissions).

Past the workspace's token limits, the service answers auth_rate_limited with a time to retry after.

Hand it to the sandbox

Inside the sandbox, the CLI and SDK read the token from FLASHDRIVE_API_KEY. Pass it to the sandbox as a secret, never as a value on a command line. The sandbox needs outbound HTTPS to the API; if you set FLASHDRIVE_BASE_URL, pass that too.

Where the job runsHow to pass the token
A sandbox with a network proxy that can add headersA proxy route for the API host that adds Authorization: Bearer <token>, with the token stored as the route's secret. The sandbox never holds the token: set FLASHDRIVE_API_KEY=proxy-injected inside it. The CLI and SDK use the sandbox's proxy (HTTPS_PROXY) and its CA bundle. Prefer this where your sandbox provider offers it.
E2BThe sandbox's envs when you create it.
A serverless GPU platformIts secret store, attached to the function or sandbox.
Daytonaenv_vars (envVars in TypeScript) when you create the sandbox.
Vercel SandboxThe env of each command that needs it.
Docker or another runtime--env-file with a file only you can read, or -e FLASHDRIVE_API_KEY with no value to pass through a variable already set in your environment.

Use the drive inside the sandbox

Install the CLI (pip install --upgrade flashdrive-cli, Python 3.10 or later). No sign-in is needed: commands use the token's drive, and with a folder token, uploads go to its folder by default.

flashdrive file list
flashdrive grep 'def train' --glob '**/*.py'
flashdrive file read DOCUMENT_ID --start-line 1 --line-count 50
flashdrive upload ./results --recursive --wait          # read_write tokens
flashdrive file patch DOCUMENT_ID chunk.bin --append --revision REVISION
  • With a folder token, flashdrive file list covers one folder per call (use flashdrive folder list for its subfolders); grep covers the whole subtree.
  • flashdrive file cat --bytes and flashdrive file get read a file's original bytes. flashdrive file link is not available to a sandbox token.
  • In Python, pass folder_id when uploading with a folder token.

Mount the drive

For large and media files, mount the drive (Linux with /dev/fuse; the CLI's Linux package includes the mount helper; see mount requirements):

flashdrive mount --at /mnt/drive

A folder token mounts its folder as the top of the mount, and a read token mounts read-only. Files the token may not write, such as instruction files, stay in the sandbox and show as unsaved in flashdrive mounts. If FUSE or the helper is unavailable, use the file commands above. After a sandbox wakes, check or resume its saved mount.

Follow changes

flashdrive changes                     # prints the current cursor and no changes
flashdrive file list                   # then list the drive
flashdrive changes --cursor CURSOR     # later: what changed since

Take the cursor first, then list, then follow with each new cursor. Each entry has sequence, kind (upsert or delete), document_id, external_id, filename, folder_id, revision, operation_id and operation_state. has_more is true when more entries are ready; call again with the cursor. With a folder token you see only its subtree, and a file moved out of it appears as a delete. --limit takes 1 to 1,000 entries (default 500).

Extend or revoke

flashdrive sandbox-token list
flashdrive sandbox-token extend TOKEN_ID --ttl-seconds 7200
flashdrive sandbox-token revoke TOKEN_ID --yes

list shows live tokens newest first, without their secrets. --state recent adds tokens that ended in the last 30 days, and --drive filters by drive. extend sets a live token's expiry to now plus --ttl-seconds (default 3,600), so uploads in flight keep working; an ended token cannot be extended. Revocation takes effect for new requests within 60 seconds. Revoke a token as soon as the job is done, or at once if it may have leaked.

Workspace admins also see live tokens in the Console, under Sandbox tokens in the workspace's API key settings, with Revoke on each one.

When a token ends

A token ends at its expiry, when it is revoked, or when whatever made it ends or loses access:

  • made with an API key: when that key is revoked or expires;
  • made by a signed-in person: when that sign-in ends or the person loses access to the workspace;
  • made through an assistant: when the MCP connection is revoked, its sign-in ends, or it loses the Give sandboxes drive access permission.

When a token ends, its uploads that are still queued stop too.

Copyright © 2026