0

Update Shipping address

by
Published Oct 17, 2025

Updates the shipping address for an existing credit note alone.

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 Shipping address
7
 * Updates the shipping address for an existing credit note alone.
8
 */
9
export async function main(
10
  auth: Zoho,
11
  creditnote_id: string,
12
  organization_id: string | undefined,
13
  body: {
14
    address?: string;
15
    city?: string;
16
    state?: string;
17
    zip?: string;
18
    country?: string;
19
    fax?: string;
20
  },
21
) {
22
  const url = new URL(
23
    `https://www.zohoapis.com/books/v3/creditnotes/${creditnote_id}/address/shipping`,
24
  );
25
  for (const [k, v] of [["organization_id", organization_id]]) {
26
    if (v !== undefined && v !== "" && k !== undefined) {
27
      url.searchParams.append(k, v);
28
    }
29
  }
30
  const response = await fetch(url, {
31
    method: "PUT",
32
    headers: {
33
      "Content-Type": "application/json",
34
      Authorization: "Zoho-oauthtoken " + auth.token,
35
    },
36
    body: JSON.stringify(body),
37
  });
38
  if (!response.ok) {
39
    const text = await response.text();
40
    throw new Error(`${response.status} ${text}`);
41
  }
42
  return await response.json();
43
}
44