0

Create holidays

by
Published Oct 17, 2025
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 holidays
7
 *
8
 */
9
export async function main(
10
  auth: Zoho,
11
  body:
12
    | { holidays: { name?: string; date?: string; type?: string }[] }
13
    | {
14
        holidays: {
15
          name?: string;
16
          date?: string;
17
          type?: "shift_holiday";
18
          shift_hour?: { name: string; id: string };
19
        }[];
20
      },
21
  X_CRM_ORG?: string,
22
) {
23
  const url = new URL(`https://zohoapis.com/crm/v8/settings/holidays`);
24

25
  const response = await fetch(url, {
26
    method: "POST",
27
    headers: {
28
      ...(X_CRM_ORG ? { "X-CRM-ORG": X_CRM_ORG } : {}),
29
      "Content-Type": "application/json",
30
      Authorization: "Zoho-oauthtoken " + auth.token,
31
    },
32
    body: JSON.stringify(body),
33
  });
34
  if (!response.ok) {
35
    const text = await response.text();
36
    throw new Error(`${response.status} ${text}`);
37
  }
38
  return await response.json();
39
}
40