0

Update address

by
Published Oct 17, 2025

Update shipping and billing address of an invoice.

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 address
7
 * Update shipping and billing address of an invoice.
8
 */
9
export async function main(
10
  auth: Zoho,
11
  invoice_id: string,
12
  X_com_zoho_subscriptions_organizationid: string,
13
  body: {
14
    billing_address?: {
15
      city?: string;
16
      state?: string;
17
      zip?: string;
18
      country?: string;
19
      fax?: string;
20
    };
21
    shipping_address?: {
22
      street?: string;
23
      city?: string;
24
      state?: string;
25
      zip?: string;
26
      country?: string;
27
      fax?: string;
28
    };
29
  },
30
) {
31
  const url = new URL(
32
    `https://www.zohoapis.com/billing/v1/invoices/${invoice_id}/address`,
33
  );
34

35
  const response = await fetch(url, {
36
    method: "PUT",
37
    headers: {
38
      "X-com-zoho-subscriptions-organizationid":
39
        X_com_zoho_subscriptions_organizationid,
40
      "Content-Type": "application/json",
41
      Authorization: "Zoho-oauthtoken " + auth.token,
42
    },
43
    body: JSON.stringify(body),
44
  });
45
  if (!response.ok) {
46
    const text = await response.text();
47
    throw new Error(`${response.status} ${text}`);
48
  }
49
  return await response.json();
50
}
51