0
Create Single-Use Scheduling Link
One script reply has been approved by the moderators Verified

Creates a single-use scheduling link.

Created by hugo697 51 days ago Viewed 574 times
0
Submitted by hugo697 Bun
Verified 51 days ago
1
//native
2
type Calendly = {
3
	token: string
4
}
5

6
export async function main(
7
	auth: Calendly,
8
	body: { max_event_count: 1; owner: string; owner_type: 'EventType' }
9
) {
10
	const url = new URL(`https://api.calendly.com/scheduling_links`)
11

12
	const response = await fetch(url, {
13
		method: 'POST',
14
		headers: {
15
			'Content-Type': 'application/json',
16
			Authorization: 'Bearer ' + auth.token
17
		},
18
		body: JSON.stringify(body)
19
	})
20

21
	if (!response.ok) {
22
		const text = await response.text()
23
		throw new Error(`${response.status} ${text}`)
24
	}
25

26
	return await response.json()
27
}
28