0

Update user unavailability

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 user unavailability
7
 *
8
 */
9
export async function main(
10
  auth: Zoho,
11
  id: string,
12
  body: {
13
    users_unavailability: {
14
      service: string;
15
      title: string;
16
      all_day: false | true;
17
      tp_calendar_id: string;
18
      tp_event_id: string;
19
      comments: string;
20
      from: string;
21
      id: string;
22
      to: string;
23
      user: { name: string; id: string; zuid: string };
24
    }[];
25
  },
26
) {
27
  const url = new URL(
28
    `https://zohoapis.com/crm/v8/settings/users_unavailability/${id}`,
29
  );
30

31
  const response = await fetch(url, {
32
    method: "PUT",
33
    headers: {
34
      "Content-Type": "application/json",
35
      Authorization: "Zoho-oauthtoken " + auth.token,
36
    },
37
    body: JSON.stringify(body),
38
  });
39
  if (!response.ok) {
40
    const text = await response.text();
41
    throw new Error(`${response.status} ${text}`);
42
  }
43
  return await response.json();
44
}
45