0

Clone a domain

by
Published Oct 17, 2025

Clones a Domain and all associated DNS records from a Domain that is registered in Linode's DNS manager. > --- - __CLI__. ``` linode-cli domains clone 123 --domain example.com ``` [Learn more...](https://techdocs.akamai.com/cloud-computing/docs/getting-started-with-the-linode-cli) - __OAuth scopes__. ``` domains:read_write ``` [Learn more...](https://techdocs.akamai.com/linode-api/reference/get-started#oauth)

Script linode Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Linode = {
3
  token: string;
4
};
5
/**
6
 * Clone a domain
7
 * Clones a Domain and all associated DNS records from a Domain that is registered in Linode's DNS manager.
8

9

10
>
11

12
---
13

14

15
- __CLI__.
16

17
    ```
18
    linode-cli domains clone 123 --domain example.com
19
    ```
20

21
    [Learn more...](https://techdocs.akamai.com/cloud-computing/docs/getting-started-with-the-linode-cli)
22

23
- __OAuth scopes__.
24

25
    ```
26
    domains:read_write
27
    ```
28

29
    [Learn more...](https://techdocs.akamai.com/linode-api/reference/get-started#oauth)
30
 */
31
export async function main(
32
  auth: Linode,
33
  apiVersion: "v4" | "v4beta",
34
  domainId: string,
35
  body: { domain: string },
36
) {
37
  const url = new URL(
38
    `https://api.linode.com/${apiVersion}/domains/${domainId}/clone`,
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