0

Create an Item Group

by
Published Oct 17, 2025

A new Item Group can a be created. While creating items, user can attach image for product group by passing form-data parameter image i.e., -F image=bag_s.jpg.

Script zoho Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Zoho = {
3
  token: string;
4
};
5
/**
6
 * Create an Item Group
7
 * A new Item Group can a be created. While creating items, user can attach image for product group by passing form-data parameter image i.e., -F image=bag_s.jpg.
8
 */
9
export async function main(
10
  auth: Zoho,
11
  organization_id: string | undefined,
12
  body: {
13
    group_name: string;
14
    brand?: string;
15
    manufacturer?: string;
16
    unit: string;
17
    description?: string;
18
    tax_id?: number;
19
    attribute_name1?: string;
20
    items?: {
21
      name: string;
22
      rate: number;
23
      purchase_rate: number;
24
      reorder_level?: number;
25
      initial_stock?: number;
26
      initial_stock_rate?: number;
27
      vendor_id?: number;
28
      sku?: string;
29
      upc?: number;
30
      ean?: number;
31
      isbn?: string;
32
      part_number?: string;
33
      attribute_option_name1?: number;
34
      custom_fields?: { customfield_id?: number; value?: string }[];
35
    }[];
36
    attributes?: {
37
      id?: number;
38
      name?: string;
39
      options?: { id?: number; name?: string }[];
40
    }[];
41
  },
42
) {
43
  const url = new URL(`https://www.zohoapis.com/inventory/v1/itemgroups`);
44
  for (const [k, v] of [["organization_id", organization_id]]) {
45
    if (v !== undefined && v !== "" && k !== undefined) {
46
      url.searchParams.append(k, v);
47
    }
48
  }
49
  const response = await fetch(url, {
50
    method: "POST",
51
    headers: {
52
      "Content-Type": "application/json",
53
      Authorization: "Zoho-oauthtoken " + auth.token,
54
    },
55
    body: JSON.stringify(body),
56
  });
57
  if (!response.ok) {
58
    const text = await response.text();
59
    throw new Error(`${response.status} ${text}`);
60
  }
61
  return await response.json();
62
}
63