0

Get Time Off Events for Profile

by
Published Oct 17, 2025

List time off events for profile **Token scopes**: `time-off:read`

Script deel Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
/**
3
 * Get Time Off Events for Profile
4
 * List time off events for profile
5
 **Token scopes**: `time-off:read`
6
 */
7
export async function main(
8
	auth: RT.Deel,
9
	hris_profile_id: string | undefined,
10
	time_off_type_id?: string | undefined,
11
	policy_id?: string | undefined
12
) {
13
	const url = new URL(`https://api.letsdeel.com/rest/v2/time_offs/time-off-events`)
14
	for (const [k, v] of [
15
		['hris_profile_id', hris_profile_id],
16
		['time_off_type_id', time_off_type_id],
17
		['policy_id', policy_id]
18
	]) {
19
		if (v !== undefined && v !== '') {
20
			url.searchParams.append(k, v)
21
		}
22
	}
23
	const response = await fetch(url, {
24
		method: 'GET',
25
		headers: {
26
			Authorization: 'Bearer ' + auth.apiKey
27
		},
28
		body: undefined
29
	})
30
	if (!response.ok) {
31
		const text = await response.text()
32
		throw new Error(`${response.status} ${text}`)
33
	}
34
	return await response.json()
35
}
36