---
title: "Give a sandbox one drive"
description: "Make a short-lived sandbox token, hand it to a cloud sandbox or job, and use or mount the drive inside it."
canonical_url: "https://docs.flashdrive.space/cli/sandboxes"
---
# 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

<table>
<thead>
  <tr>
    <th>
      A sandbox token
    </th>
    
    <th>
      Details
    </th>
  </tr>
</thead>

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

A sandbox token cannot move files, create folder trees with `flashdrive folder ensure`, delete a folder with everything in it, or make [file links](https://docs.flashdrive.space/cli/commands#find-read-and-write-files). 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.

```bash
flashdrive sandbox-token create --drive DRIVE_ID --folder FOLDER_ID \
  --access read --ttl-seconds 3600 --name render-job --out token.txt
```

<table>
<thead>
  <tr>
    <th>
      Option
    </th>
    
    <th>
      Use
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        --drive
      </code>
      
      , <code>
        --folder
      </code>
    </td>
    
    <td>
      The drive, and optionally the folder (with its subfolders) the token reaches. Default: the selected drive, whole.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        --access read
      </code>
      
       or <code>
        read_write
      </code>
    </td>
    
    <td>
      Default <code>
        read
      </code>
      
      .
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        --ttl-seconds N
      </code>
    </td>
    
    <td>
      300 to 43,200 seconds, default 3,600.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        --name NAME
      </code>
    </td>
    
    <td>
      A label you will recognize later, up to 120 characters.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        --out FILE
      </code>
    </td>
    
    <td>
      Save the token to a new file only you can read. The file must not exist yet.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        --print
      </code>
    </td>
    
    <td>
      Show the token once in the output instead.
    </td>
  </tr>
</tbody>
</table>

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](https://docs.flashdrive.space/sdk/drives-and-defaults), 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](https://docs.flashdrive.space/mcp/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.

<table>
<thead>
  <tr>
    <th>
      Where the job runs
    </th>
    
    <th>
      How to pass the token
    </th>
  </tr>
</thead>

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

## 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.

```bash
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](https://docs.flashdrive.space/cli/mount-and-sync#requirements)):

```bash
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](https://docs.flashdrive.space/cli/mount-and-sync#resume-after-a-sandbox-wakes).

### Follow changes

```bash
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

```bash
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.


## Sitemap

See the full [sitemap](https://docs.flashdrive.space/sitemap.md) for all pages.
