0

Update a personal access token

by
Published Oct 17, 2025

Updates a Personal Access Token. > --- - __CLI__. ``` linode-cli profile token-update 123 \ --label linode-cli ``` [Learn more...](https://techdocs.akamai.com/cloud-computing/docs/getting-started-with-the-linode-cli) - __OAuth scopes__. ``` account: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 personal access token
7
 * Updates a Personal Access Token.
8

9

10
>
11

12
---
13

14

15
- __CLI__.
16

17
    ```
18
    linode-cli profile token-update 123 \
19
  --label linode-cli
20
    ```
21

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

24
- __OAuth scopes__.
25

26
    ```
27
    account:read_write
28
    ```
29

30
    [Learn more...](https://techdocs.akamai.com/linode-api/reference/get-started#oauth)
31
 */
32
export async function main(
33
  auth: Linode,
34
  apiVersion: "v4" | "v4beta",
35
  tokenId: string,
36
  body: {
37
    created?: string;
38
    expiry?: string;
39
    id?: number;
40
    label?: string;
41
    scopes?: string;
42
    token?: string;
43
  },
44
) {
45
  const url = new URL(
46
    `https://api.linode.com/${apiVersion}/profile/tokens/${tokenId}`,
47
  );
48

49
  const response = await fetch(url, {
50
    method: "PUT",
51
    headers: {
52
      "Content-Type": "application/json",
53
      Authorization: "Bearer " + auth.token,
54
    },
55
    body: JSON.stringify(body),
56
  });
57
  if (!response.ok) {
58
    const text = await response.text();
59
    throw new Error(`${response.status} ${text}`);
60
  }
61
  return await response.json();
62
}
63