0

Update Team Attributes

by
Published Oct 17, 2025

Updates one or more Team Attribute(s) by ID.

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 Team Attributes
7
 * Updates one or more Team Attribute(s) by ID.
8
 */
9
export async function main(
10
  auth: Kustomer,
11
  id: string,
12
  body: {
13
    icon?: string;
14
    name?: string;
15
    displayName?: string;
16
    members?: string[];
17
    createdAt?: string;
18
    deleted?: false | true;
19
  },
20
) {
21
  const url = new URL(`https://api.kustomerapp.com/v1/teams/${id}`);
22

23
  const response = await fetch(url, {
24
    method: "PATCH",
25
    headers: {
26
      "Content-Type": "application/json",
27
      Authorization: "Bearer " + auth.apiKey,
28
    },
29
    body: JSON.stringify(body),
30
  });
31
  if (!response.ok) {
32
    const text = await response.text();
33
    throw new Error(`${response.status} ${text}`);
34
  }
35
  return await response.json();
36
}
37