Creates a single-use scheduling link.
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