> ## Documentation Index
> Fetch the complete documentation index at: https://docs.baseten.co/llms.txt
> Use this file to discover all available pages before exploring further.

# Manage drives

> Create a drive, check its status, replace its labels, and delete it.

Create a drive, check it, change its labels, or delete it. Create it in the
region where the sandboxes that mount it run. To use the files from a sandbox,
see [Mount drives](https://docs.baseten.co/drives/mount.md).

> [!NOTE]
>
> Drives are in private preview. [Contact us](mailto:support@baseten.co) to request access for your organization.

## Set up

The drive examples use the same SDKs and CLI as sandboxes. The management
client creates, gets, lists, updates, and deletes drives. Mounting goes
through a sandbox.

Every example reads your API key from the `BASETEN_API_KEY` environment
variable, so keep the key out of your code.

**To set your API key**:

Replace `<BASETEN_API_KEY>` with a
[personal API key](https://docs.baseten.co/organization/api-keys.md#key-types) or a team API key with
**Full access to all team models**. Other key types, such as
**Invoke dedicated models**, can't create the access token that drive requests
use. The SDKs and CLI create that token for you. Then run the following
command in the shell where you run the examples:

```bash theme={"system"}
export BASETEN_API_KEY="<BASETEN_API_KEY>"
```

**To install and connect your SDK or CLI**:

> [tab] TypeScript
>
> 1. Run the following command to install the SDK:
>
>    ```bash theme={"system"}
>    npm install @basetenlabs/client @basetenlabs/sandbox undici
>    ```
>
> 2. Create the management client, which reads the key from the
>    environment:
>
>    ```typescript theme={"system"}
>    import { ManagementClient } from "@basetenlabs/client";
>
>    const client = new ManagementClient({ apiKey: process.env.BASETEN_API_KEY! });
>    ```

> [tab] Python
>
> 1. Run the following command to install the SDK:
>
>    ```bash theme={"system"}
>    pip install --upgrade baseten "httpx[http2]"
>    ```
>
> 2. Create the management client, which reads the key from the
>    environment:
>
>    ```python theme={"system"}
>    import os
>
>    from baseten.client import ManagementClient
>
>    client = ManagementClient(api_key=os.environ["BASETEN_API_KEY"])
>    ```

> [tab] Go
>
> 1. Run the following command to install the SDK:
>
>    ```bash theme={"system"}
>    go get github.com/basetenlabs/baseten-go@latest
>    ```
>
> 2. Create the management client, which reads the key from the
>    environment:
>
>    ```go theme={"system"}
>    management, err := client.NewManagementClient(client.ManagementClientOptions{
>        APIKey: os.Getenv("BASETEN_API_KEY"),
>    })
>    if err != nil {
>        log.Fatal(err)
>    }
>    ```
>
>    Import `github.com/basetenlabs/baseten-go/client`.

> [tab] API
>
> The [drive API](https://docs.baseten.co/reference/management-api/overview.md#drives) doesn't accept
> your API key directly. Exchange it for an
> [access token](https://docs.baseten.co/sandboxes/authentication.md) with the `drives` scope. Request
> the `sandboxes` scope too, so one token also works for mount requests.
>
> 1. Run the following command to
>    [create a token](https://docs.baseten.co/reference/management-api/sandboxes/create-a-sandbox-access-token.md):
>
>    ```bash theme={"system"}
>    curl --request POST \
>      --url https://api.baseten.co/v1/token \
>      --header "Authorization: Bearer $BASETEN_API_KEY" \
>      --header "Content-Type: application/json" \
>      --data '{"scopes": ["sandboxes", "drives"]}'
>    ```
>
>    If drives aren't turned on for your organization, the request returns
>    HTTP `403`.
>
> 2. Replace `<TOKEN>` with the response's `token` value, then run the
>    following command:
>
>    ```bash theme={"system"}
>    export SANDBOX_TOKEN="<TOKEN>"
>    ```

> [tab] CLI
>
> 1. [Install or update the Baseten CLI](https://docs.baseten.co/reference/cli/baseten/overview.md#install).
>
> 2. Run the following command to sign in:
>
>    ```bash theme={"system"}
>    baseten auth login
>    ```
>
> The drive commands are [`baseten drive`](https://docs.baseten.co/reference/cli/baseten/drive)
> and [`baseten sandbox drive`](https://docs.baseten.co/reference/cli/baseten/sandbox#drive).

## Select a team

If you belong to one team, requests use it. If you belong to more than one,
every drive request must name a team, or it fails. Pass the same team when you
create the sandbox client. Create the drive in the team whose sandboxes mount
it.

Replace `<TEAM_ID>` with the team's ID. [Select a team](https://docs.baseten.co/sandboxes/configure.md#select-a-team)
shows how to find it for a sandbox. Use that same ID here.

**To pass the team**:

> [tab] TypeScript
>
> Add `teamId` to each drive call, and pass it when you create the sandbox client:
>
> ```typescript theme={"system"}
> import { ManagementClient } from "@basetenlabs/client";
> import { SandboxClient } from "@basetenlabs/sandbox";
>
> const apiKey = process.env.BASETEN_API_KEY!;
> const client = new ManagementClient({ apiKey });
> const drive = await client.drives.getInfo({ name: "shared-notes", teamId: "<TEAM_ID>" });
>
> const sandboxes = new SandboxClient({ apiKey, teamId: "<TEAM_ID>" });
> ```

> [tab] Python
>
> Add `team_id` to each drive call, and pass it when you create the sandbox client:
>
> ```python theme={"system"}
> import os
>
> from baseten.client import ManagementClient
> from baseten.sandbox import SandboxClient
>
> api_key = os.environ["BASETEN_API_KEY"]
> with ManagementClient(api_key=api_key) as client:
>     drive = client.drives.get_info(name="shared-notes", team_id="<TEAM_ID>")
>
> sandboxes = SandboxClient(api_key=api_key, team_id="<TEAM_ID>")
> ```

> [tab] Go
>
> Set `TeamID` in the drive options and the sandbox client options:
>
> ```go theme={"system"}
> client.DriveGetInfoOptions{
>     Name:   "shared-notes",
>     TeamID: "<TEAM_ID>",
> }
>
> sandbox.ClientOptions{
>     APIKey: os.Getenv("BASETEN_API_KEY"),
>     TeamID: "<TEAM_ID>",
> }
> ```

> [tab] API
>
> Add `team_id` to each drive request. You can send the same ID in the
> `X-Team-Id` header instead. If you send both, use the same ID.
>
> ```bash theme={"system"}
> curl --url "https://api.baseten.co/v1/drives/instances?team_id=<TEAM_ID>" \
>   --header "Authorization: Bearer $SANDBOX_TOKEN"
> ```

> [tab] CLI
>
> Add `--team` to each drive and sandbox command:
>
> ```bash theme={"system"}
> baseten drive list --team <TEAM_ID>
> ```

## Create a drive

Baseten creates the drive in your default sandbox region. If your sandboxes
run in a different region, [create the drive in that region](#create-a-drive-in-a-specific-region).

You can't change the name or region later. Creation returns before the drive
is ready. The drive is ready when its status is `DEPLOYED`.

> [!NOTE]
>
> Each drive name is unique in your team. Use lowercase letters, digits, and
> hyphens, from 1 to 49 characters, and don't start or end with a hyphen. If
> you don't pass a name, Baseten generates one.

**To create a drive named `shared-notes`**:

> [tab] TypeScript
>
> Run the following code, which waits until the drive is ready:
>
> ```typescript theme={"system"}
> import { ManagementClient } from "@basetenlabs/client";
>
> const client = new ManagementClient({ apiKey: process.env.BASETEN_API_KEY! });
> let drive = await client.drives.create({
>   name: "shared-notes",
>   labels: { project: "alpha" },
> });
> while (drive.status === "DEPLOYING") {
>   await new Promise((resolve) => setTimeout(resolve, 2000));
>   drive = await client.drives.getInfo({ name: "shared-notes" });
> }
> console.log(drive.status, drive.region);
> ```

> [tab] Python
>
> Run the following code, which waits until the drive is ready:
>
> ```python theme={"system"}
> import os
> import time
>
> from baseten.client import ManagementClient
>
> with ManagementClient(api_key=os.environ["BASETEN_API_KEY"]) as client:
>     drive = client.drives.create(name="shared-notes", labels={"project": "alpha"})
>     while drive.status == "DEPLOYING":
>         time.sleep(2)
>         drive = client.drives.get_info(name="shared-notes")
>     print(drive.status, drive.region)
> ```

> [tab] Go
>
> Run the following code, which waits until the drive is ready:
>
> ```go theme={"system"}
> package main
>
> import (
>     "context"
>     "fmt"
>     "log"
>     "os"
>     "time"
>
>     "github.com/basetenlabs/baseten-go/client"
> )
>
> func main() {
>     ctx := context.Background()
>     management, err := client.NewManagementClient(client.ManagementClientOptions{
>         APIKey: os.Getenv("BASETEN_API_KEY"),
>     })
>     if err != nil {
>         log.Fatal(err)
>     }
>     drive, err := management.Drives().Create(ctx, client.DriveCreateOptions{
>         Name:   "shared-notes",
>         Labels: map[string]string{"project": "alpha"},
>     })
>     if err != nil {
>         log.Fatal(err)
>     }
>     for drive.Status == client.DriveStatusDeploying {
>         time.Sleep(2 * time.Second)
>         drive, err = management.Drives().GetInfo(ctx, client.DriveGetInfoOptions{Name: "shared-notes"})
>         if err != nil {
>             log.Fatal(err)
>         }
>     }
>     fmt.Println(drive.Status, drive.Region)
> }
> ```

> [tab] API
>
> 1. Run the following command to
>    [create the drive](https://docs.baseten.co/reference/management-api/drives/create-a-drive.md):
>
>    ```bash theme={"system"}
>    curl --request POST \
>      --url https://api.baseten.co/v1/drives/instances \
>      --header "Authorization: Bearer $SANDBOX_TOKEN" \
>      --header "Content-Type: application/json" \
>      --data '{"name": "shared-notes", "labels": {"project": "alpha"}}'
>    ```
>
>    The request returns HTTP `201` with the drive's record. Its `status`
>    can still be `DEPLOYING`.
>
> 2. Run the following command to [get the drive](https://docs.baseten.co/reference/management-api/drives/get-a-drive.md)
>    until the response's `status` is `DEPLOYED`:
>
>    ```bash theme={"system"}
>    curl --url https://api.baseten.co/v1/drives/instances/shared-notes \
>      --header "Authorization: Bearer $SANDBOX_TOKEN"
>    ```
>
>    The response's `region` field holds the drive's region.

> [tab] CLI
>
> 1. Run the following command to create the drive:
>
>    ```bash theme={"system"}
>    baseten drive create --name shared-notes --label project=alpha
>    ```
>
> 2. Run the following command until it prints `"DEPLOYED"`:
>
>    ```bash theme={"system"}
>    baseten drive describe --name shared-notes --jq '.status'
>    ```

## Create a drive in a specific region

To mount a drive from a sandbox, create the drive in the sandbox's region.
Drives are available in `us-was-1` and `eu-fra-1`.

Replace `hello-world` with the name of a sandbox in a supported region.
If you already know the region where your sandboxes run or plan to run,
start at step 2 and use that region.

> [tab] TypeScript
>
> 1. Run the following code to print the region of the sandbox named
>    `hello-world`:
>
>    ```typescript theme={"system"}
>    import { SandboxClient } from "@basetenlabs/sandbox";
>
>    const sandboxes = new SandboxClient({ apiKey: process.env.BASETEN_API_KEY! });
>    const info = await sandboxes.getInfo({ name: "hello-world" });
>    console.log(info.region);
>    ```
>
> 2. Create the drive in that region. Replace `us-was-1` with the region
>    from step 1 if it differs.
>
>    ```typescript theme={"system"}
>    import { ManagementClient } from "@basetenlabs/client";
>
>    const management = new ManagementClient({ apiKey: process.env.BASETEN_API_KEY! });
>    const drive = await management.drives.create({
>      name: "shared-notes",
>      region: "us-was-1",
>    });
>    console.log(drive.region);
>    ```

> [tab] Python
>
> 1. Run the following code to print the region of the sandbox named
>    `hello-world`:
>
>    ```python theme={"system"}
>    import os
>
>    from baseten.sandbox import SandboxClient
>
>    with SandboxClient(api_key=os.environ["BASETEN_API_KEY"]) as sandboxes:
>        info = sandboxes.get_info(name="hello-world")
>        print(info.region)
>    ```
>
> 2. Create the drive in that region. Replace `us-was-1` with the region
>    from step 1 if it differs.
>
>    ```python theme={"system"}
>    import os
>
>    from baseten.client import ManagementClient
>
>    with ManagementClient(api_key=os.environ["BASETEN_API_KEY"]) as management:
>        drive = management.drives.create(name="shared-notes", region="us-was-1")
>        print(drive.region)
>    ```

> [tab] Go
>
> 1. Run the following code to print the region of the sandbox named
>    `hello-world`:
>
>    ```go theme={"system"}
>    package main
>
>    import (
>        "context"
>        "fmt"
>        "log"
>        "os"
>
>        "github.com/basetenlabs/baseten-go/sandbox"
>    )
>
>    func main() {
>        ctx := context.Background()
>        sandboxes, err := sandbox.NewClient(sandbox.ClientOptions{
>            APIKey: os.Getenv("BASETEN_API_KEY"),
>        })
>        if err != nil {
>            log.Fatal(err)
>        }
>        info, err := sandboxes.GetInfo(ctx, sandbox.GetInfoOptions{Name: "hello-world"})
>        if err != nil {
>            log.Fatal(err)
>        }
>        fmt.Println(info.Region)
>    }
>    ```
>
> 2. Create the drive in that region. Replace `us-was-1` with the region
>    from step 1 if it differs.
>
>    ```go theme={"system"}
>    package main
>
>    import (
>        "context"
>        "fmt"
>        "log"
>        "os"
>
>        "github.com/basetenlabs/baseten-go/client"
>    )
>
>    func main() {
>        ctx := context.Background()
>        management, err := client.NewManagementClient(client.ManagementClientOptions{
>            APIKey: os.Getenv("BASETEN_API_KEY"),
>        })
>        if err != nil {
>            log.Fatal(err)
>        }
>        drive, err := management.Drives().Create(ctx, client.DriveCreateOptions{
>            Name:   "shared-notes",
>            Region: "us-was-1",
>        })
>        if err != nil {
>            log.Fatal(err)
>        }
>        fmt.Println(drive.Region)
>    }
>    ```

> [tab] API
>
> 1. Run the following command to get the sandbox named `hello-world`.
>    Check the `region` field in the response.
>
>    ```bash theme={"system"}
>    curl --url https://api.baseten.co/v1/sandboxes/instances/hello-world \
>      --header "Authorization: Bearer $SANDBOX_TOKEN"
>    ```
>
> 2. Create the drive in the region from the response. Replace `us-was-1`
>    with that region if it differs.
>
>    ```bash theme={"system"}
>    curl --request POST \
>      --url https://api.baseten.co/v1/drives/instances \
>      --header "Authorization: Bearer $SANDBOX_TOKEN" \
>      --header "Content-Type: application/json" \
>      --data '{"name": "shared-notes", "region": "us-was-1"}'
>    ```

> [tab] CLI
>
> 1. Run the following command to print the region of the sandbox named
>    `hello-world`:
>
>    ```bash theme={"system"}
>    baseten sandbox describe --name hello-world --jq '.region'
>    ```
>
> 2. Run the following command to create the drive in that region, such as
>    `us-was-1`:
>
>    ```bash theme={"system"}
>    baseten drive create --name shared-notes --region us-was-1
>    ```

## Get a drive

A drive's record holds its name, region, status, and labels, and when and by
whom it was created and last updated. Its status is one of these values:

| Status | Meaning |
| - | - |
| `DEPLOYING` | Baseten is still setting up the drive. |
| `DEPLOYED` | The drive is ready to mount. |
| `FAILED` | Setup failed. |
| `DELETING` | Baseten is deleting the drive and its files. |

**To get the drive named `shared-notes`**:

> [tab] TypeScript
>
> Run the following code:
>
> ```typescript theme={"system"}
> import { ManagementClient } from "@basetenlabs/client";
>
> const client = new ManagementClient({ apiKey: process.env.BASETEN_API_KEY! });
> const drive = await client.drives.getInfo({ name: "shared-notes" });
> console.log(drive.status, drive.region, drive.labels);
> ```

> [tab] Python
>
> Run the following code:
>
> ```python theme={"system"}
> import os
>
> from baseten.client import ManagementClient
>
> with ManagementClient(api_key=os.environ["BASETEN_API_KEY"]) as client:
>     drive = client.drives.get_info(name="shared-notes")
>     print(drive.status, drive.region, drive.labels)
> ```

> [tab] Go
>
> Run the following code:
>
> ```go theme={"system"}
> package main
>
> import (
>     "context"
>     "fmt"
>     "log"
>     "os"
>
>     "github.com/basetenlabs/baseten-go/client"
> )
>
> func main() {
>     ctx := context.Background()
>     management, err := client.NewManagementClient(client.ManagementClientOptions{
>         APIKey: os.Getenv("BASETEN_API_KEY"),
>     })
>     if err != nil {
>         log.Fatal(err)
>     }
>     drive, err := management.Drives().GetInfo(ctx, client.DriveGetInfoOptions{Name: "shared-notes"})
>     if err != nil {
>         log.Fatal(err)
>     }
>     fmt.Println(drive.Status, drive.Region, drive.Labels)
> }
> ```

> [tab] API
>
> Run the following command to [get the drive](https://docs.baseten.co/reference/management-api/drives/get-a-drive.md):
>
> ```bash theme={"system"}
> curl --url https://api.baseten.co/v1/drives/instances/shared-notes \
>   --header "Authorization: Bearer $SANDBOX_TOKEN"
> ```
>
> A drive that doesn't exist returns HTTP `404`.

> [tab] CLI
>
> Run the following command:
>
> ```bash theme={"system"}
> baseten drive describe --name shared-notes
> ```
>
> Add `--output json` to print the full record as JSON.

## List drives

Drives are listed newest first. The SDKs fetch further pages as you iterate.

**To list your team's drives**:

> [tab] TypeScript
>
> Run the following code:
>
> ```typescript theme={"system"}
> import { ManagementClient } from "@basetenlabs/client";
>
> const client = new ManagementClient({ apiKey: process.env.BASETEN_API_KEY! });
> for await (const drive of client.drives.list()) {
>   console.log(drive.name, drive.status, drive.region);
> }
> ```

> [tab] Python
>
> Run the following code:
>
> ```python theme={"system"}
> import os
>
> from baseten.client import ManagementClient
>
> with ManagementClient(api_key=os.environ["BASETEN_API_KEY"]) as client:
>     for drive in client.drives.list():
>         print(drive.name, drive.status, drive.region)
> ```

> [tab] Go
>
> Run the following code:
>
> ```go theme={"system"}
> package main
>
> import (
>     "context"
>     "fmt"
>     "log"
>     "os"
>
>     "github.com/basetenlabs/baseten-go/client"
> )
>
> func main() {
>     ctx := context.Background()
>     management, err := client.NewManagementClient(client.ManagementClientOptions{
>         APIKey: os.Getenv("BASETEN_API_KEY"),
>     })
>     if err != nil {
>         log.Fatal(err)
>     }
>     for drive, err := range management.Drives().List(ctx, client.DriveListOptions{}) {
>         if err != nil {
>             log.Fatal(err)
>         }
>         fmt.Println(drive.Name, drive.Status, drive.Region)
>     }
> }
> ```

> [tab] API
>
> Run the following command to [list your drives](https://docs.baseten.co/reference/management-api/drives/list-drives.md):
>
> ```bash theme={"system"}
> curl --url "https://api.baseten.co/v1/drives/instances?limit=100" \
>   --header "Authorization: Bearer $SANDBOX_TOKEN"
> ```
>
> The response holds up to `limit` drives in `items`, from 1 to 100 with a
> default of 20. While `pagination.has_more` is `true`, request the next
> page by adding `cursor` with the value of `pagination.cursor`. Keep the
> other query parameters the same.

> [tab] CLI
>
> Run the following command:
>
> ```bash theme={"system"}
> baseten drive list
> ```
>
> The command prints up to 1,000 drives. Pass `--limit 0` to print all of
> them. To print only the names, add `--jq '.items[].name'`.

## Filter drives

Filter by a search over drive names, by status, or by both. The status values
are `DEPLOYING`, `DEPLOYED`, `FAILED`, and `DELETING`, and you can pass more
than one.

**To list drives with `notes` in their name that failed**:

> [tab] TypeScript
>
> Run the following code:
>
> ```typescript theme={"system"}
> import { ManagementClient } from "@basetenlabs/client";
>
> const client = new ManagementClient({ apiKey: process.env.BASETEN_API_KEY! });
> for await (const drive of client.drives.list({ query: "notes", statuses: ["FAILED"] })) {
>   console.log(drive.name, drive.status);
> }
> ```

> [tab] Python
>
> Run the following code:
>
> ```python theme={"system"}
> import os
>
> from baseten.client import ManagementClient
>
> with ManagementClient(api_key=os.environ["BASETEN_API_KEY"]) as client:
>     for drive in client.drives.list(query="notes", statuses=["FAILED"]):
>         print(drive.name, drive.status)
> ```

> [tab] Go
>
> Run the following code:
>
> ```go theme={"system"}
> package main
>
> import (
>     "context"
>     "fmt"
>     "log"
>     "os"
>
>     "github.com/basetenlabs/baseten-go/client"
> )
>
> func main() {
>     ctx := context.Background()
>     management, err := client.NewManagementClient(client.ManagementClientOptions{
>         APIKey: os.Getenv("BASETEN_API_KEY"),
>     })
>     if err != nil {
>         log.Fatal(err)
>     }
>     opts := client.DriveListOptions{
>         Query:    "notes",
>         Statuses: []client.DriveStatus{client.DriveStatusFailed},
>     }
>     for drive, err := range management.Drives().List(ctx, opts) {
>         if err != nil {
>             log.Fatal(err)
>         }
>         fmt.Println(drive.Name, drive.Status)
>     }
> }
> ```

> [tab] API
>
> Run the following command:
>
> ```bash theme={"system"}
> curl --url "https://api.baseten.co/v1/drives/instances?q=notes&status=FAILED" \
>   --header "Authorization: Bearer $SANDBOX_TOKEN"
> ```
>
> To match more than one status, repeat `status`, such as `status=FAILED&status=DEPLOYING`.

> [tab] CLI
>
> Run the following command:
>
> ```bash theme={"system"}
> baseten drive list --query notes --status failed
> ```
>
> The CLI takes lowercase status values. Repeat `--status` to match more than one.

## Replace drive labels

Labels are the only part of a drive you can change. The labels you send replace the drive's current labels. They aren't merged with the labels already on it.

**To set the labels of `shared-notes` to `project=alpha` and `env=dev`**:

> [tab] TypeScript
>
> Run the following code:
>
> ```typescript theme={"system"}
> import { ManagementClient } from "@basetenlabs/client";
>
> const client = new ManagementClient({ apiKey: process.env.BASETEN_API_KEY! });
> const drive = await client.drives.update({
>   name: "shared-notes",
>   labels: { project: "alpha", env: "dev" },
> });
> console.log(drive.labels);
> ```
>
> To remove every label, pass `labels: {}`.

> [tab] Python
>
> Run the following code:
>
> ```python theme={"system"}
> import os
>
> from baseten.client import ManagementClient
>
> with ManagementClient(api_key=os.environ["BASETEN_API_KEY"]) as client:
>     drive = client.drives.update(
>         name="shared-notes", labels={"project": "alpha", "env": "dev"}
>     )
>     print(drive.labels)
> ```
>
> To remove every label, pass `labels={}`.

> [tab] Go
>
> Run the following code:
>
> ```go theme={"system"}
> package main
>
> import (
>     "context"
>     "fmt"
>     "log"
>     "os"
>
>     "github.com/basetenlabs/baseten-go/client"
> )
>
> func main() {
>     ctx := context.Background()
>     management, err := client.NewManagementClient(client.ManagementClientOptions{
>         APIKey: os.Getenv("BASETEN_API_KEY"),
>     })
>     if err != nil {
>         log.Fatal(err)
>     }
>     drive, err := management.Drives().Update(ctx, client.DriveUpdateOptions{
>         Name:   "shared-notes",
>         Labels: map[string]string{"project": "alpha", "env": "dev"},
>     })
>     if err != nil {
>         log.Fatal(err)
>     }
>     fmt.Println(drive.Labels)
> }
> ```
>
> To remove every label, pass an empty map.

> [tab] API
>
> Run the following command to [replace the drive's labels](https://docs.baseten.co/reference/management-api/drives/update-a-drive.md):
>
> ```bash theme={"system"}
> curl --request PATCH \
>   --url https://api.baseten.co/v1/drives/instances/shared-notes \
>   --header "Authorization: Bearer $SANDBOX_TOKEN" \
>   --header "Content-Type: application/json" \
>   --data '{"labels": {"project": "alpha", "env": "dev"}}'
> ```
>
> The response holds the drive's record with its new labels. To remove every
> label, send `{"labels": {}}`. A request that includes `name` or `region`
> returns HTTP `400`.

> [tab] CLI
>
> Run the following command:
>
> ```bash theme={"system"}
> baseten drive update --name shared-notes --label project=alpha --label env=dev
> ```
>
> To remove every label, pass `--clear-labels` instead of `--label`. The two
> flags can't be combined.

## Delete a drive

Delete a drive when no sandbox needs its files anymore.

> [!WARNING]
>
> Deleting a drive permanently deletes every file on it, for every sandbox that
> uses it. You can't undo it.

Before you delete a drive, [unmount it](https://docs.baseten.co/drives/mount.md#unmount-a-drive) from every
sandbox that has it mounted. Baseten doesn't block deleting a drive that's
still mounted, and a sandbox that has it mounted keeps the mount after the
drive is gone, still able to read and write there. Deletion continues after
the call returns, and the drive's status is `DELETING` until it's gone.

**To delete the drive named `shared-notes`**:

> [tab] TypeScript
>
> Run the following code:
>
> ```typescript theme={"system"}
> import { ManagementClient } from "@basetenlabs/client";
>
> const client = new ManagementClient({ apiKey: process.env.BASETEN_API_KEY! });
> const drive = await client.drives.delete({ name: "shared-notes" });
> console.log(drive.status);
> ```

> [tab] Python
>
> Run the following code:
>
> ```python theme={"system"}
> import os
>
> from baseten.client import ManagementClient
>
> with ManagementClient(api_key=os.environ["BASETEN_API_KEY"]) as client:
>     drive = client.drives.delete(name="shared-notes")
>     print(drive.status)
> ```

> [tab] Go
>
> Run the following code:
>
> ```go theme={"system"}
> package main
>
> import (
>     "context"
>     "fmt"
>     "log"
>     "os"
>
>     "github.com/basetenlabs/baseten-go/client"
> )
>
> func main() {
>     ctx := context.Background()
>     management, err := client.NewManagementClient(client.ManagementClientOptions{
>         APIKey: os.Getenv("BASETEN_API_KEY"),
>     })
>     if err != nil {
>         log.Fatal(err)
>     }
>     drive, err := management.Drives().Delete(ctx, client.DriveDeleteOptions{Name: "shared-notes"})
>     if err != nil {
>         log.Fatal(err)
>     }
>     fmt.Println(drive.Status)
> }
> ```

> [tab] API
>
> Run the following command to [delete the drive](https://docs.baseten.co/reference/management-api/drives/delete-a-drive.md):
>
> ```bash theme={"system"}
> curl --request DELETE \
>   --url https://api.baseten.co/v1/drives/instances/shared-notes \
>   --header "Authorization: Bearer $SANDBOX_TOKEN"
> ```
>
> The request returns HTTP `202` with the drive's record, whose `status` is
> `DELETING`.

> [tab] CLI
>
> Run the following command and confirm when prompted:
>
> ```bash theme={"system"}
> baseten drive delete --name shared-notes
> ```
>
> Pass `--yes` to skip the prompt when scripting.

The SDK examples print `DELETING`. To confirm the drive is gone,
[get the drive](#get-a-drive). Once it's gone, the request returns HTTP `404`.

## Next steps

> [card] [Mount drives](https://docs.baseten.co/drives/mount.md)
>
> Mount the drive in a running sandbox.

> [card] [Drives](https://docs.baseten.co/drives/overview.md)
>
> Decide when a drive fits better than a sandbox volume.
