0

Create a product

by
Published Oct 17, 2025

Create a new product.

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 a product
7
 * Create a new product.
8
 */
9
export async function main(
10
  auth: Zoho,
11
  X_com_zoho_subscriptions_organizationid: string,
12
  body: {
13
    name: string;
14
    description?: string;
15
    email_ids?: string;
16
    redirect_url?: string;
17
  },
18
) {
19
  const url = new URL(`https://www.zohoapis.com/billing/v1/products`);
20

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