0

Update an Item Group

by
Published Oct 17, 2025

Updates the details of an existing Item Group.

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 an Item Group
7
 * Updates the details of an existing Item Group.
8
 */
9
export async function main(
10
  auth: Zoho,
11
  itemgroup_id: string,
12
  organization_id: string | undefined,
13
  body: {
14
    group_name: string;
15
    brand?: string;
16
    manufacturer?: string;
17
    unit: string;
18
    description?: string;
19
    tax_id?: number;
20
    attribute_name1?: string;
21
    custom_fields?: { customfield_id?: number; value?: string }[];
22
    name: string;
23
    rate: number;
24
    purchase_rate: number;
25
    sku: string;
26
  },
27
) {
28
  const url = new URL(
29
    `https://www.zohoapis.com/inventory/v1/itemgroups/${itemgroup_id}`,
30
  );
31
  for (const [k, v] of [["organization_id", organization_id]]) {
32
    if (v !== undefined && v !== "" && k !== undefined) {
33
      url.searchParams.append(k, v);
34
    }
35
  }
36
  const response = await fetch(url, {
37
    method: "PUT",
38
    headers: {
39
      "Content-Type": "application/json",
40
      Authorization: "Zoho-oauthtoken " + auth.token,
41
    },
42
    body: JSON.stringify(body),
43
  });
44
  if (!response.ok) {
45
    const text = await response.text();
46
    throw new Error(`${response.status} ${text}`);
47
  }
48
  return await response.json();
49
}
50