0

Resize a Linode

by
Published Oct 17, 2025

Resizes a Linode you have the `read_write` permission to a different Type.

Script linode Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Linode = {
3
  token: string;
4
};
5
/**
6
 * Resize a Linode
7
 * Resizes a Linode you have the `read_write` permission to a different Type.
8
 */
9
export async function main(
10
  auth: Linode,
11
  apiVersion: "v4" | "v4beta",
12
  linodeId: string,
13
  body: {
14
    allow_auto_disk_resize?: false | true;
15
    migration_type?: "warm" | "cold";
16
    type: string;
17
  },
18
) {
19
  const url = new URL(
20
    `https://api.linode.com/${apiVersion}/linode/instances/${linodeId}/resize`,
21
  );
22

23
  const response = await fetch(url, {
24
    method: "POST",
25
    headers: {
26
      "Content-Type": "application/json",
27
      Authorization: "Bearer " + auth.token,
28
    },
29
    body: JSON.stringify(body),
30
  });
31
  if (!response.ok) {
32
    const text = await response.text();
33
    throw new Error(`${response.status} ${text}`);
34
  }
35
  return await response.json();
36
}
37