0

Update Current User

by
Published Oct 17, 2025

Updates the current user.

Script kustomer Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Kustomer = {
3
  apiKey: string;
4
};
5
/**
6
 * Update Current User
7
 * Updates the current user.
8
 */
9
export async function main(
10
  auth: Kustomer,
11
  body: {
12
    displayName?: string;
13
    avatarUrl?: string;
14
    name?: string;
15
    email?: string;
16
    mobile?: string;
17
    emailSignature?: string;
18
    deleted?: false | true;
19
    password?: string;
20
    currentPassword?: string;
21
    userType?: "user" | "limited" | "hourly";
22
    roleGroups?: string[];
23
    roles?: string[];
24
  },
25
) {
26
  const url = new URL(`https://api.kustomerapp.com/v1/users/current`);
27

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