0

Get verification method

by
Published Oct 17, 2025

Get verification method by provided country and document type **Token scopes**: `screenings:read`, `worker:read`

Script deel Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
/**
3
 * Get verification method
4
 * Get verification method by provided country and document type
5
 **Token scopes**: `screenings:read`, `worker:read`
6
 */
7
export async function main(
8
	auth: RT.Deel,
9
	country: string | undefined,
10
	document_type: 'passport' | 'government_id' | 'driving_license' | 'other' | undefined
11
) {
12
	const url = new URL(`https://api.letsdeel.com/rest/v2/screenings/verification-method`)
13
	for (const [k, v] of [
14
		['country', country],
15
		['document_type', document_type]
16
	]) {
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