0

Gets all updated employee IDs

by
Published Oct 17, 2025

This API allows for efficient syncing of employee data. When you use this API you will provide a timestamp and the results will be limited to just the employees that have changed since the time you provided. This API operates on an employee-last-changed-timestamp, which means that a change in ANY individual field in the employee record, as well as any change to the employment status, job info, or compensation tables, will cause that employee to be returned via this API.

Script bamboo_hr Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
/**
3
 * Gets all updated employee IDs
4
 * This API allows for efficient syncing of employee data. When you use this API you will provide a timestamp and the results will be limited to just the employees that have changed since the time you provided. This API operates on an employee-last-changed-timestamp, which means that a change in ANY individual field in the employee record, as well as any change to the employment status, job info, or compensation tables, will cause that employee to be returned via this API.
5
 */
6
export async function main(
7
	auth: RT.BambooHr,
8
	since: string | undefined,
9
	_type?: string | undefined
10
) {
11
	const url = new URL(`https://${auth.companyDomain}.bamboohr.com/api/v1/employees/changed`)
12
	for (const [k, v] of [
13
		['since', since],
14
		['type', _type]
15
	]) {
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
			Authorization: 'Basic ' + btoa(`${auth.apiKey}:x`)
24
		},
25
		body: undefined
26
	})
27
	if (!response.ok) {
28
		const text = await response.text()
29
		throw new Error(`${response.status} ${text}`)
30
	}
31
	return await response.text()
32
}
33