0

Update 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
 * Update holidays
7
 *
8
 */
9
export async function main(
10
  auth: Zoho,
11
  body: {
12
    holidays?: {
13
      year: number;
14
      name: string;
15
      date: string;
16
      type: string;
17
      id: string;
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: "PUT",
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