0

Create a user

by
Published Oct 17, 2025

Creates a user on your account.

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 user
7
 * Creates a user on your account.
8
 */
9
export async function main(
10
  auth: Linode,
11
  apiVersion: "v4" | "v4beta",
12
  body: {
13
    email?: string;
14
    last_login?: { login_datetime?: string; status?: "successful" | "failed" };
15
    password_created?: string;
16
    restricted?: false | true;
17
    ssh_keys?: string[];
18
    tfa_enabled?: false | true;
19
    username?: string;
20
    verified_phone_number?: string;
21
  },
22
) {
23
  const url = new URL(`https://api.linode.com/${apiVersion}/account/users`);
24

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