0

Retrieve a single person

by
Published Oct 17, 2025

Retrieve a single person in your organization. **Token scopes**: `people:read`

Script deel Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
/**
3
 * Retrieve a single person
4
 * Retrieve a single person in your organization.
5
 **Token scopes**: `people:read`
6
 */
7
export async function main(
8
	auth: RT.Deel,
9
	hrisProfileOid: string,
10
	include_custom_fields?: string | undefined,
11
	include_worker_relations?: string | undefined
12
) {
13
	const url = new URL(`https://api.letsdeel.com/rest/v2/people/${hrisProfileOid}`)
14
	for (const [k, v] of [
15
		['include_custom_fields', include_custom_fields],
16
		['include_worker_relations', include_worker_relations]
17
	]) {
18
		if (v !== undefined && v !== '') {
19
			url.searchParams.append(k, v)
20
		}
21
	}
22
	const response = await fetch(url, {
23
		method: 'GET',
24
		headers: {
25
			Authorization: 'Bearer ' + auth.apiKey
26
		},
27
		body: undefined
28
	})
29
	if (!response.ok) {
30
		const text = await response.text()
31
		throw new Error(`${response.status} ${text}`)
32
	}
33
	return await response.json()
34
}
35