0

Estimate Future Time Off Balances

by
Published Oct 17, 2025

This endpoint will sum future time off accruals, scheduled time off, and carry-over events to produce estimates for the anticipated time off balance on a given date in the future.

Script bamboo_hr Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
/**
3
 * Estimate Future Time Off Balances
4
 * This endpoint will sum future time off accruals, scheduled time off, and carry-over events to produce estimates for the anticipated time off balance on a given date in the future.
5
 */
6
export async function main(
7
	auth: RT.BambooHr,
8
	employeeId: string,
9
	end: string | undefined,
10
	AcceptHeaderParameter?: string
11
) {
12
	const url = new URL(
13
		`https://${auth.companyDomain}.bamboohr.com/api/v1/employees/${employeeId}/time_off/calculator`
14
	)
15
	for (const [k, v] of [['end', end]]) {
16
		if (v !== undefined && v !== '') {
17
			url.searchParams.append(k, v)
18
		}
19
	}
20
	const response = await fetch(url, {
21
		method: 'GET',
22
		headers: {
23
			...(AcceptHeaderParameter ? { AcceptHeaderParameter: AcceptHeaderParameter } : {}),
24
			Authorization: 'Basic ' + btoa(`${auth.apiKey}:x`)
25
		},
26
		body: undefined
27
	})
28
	if (!response.ok) {
29
		const text = await response.text()
30
		throw new Error(`${response.status} ${text}`)
31
	}
32
	return await response.json()
33
}
34