0

Update billing address

by
Published Oct 17, 2025

Updates the billing address for this sales order 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 billing address
7
 * Updates the billing address for this sales order alone.
8
 */
9
export async function main(
10
  auth: Zoho,
11
  salesorder_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
    phone?: string;
20
    fax?: string;
21
    attention?: string;
22
    is_one_off_address?: false | true;
23
    is_update_customer?: false | true;
24
    is_verified?: false | true;
25
  },
26
) {
27
  const url = new URL(
28
    `https://www.zohoapis.com/books/v3/salesorders/${salesorder_id}/address/billing`,
29
  );
30
  for (const [k, v] of [["organization_id", organization_id]]) {
31
    if (v !== undefined && v !== "" && k !== undefined) {
32
      url.searchParams.append(k, v);
33
    }
34
  }
35
  const response = await fetch(url, {
36
    method: "PUT",
37
    headers: {
38
      "Content-Type": "application/json",
39
      Authorization: "Zoho-oauthtoken " + auth.token,
40
    },
41
    body: JSON.stringify(body),
42
  });
43
  if (!response.ok) {
44
    const text = await response.text();
45
    throw new Error(`${response.status} ${text}`);
46
  }
47
  return await response.json();
48
}
49