0

Create Klass

by
Published Oct 17, 2025

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|

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 Klass
7
 * Creates a new [Klass](https://help.kustomer.com/define-attributes-Skr924HI#Attributes) model for your Kustomer organization.
8

9
Any one of the following roles is required for this endpoint:
10

11
|Legacy Role|Equivalent Permission Set Role|
12
|-----|--------|
13
|org.admin.klass.write|org.permission.klass.create|
14
 */
15
export async function main(
16
  auth: Kustomer,
17
  body: {
18
    name: string;
19
    displayName?: string;
20
    icon?: string;
21
    color?: string;
22
    jsonSchema?: unknown;
23
    klassSchema?: "task";
24
    mixins?: "commentable" | "assignable" | "editable" | "creatable"[];
25
    status?: "enabled" | "disabled";
26
  },
27
) {
28
  const url = new URL(`https://api.kustomerapp.com/v1/klasses`);
29

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