0

Create / Invite New User

by
Published Oct 17, 2025

Creates an account for a new user and sends an email invitation to join the organization within Kustomer. ### Note > Requires **org.admin.user** permissions. The permissions for the new user cannot exceed those of the user making the request and will be filtered automatically. The default roles for new users are **org.admin** and **org.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
 * Create / Invite New User
7
 * Creates an account for a new user and sends an email invitation to join the organization within Kustomer.
8

9
### Note
10
> Requires **org.admin.user** permissions.  The permissions for the new user cannot exceed those of the user making the request and will be filtered automatically. The default roles for new users are **org.admin** and **org.user**.
11
 */
12
export async function main(
13
  auth: Kustomer,
14
  body: {
15
    displayName?: string;
16
    avatarUrl?: string;
17
    name: string;
18
    email: string;
19
    mobile?: string;
20
    emailSignature?: string;
21
    userType?: "user" | "machine" | "limited" | "hourly";
22
    roleGroups?: string[];
23
    roles?: string[];
24
  },
25
) {
26
  const url = new URL(`https://api.kustomerapp.com/v1/users`);
27

28
  const response = await fetch(url, {
29
    method: "POST",
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