0

List Employee Trainings

by
Published Oct 17, 2025

Get all employee training records. The owner of the API key used must have access to view the employee. The API will only return trainings for the employee that the owner of the API key has permission to see. Included with each employee training is the training information that has been selected for tracking in settings.

Script bamboo_hr Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
/**
3
 * List Employee Trainings
4
 * Get all employee training records. The owner of the API key used must have access to view the employee. The API will only return trainings for the employee that the owner of the API key has permission to see. Included with each employee training is the training information that has been selected for tracking in settings.
5
 */
6
export async function main(
7
	auth: RT.BambooHr,
8
	employeeId: string = '0',
9
	trainingTypeId?: string | undefined
10
) {
11
	const url = new URL(
12
		`https://${auth.companyDomain}.bamboohr.com/api/v1/training/record/employee/${employeeId}`
13
	)
14
	for (const [k, v] of [['trainingTypeId', trainingTypeId]]) {
15
		if (v !== undefined && v !== '') {
16
			url.searchParams.append(k, v)
17
		}
18
	}
19
	const response = await fetch(url, {
20
		method: 'GET',
21
		headers: {
22
			Authorization: 'Basic ' + btoa(`${auth.apiKey}:x`)
23
		},
24
		body: undefined
25
	})
26
	if (!response.ok) {
27
		const text = await response.text()
28
		throw new Error(`${response.status} ${text}`)
29
	}
30
	return await response.json()
31
}
32