//native
type Kustomer = {
apiKey: string;
};
/**
* Create / Invite New User
* 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**.
*/
export async function main(
auth: Kustomer,
body: {
displayName?: string;
avatarUrl?: string;
name: string;
email: string;
mobile?: string;
emailSignature?: string;
userType?: "user" | "machine" | "limited" | "hourly";
roleGroups?: string[];
roles?: string[];
},
) {
const url = new URL(`https://api.kustomerapp.com/v1/users`);
const response = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer " + auth.apiKey,
},
body: JSON.stringify(body),
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 235 days ago