Create Share
One script reply has been approved by the moderators Verified

Endpoint for our Customize Once and Share feature. This allows you to customize events for a specific invitee without needing to make an entirely new event type. This feature is only available for one-on-one event types. Note: Any parameter which is not provided in the request body will be copied from the target event type.

Created by hugo697 417 days ago
Submitted by hugo697 Bun
Verified 417 days ago
1
//native
2
type Calendly = {
3
	token: string
4
}
5

6
export async function main(
7
	auth: Calendly,
8
	body: {
9
		event_type: string
10
		name?: string
11
		duration?: number
12
		duration_options?: number[]
13
		period_type?: 'available_moving' | 'moving' | 'fixed' | 'unlimited'
14
		start_date?: string
15
		end_date?: string
16
		max_booking_time?: number
17
		hide_location?: false | true
18
		location_configurations?: {
19
			location?: string
20
			additional_info?: string
21
			phone_number?: string
22
			position?: number
23
			kind?:
24
				| 'physical'
25
				| 'ask_invitee'
26
				| 'custom'
27
				| 'outbound_call'
28
				| 'inbound_call'
29
				| 'google_conference'
30
				| 'gotomeeting_conference'
31
				| 'microsoft_teams_conference'
32
				| 'webex_conference'
33
				| 'zoom_conference'
34
		}[]
35
		availability_rule?: {
36
			rules?: {
37
				type?: 'wday' | 'date'
38
				wday?: 'sunday' | 'monday' | 'tuesday' | 'wednesday' | 'thursday' | 'friday' | 'saturday'
39
				date?: string
40
				intervals?: { from?: string; to?: string }[]
41
			}[]
42
			timezone?: string
43
		}
44
	}
45
) {
46
	const url = new URL(`https://api.calendly.com/shares`)
47

48
	const response = await fetch(url, {
49
		method: 'POST',
50
		headers: {
51
			'Content-Type': 'application/json',
52
			Authorization: 'Bearer ' + auth.token
53
		},
54
		body: JSON.stringify(body)
55
	})
56

57
	if (!response.ok) {
58
		const text = await response.text()
59
		throw new Error(`${response.status} ${text}`)
60
	}
61

62
	return await response.json()
63
}
64