0

Get Time Off Types

by
Published Oct 17, 2025

This endpoint gets a list of time off types.

Script bamboo_hr Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
/**
3
 * Get Time Off Types
4
 * This endpoint gets a list of time off types.
5
 */
6
export async function main(
7
	auth: RT.BambooHr,
8
	mode?: string | undefined,
9
	AcceptHeaderParameter?: string
10
) {
11
	const url = new URL(`https://${auth.companyDomain}.bamboohr.com/api/v1/meta/time_off/types`)
12
	for (const [k, v] of [['mode', mode]]) {
13
		if (v !== undefined && v !== '') {
14
			url.searchParams.append(k, v)
15
		}
16
	}
17
	const response = await fetch(url, {
18
		method: 'GET',
19
		headers: {
20
			...(AcceptHeaderParameter ? { AcceptHeaderParameter: AcceptHeaderParameter } : {}),
21
			Authorization: 'Basic ' + btoa(`${auth.apiKey}:x`)
22
		},
23
		body: undefined
24
	})
25
	if (!response.ok) {
26
		const text = await response.text()
27
		throw new Error(`${response.status} ${text}`)
28
	}
29
	return await response.json()
30
}
31