0

Create a managed service

by
Published Oct 17, 2025

Creates a Managed Service.

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 managed service
7
 * Creates a Managed Service.
8
 */
9
export async function main(
10
  auth: Linode,
11
  apiVersion: "v4" | "v4beta",
12
  body: {
13
    address?: string;
14
    body?: string;
15
    consultation_group?: string;
16
    created?: string;
17
    credentials?: number[];
18
    id?: number;
19
    label?: string;
20
    notes?: string;
21
    region?: string;
22
    service_type?: "url" | "tcp";
23
    status?: "disabled" | "pending" | "ok" | "problem";
24
    timeout?: number;
25
    updated?: string;
26
  },
27
) {
28
  const url = new URL(`https://api.linode.com/${apiVersion}/managed/services`);
29

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