0

Update an image

by
Published Oct 17, 2025

Updates a private image 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 an image
7
 * Updates a private image that you have permission to `read_write`.
8
 */
9
export async function main(
10
  auth: Linode,
11
  apiVersion: "v4" | "v4beta",
12
  imageId: string,
13
  body: {
14
    capabilities?: string[];
15
    created?: string;
16
    created_by?: string;
17
    deprecated?: false | true;
18
    description?: string;
19
    eol?: string;
20
    expiry?: string;
21
    id?: string;
22
    is_public?: false | true;
23
    label?: string;
24
    regions?: {
25
      region?: string;
26
      status?:
27
        | "available"
28
        | "creating"
29
        | "pending"
30
        | "pending deletion"
31
        | "pending replication"
32
        | "replicating";
33
    }[];
34
    size?: number;
35
    status?: "available" | "creating" | "pending_upload";
36
    tags?: string[];
37
    total_size?: number;
38
    type?: "manual" | "automatic";
39
    updated?: string;
40
    vendor?: string;
41
  },
42
) {
43
  const url = new URL(`https://api.linode.com/${apiVersion}/images/${imageId}`);
44

45
  const response = await fetch(url, {
46
    method: "PUT",
47
    headers: {
48
      "Content-Type": "application/json",
49
      Authorization: "Bearer " + auth.token,
50
    },
51
    body: JSON.stringify(body),
52
  });
53
  if (!response.ok) {
54
    const text = await response.text();
55
    throw new Error(`${response.status} ${text}`);
56
  }
57
  return await response.json();
58
}
59