0

Create a Shipment Order

by
Published Oct 17, 2025

A new shipment order can a be created. To create shipment, URL parameter's package_ids and salesorder_id are mandatory.

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 a Shipment Order
7
 * A new shipment order can a be created. To create shipment, URL parameter's package_ids and salesorder_id are mandatory.
8
 */
9
export async function main(
10
  auth: Zoho,
11
  organization_id: string | undefined,
12
  package_ids: string | undefined,
13
  salesorder_id: string | undefined,
14
  body: {
15
    shipment_number: string;
16
    date: string;
17
    reference_number?: string;
18
    contact_persons?: { contact_person_id?: number }[];
19
    delivery_method: string;
20
    tracking_number: string;
21
    shipping_charge?: number;
22
    exchange_rate?: number;
23
    template_id?: number;
24
    notes?: string;
25
    custom_fields?: { customfield_id?: number; value?: string }[];
26
  },
27
) {
28
  const url = new URL(`https://www.zohoapis.com/inventory/v1/shipmentorders`);
29
  for (const [k, v] of [
30
    ["organization_id", organization_id],
31
    ["package_ids", package_ids],
32
    ["salesorder_id", salesorder_id],
33
  ]) {
34
    if (v !== undefined && v !== "" && k !== undefined) {
35
      url.searchParams.append(k, v);
36
    }
37
  }
38
  const response = await fetch(url, {
39
    method: "POST",
40
    headers: {
41
      "Content-Type": "application/json",
42
      Authorization: "Zoho-oauthtoken " + auth.token,
43
    },
44
    body: JSON.stringify(body),
45
  });
46
  if (!response.ok) {
47
    const text = await response.text();
48
    throw new Error(`${response.status} ${text}`);
49
  }
50
  return await response.json();
51
}
52