0

Add a configuration profile interface

by
Published Oct 17, 2025

Creates and appends a single interface to the end of the `interfaces` array for an existing configuration profile.

Script linode Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Linode = {
3
  token: string;
4
};
5
/**
6
 * Add a configuration profile interface
7
 * Creates and appends a single interface to the end of the `interfaces` array for an existing configuration profile.
8
 */
9
export async function main(
10
  auth: Linode,
11
  apiVersion: "v4" | "v4beta",
12
  linodeId: string,
13
  configId: string,
14
  body: {} & {
15
    active?: false | true;
16
    id?: number;
17
    ip_ranges?: string[];
18
    ipam_address?: string;
19
    ipv4?: { nat_1_1?: string; vpc?: string };
20
    label?: string;
21
    primary?: false | true;
22
    purpose: "public" | "vlan" | "vpc";
23
    subnet_id?: number;
24
    vpc_id?: number;
25
  },
26
) {
27
  const url = new URL(
28
    `https://api.linode.com/${apiVersion}/linode/instances/${linodeId}/configs/${configId}/interfaces`,
29
  );
30

31
  const response = await fetch(url, {
32
    method: "POST",
33
    headers: {
34
      "Content-Type": "application/json",
35
      Authorization: "Bearer " + auth.token,
36
    },
37
    body: JSON.stringify(body),
38
  });
39
  if (!response.ok) {
40
    const text = await response.text();
41
    throw new Error(`${response.status} ${text}`);
42
  }
43
  return await response.json();
44
}
45