0

Update an addon

by
Published Oct 17, 2025

Update details of an existing addon.

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 an addon
7
 * Update details of an existing addon.
8
 */
9
export async function main(
10
  auth: Zoho,
11
  addon_code: string,
12
  X_com_zoho_subscriptions_organizationid: string,
13
  body: {
14
    addon_code: string;
15
    name: string;
16
    unit_name: string;
17
    pricing_scheme?: string;
18
    price_brackets: {
19
      start_quantity: number;
20
      end_quantity: number;
21
      price: number;
22
    }[];
23
    type?: string;
24
    interval_unit?: string;
25
    tags?: { tag_id?: number; tag_option_id?: number }[];
26
    custom_fields?: { label?: string; value?: string }[];
27
    applicable_to_all_plans?: false | true;
28
    plans: { plan_code: string; name?: {} }[];
29
    product_id: string;
30
    description?: string;
31
    store_markup_description?: string;
32
    product_type?: string;
33
    hsn_or_sac?: string;
34
    sat_item_key_code?: string;
35
    unitkey_code?: string;
36
    item_tax_preferences?: {
37
      tax_specification?: string;
38
      tax_name?: string;
39
      tax_percentage?: number;
40
      tax_id?: string;
41
    }[];
42
    tax_id?: string;
43
    tax_exemption_id?: string;
44
    tax_exemption_code?: string;
45
  },
46
) {
47
  const url = new URL(
48
    `https://www.zohoapis.com/billing/v1/addons/${addon_code}`,
49
  );
50

51
  const response = await fetch(url, {
52
    method: "PUT",
53
    headers: {
54
      "X-com-zoho-subscriptions-organizationid":
55
        X_com_zoho_subscriptions_organizationid,
56
      "Content-Type": "application/json",
57
      Authorization: "Zoho-oauthtoken " + auth.token,
58
    },
59
    body: JSON.stringify(body),
60
  });
61
  if (!response.ok) {
62
    const text = await response.text();
63
    throw new Error(`${response.status} ${text}`);
64
  }
65
  return await response.json();
66
}
67