0
List User Busy Times
One script reply has been approved by the moderators Verified

Returns an ascending list of user internal and external scheduled events within a specified date range.

Date range can be no greater than 1 week (7 days).

NOTE:

  • This endpoint does not support traditional keyset pagination.
  • External events will only be returned for calendars that have "Check for conflicts" configured.
Created by hugo697 16 days ago Viewed 0 times
0
Submitted by hugo697 Bun
Verified 16 days ago
1
//native
2
type Calendly = {
3
	token: string
4
}
5

6
export async function main(
7
	auth: Calendly,
8
	user: string | undefined,
9
	start_time: string | undefined,
10
	end_time: string | undefined
11
) {
12
	const url = new URL(`https://api.calendly.com/user_busy_times`)
13

14
	for (const [k, v] of [
15
		['user', user],
16
		['start_time', start_time],
17
		['end_time', end_time]
18
	]) {
19
		if (v !== undefined && k !== undefined) {
20
			url.searchParams.append(k, v)
21
		}
22
	}
23

24
	const response = await fetch(url, {
25
		method: 'GET',
26
		headers: {
27
			Authorization: 'Bearer ' + auth.token
28
		},
29
		body: undefined
30
	})
31

32
	if (!response.ok) {
33
		const text = await response.text()
34
		throw new Error(`${response.status} ${text}`)
35
	}
36

37
	return await response.json()
38
}
39