0

Get employee from organization integrated with external benefits vendor

by
Published Oct 17, 2025

Get employee from organization integrated with external benefits vendor **Token scopes**: `people:read`

Script deel Verified

The script

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