0

Update Klass by ID

by
Published Oct 17, 2025

Updates Klass attributes based on the unique Klass ID. Any one of the following roles is required for this endpoint: |Legacy Role|Equivalent Permission Set Role| |-----|--------| |org.admin.klass.write|org.permission.klass.update|

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 Klass by ID
7
 * Updates Klass attributes based on the unique Klass ID.
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.update|
14
 */
15
export async function main(
16
  auth: Kustomer,
17
  id: string,
18
  body: {
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/${id}`);
29

30
  const response = await fetch(url, {
31
    method: "PUT",
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