//native
type Kustomer = {
apiKey: string;
};
/**
* Create Klass
* Creates a new [Klass](https://help.kustomer.com/define-attributes-Skr924HI#Attributes) model for your Kustomer organization.
Any one of the following roles is required for this endpoint:
|Legacy Role|Equivalent Permission Set Role|
|-----|--------|
|org.admin.klass.write|org.permission.klass.create|
*/
export async function main(
auth: Kustomer,
body: {
name: string;
displayName?: string;
icon?: string;
color?: string;
jsonSchema?: unknown;
klassSchema?: "task";
mixins?: "commentable" | "assignable" | "editable" | "creatable"[];
status?: "enabled" | "disabled";
},
) {
const url = new URL(`https://api.kustomerapp.com/v1/klasses`);
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