0

Create a domain

by
Published Oct 17, 2025

Adds a new Domain to Linode's DNS Manager.

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 domain
7
 * Adds a new Domain to Linode's DNS Manager.
8
 */
9
export async function main(
10
  auth: Linode,
11
  apiVersion: "v4" | "v4beta",
12
  body: {
13
    axfr_ips?: string[];
14
    description?: string;
15
    domain?: string;
16
    expire_sec?: number;
17
    group?: string;
18
    id?: number;
19
    master_ips?: string[];
20
    refresh_sec?: number;
21
    retry_sec?: number;
22
    soa_email?: string;
23
    status?: "disabled" | "active";
24
    tags?: string[];
25
    ttl_sec?: number;
26
    type?: "master" | "slave";
27
  },
28
) {
29
  const url = new URL(`https://api.linode.com/${apiVersion}/domains`);
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