0

Update group

by
Published Oct 17, 2025
Script zoho Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Zoho = {
3
  token: string;
4
};
5
/**
6
 * Update group
7
 *
8
 */
9
export async function main(
10
  auth: Zoho,
11
  group: string,
12
  body: {
13
    user_groups?: {
14
      created_by: { name: string; id: string };
15
      modified_by: { name: string; id: string };
16
      modified_time: string;
17
      created_time: string;
18
      description: string;
19
      id: string;
20
      name: string;
21
      sources_count: {
22
        territories: number;
23
        roles: number;
24
        groups: number;
25
        users: { inactive: number; deleted: number; active: number };
26
      };
27
      sources: {
28
        type: "territories" | "roles" | "users";
29
        source: { id: string; name: string };
30
        subordinates: false | true;
31
        sub_territories: false | true;
32
      }[];
33
    }[];
34
  },
35
) {
36
  const url = new URL(
37
    `https://zohoapis.com/crm/v8/settings/user_groups/${group}`,
38
  );
39

40
  const response = await fetch(url, {
41
    method: "PUT",
42
    headers: {
43
      "Content-Type": "application/json",
44
      Authorization: "Zoho-oauthtoken " + auth.token,
45
    },
46
    body: JSON.stringify(body),
47
  });
48
  if (!response.ok) {
49
    const text = await response.text();
50
    throw new Error(`${response.status} ${text}`);
51
  }
52
  return await response.json();
53
}
54