0

Update a volume

by
Published Oct 17, 2025

Updates a Volume that you have permission to `read_write`. > --- - __CLI__. ``` linode-cli volumes update 12345 \ --label my_volume ``` [Learn more...](https://techdocs.akamai.com/cloud-computing/docs/getting-started-with-the-linode-cli) - __OAuth scopes__. ``` volumes:read_write ``` [Learn more...](https://techdocs.akamai.com/linode-api/reference/get-started#oauth)

Script linode Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Linode = {
3
  token: string;
4
};
5
/**
6
 * Update a volume
7
 * Updates a Volume that you have permission to `read_write`.
8

9

10
>
11

12
---
13

14

15
- __CLI__.
16

17
    ```
18
    linode-cli volumes update 12345 \
19
  --label my_volume
20
    ```
21

22
    [Learn more...](https://techdocs.akamai.com/cloud-computing/docs/getting-started-with-the-linode-cli)
23

24
- __OAuth scopes__.
25

26
    ```
27
    volumes:read_write
28
    ```
29

30
    [Learn more...](https://techdocs.akamai.com/linode-api/reference/get-started#oauth)
31
 */
32
export async function main(
33
  auth: Linode,
34
  apiVersion: "v4" | "v4beta",
35
  volumeId: string,
36
  body: {
37
    created?: string;
38
    encryption?: "enabled" | "disabled";
39
    filesystem_path?: string;
40
    hardware_type?: "hdd" | "nvme";
41
    id?: number;
42
    label?: string;
43
    linode_id?: number;
44
    linode_label?: string;
45
    region?: string;
46
    size?: number;
47
    status?: "creating" | "active" | "resizing" | "key_rotating";
48
    tags?: string[];
49
    updated?: string;
50
  } & { linode_id?: {}; size?: {} },
51
) {
52
  const url = new URL(
53
    `https://api.linode.com/${apiVersion}/volumes/${volumeId}`,
54
  );
55

56
  const response = await fetch(url, {
57
    method: "PUT",
58
    headers: {
59
      "Content-Type": "application/json",
60
      Authorization: "Bearer " + auth.token,
61
    },
62
    body: JSON.stringify(body),
63
  });
64
  if (!response.ok) {
65
    const text = await response.text();
66
    throw new Error(`${response.status} ${text}`);
67
  }
68
  return await response.json();
69
}
70