0

Create Assemblies

by
Published Oct 17, 2025

Assemblies is the technique of putting together different components in desired quantities to produce a single commodity. These components could be goods, services and other non-inventory items of your choice.

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 Assemblies
7
 * Assemblies is the technique of putting together different components in desired quantities to produce a single commodity. These components could be goods, services and other non-inventory items of your choice.
8
 */
9
export async function main(
10
  auth: Zoho,
11
  organization_id: string | undefined,
12
  body: {
13
    reference_number: string;
14
    date: string;
15
    description?: string;
16
    composite_item_id: number;
17
    composite_item_name: string;
18
    composite_item_sku?: string;
19
    quantity_to_bundle: number;
20
    line_items: {
21
      item_id: number;
22
      name: string;
23
      description?: string;
24
      quantity_consumed: number;
25
      unit?: string;
26
      account_id: number;
27
      account_name?: string;
28
      location_id?: string;
29
      location_name?: string;
30
      rate?: number;
31
    }[];
32
    is_completed: false | true;
33
  },
34
) {
35
  const url = new URL(`https://www.zohoapis.com/inventory/v1/bundles`);
36
  for (const [k, v] of [["organization_id", organization_id]]) {
37
    if (v !== undefined && v !== "" && k !== undefined) {
38
      url.searchParams.append(k, v);
39
    }
40
  }
41
  const response = await fetch(url, {
42
    method: "POST",
43
    headers: {
44
      "Content-Type": "application/json",
45
      Authorization: "Zoho-oauthtoken " + auth.token,
46
    },
47
    body: JSON.stringify(body),
48
  });
49
  if (!response.ok) {
50
    const text = await response.text();
51
    throw new Error(`${response.status} ${text}`);
52
  }
53
  return await response.json();
54
}
55