0

Delete a disk

by
Published Oct 17, 2025

Deletes a Disk you have permission to `read_write`. __Deleting a Disk is a destructive action and cannot be undone.__ > --- - __CLI__. ``` linode-cli linodes disk-delete 123 24674 ``` [Learn more...](https://techdocs.akamai.com/cloud-computing/docs/getting-started-with-the-linode-cli) - __OAuth scopes__. ``` linodes: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
 * Delete a disk
7
 * Deletes a Disk you have permission to `read_write`.
8

9
__Deleting a Disk is a destructive action and cannot be undone.__
10

11

12
>
13

14
---
15

16

17
- __CLI__.
18

19
    ```
20
    linode-cli linodes disk-delete 123 24674
21
    ```
22

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

25
- __OAuth scopes__.
26

27
    ```
28
    linodes:read_write
29
    ```
30

31
    [Learn more...](https://techdocs.akamai.com/linode-api/reference/get-started#oauth)
32
 */
33
export async function main(
34
  auth: Linode,
35
  apiVersion: "v4" | "v4beta",
36
  linodeId: string,
37
  diskId: string,
38
) {
39
  const url = new URL(
40
    `https://api.linode.com/${apiVersion}/linode/instances/${linodeId}/disks/${diskId}`,
41
  );
42

43
  const response = await fetch(url, {
44
    method: "DELETE",
45
    headers: {
46
      Authorization: "Bearer " + auth.token,
47
    },
48
    body: undefined,
49
  });
50
  if (!response.ok) {
51
    const text = await response.text();
52
    throw new Error(`${response.status} ${text}`);
53
  }
54
  return await response.json();
55
}
56