0

Retrieve Benefits by Country

by
Published Oct 17, 2025

Retrieves list of benefits available in a specific country based work visa requirement, work hours, employment type, team, and legal entity. **Token scopes**: `benefits:read`

Script deel Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
/**
3
 * Retrieve Benefits by Country
4
 * Retrieves list of benefits available in a specific country based work visa requirement, work hours, employment type, team, and legal entity.
5
 **Token scopes**: `benefits:read`
6
 */
7
export async function main(
8
	auth: RT.Deel,
9
	country_code: string | undefined,
10
	work_visa: string | undefined,
11
	work_hours_per_week: string | undefined,
12
	employment_type: 'Full-time' | 'Part-time' | undefined,
13
	team_id: string | undefined,
14
	legal_entity_id: string | undefined
15
) {
16
	const url = new URL(`https://api.letsdeel.com/rest/v2/eor/benefits`)
17
	for (const [k, v] of [
18
		['country_code', country_code],
19
		['work_visa', work_visa],
20
		['work_hours_per_week', work_hours_per_week],
21
		['employment_type', employment_type],
22
		['team_id', team_id],
23
		['legal_entity_id', legal_entity_id]
24
	]) {
25
		if (v !== undefined && v !== '') {
26
			url.searchParams.append(k, v)
27
		}
28
	}
29
	const response = await fetch(url, {
30
		method: 'GET',
31
		headers: {
32
			Authorization: 'Bearer ' + auth.apiKey
33
		},
34
		body: undefined
35
	})
36
	if (!response.ok) {
37
		const text = await response.text()
38
		throw new Error(`${response.status} ${text}`)
39
	}
40
	return await response.json()
41
}
42