0

Get company report

by
Published Oct 17, 2025

**Warning: This endpoint will soon be deprecated and replaced with Custom Reports - Get Report by ID.

Script bamboo_hr Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
/**
3
 * Get company report
4
 * **Warning: This endpoint will soon be deprecated and replaced with Custom Reports - Get Report by ID.
5
 */
6
export async function main(
7
	auth: RT.BambooHr,
8
	id: string,
9
	format: string | undefined,
10
	fd?: string | undefined,
11
	onlyCurrent?: string | undefined,
12
	AcceptHeaderParameter?: string
13
) {
14
	const url = new URL(`https://${auth.companyDomain}.bamboohr.com/api/v1/reports/${id}`)
15
	for (const [k, v] of [
16
		['format', format],
17
		['fd', fd],
18
		['onlyCurrent', onlyCurrent]
19
	]) {
20
		if (v !== undefined && v !== '') {
21
			url.searchParams.append(k, v)
22
		}
23
	}
24
	const response = await fetch(url, {
25
		method: 'GET',
26
		headers: {
27
			...(AcceptHeaderParameter ? { AcceptHeaderParameter: AcceptHeaderParameter } : {}),
28
			Authorization: 'Basic ' + btoa(`${auth.apiKey}:x`)
29
		},
30
		body: undefined
31
	})
32
	if (!response.ok) {
33
		const text = await response.text()
34
		throw new Error(`${response.status} ${text}`)
35
	}
36
	return await response.json()
37
}
38