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

# Update a drive

> Replace a drive's labels. A drive's name and region can't change.

Labels are the only part of a [drive](https://docs.baseten.co/drives/overview.md) you can change. The
labels you send replace all of the drive's current labels; they aren't merged
with them. [Set up your SDK or the CLI](https://docs.baseten.co/drives/create-drives.md#set-up) before running
these examples.

> [!NOTE]
>
> Drives are in pre-release in the Baseten CLI (`baseten drive` and `baseten sandbox drive`) and in the Python, TypeScript, and Go SDKs (`baseten`, `@basetenlabs/client`, `@basetenlabs/sandbox`, and `baseten-go`). Commands, methods, and responses can change. The [Management API drive operations](https://docs.baseten.co/reference/management-api/overview.md#drives) are experimental.

## Replace a drive's labels

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

## Next steps

> [card] [Get a drive](https://docs.baseten.co/drives/get-drives.md)
>
> Check a drive's status, region, and labels.

> [card] [List drives](https://docs.baseten.co/drives/list-drives.md)
>
> Find drives by name or status.
