0

Update a Linode

by
Published Oct 17, 2025

Updates a Linode that you have permission to `read_write`.

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 Linode
7
 * Updates a Linode that you have permission to `read_write`.
8
 */
9
export async function main(
10
  auth: Linode,
11
  apiVersion: "v4" | "v4beta",
12
  linodeId: string,
13
  body: {
14
    alerts?: {
15
      cpu?: number;
16
      io?: number;
17
      network_in?: number;
18
      network_out?: number;
19
      transfer_quota?: number;
20
    };
21
    backups?: {
22
      available?: false | true;
23
      enabled?: false | true;
24
      last_successful?: string;
25
      schedule?: {
26
        day?:
27
          | "Scheduling"
28
          | "Sunday"
29
          | "Monday"
30
          | "Tuesday"
31
          | "Wednesday"
32
          | "Thursday"
33
          | "Friday"
34
          | "Saturday";
35
        window?:
36
          | "Scheduling"
37
          | "W0"
38
          | "W2"
39
          | "W4"
40
          | "W6"
41
          | "W8"
42
          | "W10"
43
          | "W12"
44
          | "W14"
45
          | "W16"
46
          | "W18"
47
          | "W20"
48
          | "W22";
49
      };
50
    };
51
    capabilities?: string[];
52
    created?: string;
53
    disk_encryption?: string;
54
    group?: string;
55
    has_user_data?: false | true;
56
    host_uuid?: string;
57
    hypervisor?: "kvm";
58
    id?: number;
59
    image?: string;
60
    ipv4?: string[];
61
    ipv6?: string;
62
    label?: string;
63
    lke_cluster_id?: number;
64
    placement_group?: {
65
      id?: number;
66
      label?: string;
67
      placement_group_policy?: "strict" | "flexible";
68
      placement_group_type?: "anti_affinity:local";
69
    };
70
    region?: string;
71
    specs?: {
72
      disk?: number;
73
      gpus?: number;
74
      memory?: number;
75
      transfer?: number;
76
      vcpus?: number;
77
    };
78
    status?:
79
      | "running"
80
      | "offline"
81
      | "booting"
82
      | "busy"
83
      | "rebooting"
84
      | "shutting_down"
85
      | "provisioning"
86
      | "deleting"
87
      | "migrating"
88
      | "rebuilding"
89
      | "cloning"
90
      | "restoring"
91
      | "stopped"
92
      | "billing_suspension";
93
    tags?: string[];
94
    type?: string;
95
    updated?: string;
96
    watchdog_enabled?: false | true;
97
  },
98
) {
99
  const url = new URL(
100
    `https://api.linode.com/${apiVersion}/linode/instances/${linodeId}`,
101
  );
102

103
  const response = await fetch(url, {
104
    method: "PUT",
105
    headers: {
106
      "Content-Type": "application/json",
107
      Authorization: "Bearer " + auth.token,
108
    },
109
    body: JSON.stringify(body),
110
  });
111
  if (!response.ok) {
112
    const text = await response.text();
113
    throw new Error(`${response.status} ${text}`);
114
  }
115
  return await response.json();
116
}
117