---
title: "API keys and permissions"
description: "Connect an application or script to one workspace."
canonical_url: "https://docs.flashdrive.space/platform/api-keys"
---
# API keys and permissions

> Connect an application or script to one workspace.

An API key connects an application, script or service to all drives in one workspace. Choose the permission the application needs.

<table>
<thead>
  <tr>
    <th>
      Permission
    </th>
    
    <th>
      API value
    </th>
    
    <th>
      Lets the application
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      Read
    </td>
    
    <td>
      <code>
        search
      </code>
    </td>
    
    <td>
      List, find, read and download files and folders.
    </td>
  </tr>
  
  <tr>
    <td>
      Read / Write
    </td>
    
    <td>
      <code>
        read_write
      </code>
    </td>
    
    <td>
      Do all of the above, and upload, change, move and delete files and folders.
    </td>
  </tr>
</tbody>
</table>

A key never reaches another workspace. To give a cloud sandbox or batch job access to just one drive or one folder for a limited time, use a [sandbox token](https://docs.flashdrive.space/cli/sandboxes) instead of a workspace key. To give an AI agent access, set up an [agent connection](https://docs.flashdrive.space/mcp/connect).

## Create a key

<tabs>
<tabs-item label="Console">

1. As a workspace admin, open **Settings** in the sidebar, then the **API keys** tab.
2. Enter a descriptive **Key name** and choose the **Permission** your application needs.
3. Set an expiry date and time if the key should stop working then, and select **Create key**.
4. Copy the key when it is shown and store it in your secret manager.

</tabs-item>

<tabs-item label="CLI">

```sh
flashdrive keys create "nightly-report" --permission read_write
```

`--permission` is `search` (read, the default) or `read_write`. Add `--expires-at` with a date and time to set an expiry. `flashdrive keys list` lists the workspace's keys and `flashdrive keys revoke KEY_ID` revokes one.

</tabs-item>
</tabs>

The full key is shown only once. If you lose it, create a replacement and update your application.

## Use the key

Set it in the application's environment as `FLASHDRIVE_API_KEY`. The Python SDK and the CLI read it from there:

```sh
export FLASHDRIVE_API_KEY="..."
```

To save a key for the CLI instead, run `flashdrive login --api-key` and paste the key at the hidden prompt.

For the REST API, send the key over HTTPS as `Authorization: Bearer YOUR_KEY`. See [authentication](https://docs.flashdrive.space/reference/authentication) for the other required headers.

Keep keys on servers and in secret managers. Never put a key in client-side code, a prompt, a file in a drive, or a URL.

## Rotate a key

1. Create a replacement key with the same permission.
2. Update the application and confirm it can read a file.
3. Revoke the old key.

Revoke a key at once if it may have leaked. Keys that expire stop working at their expiry time.

Continue with [SDK installation](https://docs.flashdrive.space/sdk/installation) or [authentication](https://docs.flashdrive.space/reference/authentication).


## Sitemap

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