0

Create a StackScript

by
Published Oct 17, 2025

Creates a StackScript in your Account.

Script linode Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Linode = {
3
  token: string;
4
};
5
/**
6
 * Create a StackScript
7
 * Creates a StackScript in your Account.
8
 */
9
export async function main(
10
  auth: Linode,
11
  apiVersion: "v4" | "v4beta",
12
  body: {
13
    created?: string;
14
    deployments_active?: number;
15
    deployments_total?: number;
16
    description?: string;
17
    id?: number;
18
    images?: string[];
19
    is_public?: false | true;
20
    label?: string;
21
    mine?: false | true;
22
    rev_note?: string;
23
    script?: string;
24
    updated?: string;
25
    user_defined_fields?: {
26
      default?: string;
27
      example: string;
28
      label: string;
29
      manyOf?: string;
30
      name: string;
31
      oneOf?: string;
32
    }[];
33
    user_gravatar_id?: string;
34
    username?: string;
35
  },
36
) {
37
  const url = new URL(
38
    `https://api.linode.com/${apiVersion}/linode/stackscripts`,
39
  );
40

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