0

Create an addon

by
Published Oct 17, 2025

Create a new 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
 * Create an addon
7
 * Create a new addon.
8
 */
9
export async function main(
10
  auth: Zoho,
11
  X_com_zoho_subscriptions_organizationid: string,
12
  body:
13
    | {
14
        addon_code: string;
15
        name: string;
16
        unit_name: string;
17
        pricing_scheme?: {};
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 }[];
29
        product_id: string;
30
        description?: string;
31
        store_markup_description?: string;
32
        tax_id?: string;
33
        product_type?: string;
34
        hsn_or_sac?: string;
35
        sat_item_key_code?: string;
36
        unitkey_code?: string;
37
        item_tax_preferences?: {
38
          tax_specification?: string;
39
          tax_name?: string;
40
          tax_percentage?: number;
41
          tax_id?: string;
42
        }[];
43
        tax_exemption_id?: string;
44
        tax_exemption_code?: string;
45
      }
46
    | {
47
        addon_code: string;
48
        name: string;
49
        unit_name: string;
50
        pricing_scheme?: {};
51
        price_brackets: { end_quantity?: number; price?: number }[];
52
        type?: string;
53
        interval_unit?: string;
54
        tags?: { tag_id?: number; tag_option_id?: number }[];
55
        custom_fields?: { label?: string; value?: string }[];
56
        applicable_to_all_plans?: false | true;
57
        plans: { plan_code?: string }[];
58
        product_id: string;
59
        description?: string;
60
        store_markup_description?: string;
61
        product_type?: string;
62
        hsn_or_sac?: string;
63
        sat_item_key_code?: string;
64
        unitkey_code?: string;
65
        item_tax_preferences?: {
66
          tax_specification?: string;
67
          tax_name?: string;
68
          tax_percentage?: number;
69
          tax_id?: string;
70
        }[];
71
        tax_id?: string;
72
        tax_exemption_id?: string;
73
        tax_exemption_code?: string;
74
      }
75
    | {
76
        addon_code: string;
77
        name: string;
78
        unit_name: string;
79
        pricing_scheme?: {};
80
        price_brackets: { price?: number }[];
81
        type?: string;
82
        interval_unit?: string;
83
        tags?: { tag_id?: number; tag_option_id?: number }[];
84
        custom_fields?: { label?: string; value?: string }[];
85
        applicable_to_all_plans?: false | true;
86
        plans: { plan_code?: string }[];
87
        product_id: string;
88
        description?: string;
89
        store_markup_description?: string;
90
        product_type?: string;
91
        hsn_or_sac?: string;
92
        sat_item_key_code?: string;
93
        unitkey_code?: string;
94
        item_tax_preferences?: {
95
          tax_specification?: string;
96
          tax_name?: string;
97
          tax_percentage?: number;
98
          tax_id?: string;
99
        }[];
100
        tax_id?: string;
101
        tax_exemption_id?: string;
102
        tax_exemption_code?: string;
103
      }
104
    | {
105
        addon_code: string;
106
        name: string;
107
        unit_name: string;
108
        pricing_scheme?: {};
109
        price_brackets: {
110
          start_quantity?: number;
111
          end_quantity?: number;
112
          price?: number;
113
        }[];
114
        type?: string;
115
        interval_unit?: string;
116
        tags?: { tag_id?: number; tag_option_id?: number }[];
117
        custom_fields?: { label?: string; value?: string }[];
118
        applicable_to_all_plans?: false | true;
119
        plans: { plan_code?: string }[];
120
        product_id: string;
121
        description?: string;
122
        store_markup_description?: string;
123
        product_type?: string;
124
        hsn_or_sac?: string;
125
        sat_item_key_code?: string;
126
        unitkey_code?: string;
127
        item_tax_preferences?: {
128
          tax_specification?: string;
129
          tax_name?: string;
130
          tax_percentage?: number;
131
          tax_id?: string;
132
        }[];
133
        tax_id?: string;
134
        tax_exemption_id?: string;
135
        tax_exemption_code?: string;
136
      },
137
) {
138
  const url = new URL(`https://www.zohoapis.com/billing/v1/addons`);
139

140
  const response = await fetch(url, {
141
    method: "POST",
142
    headers: {
143
      "X-com-zoho-subscriptions-organizationid":
144
        X_com_zoho_subscriptions_organizationid,
145
      "Content-Type": "application/json",
146
      Authorization: "Zoho-oauthtoken " + auth.token,
147
    },
148
    body: JSON.stringify(body),
149
  });
150
  if (!response.ok) {
151
    const text = await response.text();
152
    throw new Error(`${response.status} ${text}`);
153
  }
154
  return await response.json();
155
}
156