0

Delete a plan

by
Published Oct 17, 2025

Delete an existing plan. A plan can only be deleted if it has no transactions associated with it.

Script zoho Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Zoho = {
3
  token: string;
4
};
5
/**
6
 * Delete a plan
7
 * Delete an existing plan. A plan can only be deleted if it has no transactions associated with it.
8
 */
9
export async function main(
10
  auth: Zoho,
11
  plan_code: string,
12
  X_com_zoho_subscriptions_organizationid: string,
13
) {
14
  const url = new URL(`https://www.zohoapis.com/billing/v1/plans/${plan_code}`);
15

16
  const response = await fetch(url, {
17
    method: "DELETE",
18
    headers: {
19
      "X-com-zoho-subscriptions-organizationid":
20
        X_com_zoho_subscriptions_organizationid,
21
      Authorization: "Zoho-oauthtoken " + auth.token,
22
    },
23
    body: undefined,
24
  });
25
  if (!response.ok) {
26
    const text = await response.text();
27
    throw new Error(`${response.status} ${text}`);
28
  }
29
  return await response.json();
30
}
31