0

Update a domain record

by
Published Oct 17, 2025

Updates a single Record on this Domain. > --- - __CLI__. ``` linode-cli domains records-update 123 234 \ --name test \ --target 203.0.113.1 \ --priority 50 \ --weight 50 \ --port 80 \ --ttl_sec 604800 ``` [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
 * Update a domain record
7
 * Updates a single Record on this Domain.
8

9

10
>
11

12
---
13

14

15
- __CLI__.
16

17
    ```
18
    linode-cli domains records-update 123 234 \
19
  --name test \
20
  --target 203.0.113.1 \
21
  --priority 50 \
22
  --weight 50 \
23
  --port 80 \
24
  --ttl_sec 604800
25
    ```
26

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

29
- __OAuth scopes__.
30

31
    ```
32
    domains:read_write
33
    ```
34

35
    [Learn more...](https://techdocs.akamai.com/linode-api/reference/get-started#oauth)
36
 */
37
export async function main(
38
  auth: Linode,
39
  apiVersion: "v4" | "v4beta",
40
  domainId: string,
41
  recordId: string,
42
  body: {
43
    name?: string;
44
    port?: number;
45
    priority?: number;
46
    protocol?: string;
47
    service?: string;
48
    tag?: "issue" | "issuewild" | "iodef";
49
    target?: string;
50
    ttl_sec?: number;
51
    weight?: number;
52
  },
53
) {
54
  const url = new URL(
55
    `https://api.linode.com/${apiVersion}/domains/${domainId}/records/${recordId}`,
56
  );
57

58
  const response = await fetch(url, {
59
    method: "PUT",
60
    headers: {
61
      "Content-Type": "application/json",
62
      Authorization: "Bearer " + auth.token,
63
    },
64
    body: JSON.stringify(body),
65
  });
66
  if (!response.ok) {
67
    const text = await response.text();
68
    throw new Error(`${response.status} ${text}`);
69
  }
70
  return await response.json();
71
}
72