0

Update a Shipment Order

by
Published Oct 17, 2025

Update details of an existing Shipment Order in Zoho Inventory.

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 a Shipment Order
7
 * Update details of an existing Shipment Order in Zoho Inventory.
8
 */
9
export async function main(
10
  auth: Zoho,
11
  shipmentorder_id: string,
12
  organization_id: string | undefined,
13
  package_ids: string | undefined,
14
  salesorder_id: string | undefined,
15
  body: {
16
    shipment_number: string;
17
    date: string;
18
    reference_number?: string;
19
    contact_persons?: { contact_person_id?: number }[];
20
    delivery_method: string;
21
    tracking_number?: string;
22
    shipping_charge?: number;
23
    exchange_rate?: number;
24
    template_id?: number;
25
    notes?: string;
26
    custom_fields?: { customfield_id?: number; value?: string }[];
27
  },
28
) {
29
  const url = new URL(
30
    `https://www.zohoapis.com/inventory/v1/shipmentorders/${shipmentorder_id}`,
31
  );
32
  for (const [k, v] of [
33
    ["organization_id", organization_id],
34
    ["package_ids", package_ids],
35
    ["salesorder_id", salesorder_id],
36
  ]) {
37
    if (v !== undefined && v !== "" && k !== undefined) {
38
      url.searchParams.append(k, v);
39
    }
40
  }
41
  const response = await fetch(url, {
42
    method: "PUT",
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