0
List Event Type Available Times
One script reply has been approved by the moderators Verified

Returns a list of available times for an event type 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.
Created by hugo697 2 days ago Viewed 0 times
0
Submitted by hugo697 Bun
Verified 2 days ago
1
//native
2
type Calendly = {
3
	token: string
4
}
5

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

14
	for (const [k, v] of [
15
		['event_type', event_type],
16
		['start_time', start_time],
17
		['end_time', end_time]
18
	]) {
19
		if (v !== undefined && v !== '' && 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