0

Creating a Composite Item

by
Published Oct 17, 2025

A new composite item can be created after creating items that we want to associcate with composite item. User can attach image for composite item by calling Different API 'https://www.zohoapis.com/inventory/v1/compositeitems/{composite_item_id}/image', 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
 * Creating a Composite Item
7
 * A new composite item can be created after creating items that we want to associcate with composite item. User can attach image for composite item by calling Different API 'https://www.zohoapis.com/inventory/v1/compositeitems/{composite_item_id}/image', 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
    name: string;
14
    mapped_items: {
15
      quantity?: number;
16
      item_id: number;
17
      line_item_id?: number;
18
    }[];
19
    description?: string;
20
    is_combo_product?: false | true;
21
    vendor_id?: number;
22
    purchase_rate?: number;
23
    purchase_description?: string;
24
    initial_stock?: number;
25
    initial_stock_rate?: number;
26
    tax_id?: number;
27
    sku: string;
28
    isbn?: number;
29
    ean?: number;
30
    part_number?: string;
31
    reorder_level?: number;
32
    unit?: string;
33
    upc?: number;
34
    item_type: string;
35
    rate: number;
36
    custom_fields?: { custom_field_id?: number; value?: string }[];
37
    account_id?: number;
38
    purchase_account_id?: number;
39
    inventory_account_id?: number;
40
    item_tax_preferences?: { tax_id?: number; tax_specification?: string }[];
41
    hsn_or_sac?: string;
42
    product_type: string;
43
  },
44
) {
45
  const url = new URL(`https://www.zohoapis.com/inventory/v1/compositeitems`);
46
  for (const [k, v] of [["organization_id", organization_id]]) {
47
    if (v !== undefined && v !== "" && k !== undefined) {
48
      url.searchParams.append(k, v);
49
    }
50
  }
51
  const response = await fetch(url, {
52
    method: "POST",
53
    headers: {
54
      "Content-Type": "application/json",
55
      Authorization: "Zoho-oauthtoken " + auth.token,
56
    },
57
    body: JSON.stringify(body),
58
  });
59
  if (!response.ok) {
60
    const text = await response.text();
61
    throw new Error(`${response.status} ${text}`);
62
  }
63
  return await response.json();
64
}
65