0

Get all countries

by
Published Oct 17, 2025

Get all available countries as options. Returns a list of countries with ID and name for use in forms and dropdowns.

Script bamboo_hr Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
/**
3
 * Get all countries
4
 * Get all available countries as options. Returns a list of countries with ID and name for use in forms and dropdowns.
5
 */
6
export async function main(auth: RT.BambooHr) {
7
	const url = new URL(`https://${auth.companyDomain}.bamboohr.com/api/v1/meta/countries/options`)
8

9
	const response = await fetch(url, {
10
		method: 'GET',
11
		headers: {
12
			Authorization: 'Basic ' + btoa(`${auth.apiKey}:x`)
13
		},
14
		body: undefined
15
	})
16
	if (!response.ok) {
17
		const text = await response.text()
18
		throw new Error(`${response.status} ${text}`)
19
	}
20
	return await response.json()
21
}
22