0

Change to Online/Offline mode

by
Published Oct 17, 2025

Change the status of a particular subscription to Online/Offline mode. If auto_collect is false, the subscription is in Offline mode. If auto_collect is true, the subscription is in Online mode.

Script zoho Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Zoho = {
3
  token: string;
4
};
5
/**
6
 * Change to Online/Offline mode
7
 * Change the status of a particular subscription to Online/Offline mode. If auto_collect is false, the subscription is in Offline mode. If auto_collect is true, the subscription is in Online mode.
8
 */
9
export async function main(
10
  auth: Zoho,
11
  subscription_id: string,
12
  X_com_zoho_subscriptions_organizationid: string,
13
  body: { auto_collect: {} },
14
) {
15
  const url = new URL(
16
    `https://www.zohoapis.com/billing/v1/subscriptions/${subscription_id}/autocollect`,
17
  );
18

19
  const response = await fetch(url, {
20
    method: "POST",
21
    headers: {
22
      "X-com-zoho-subscriptions-organizationid":
23
        X_com_zoho_subscriptions_organizationid,
24
      "Content-Type": "application/json",
25
      Authorization: "Zoho-oauthtoken " + auth.token,
26
    },
27
    body: JSON.stringify(body),
28
  });
29
  if (!response.ok) {
30
    const text = await response.text();
31
    throw new Error(`${response.status} ${text}`);
32
  }
33
  return await response.json();
34
}
35