0

Retrieve payment receipts

by
Published Oct 17, 2025

Retrieve a list of payments made to Deel, including worker details, payment status, and payment methods. **Token scopes**: `accounting:read`

Script deel Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
/**
3
 * Retrieve payment receipts
4
 * Retrieve a list of payments made to Deel, including worker details, payment status, and payment methods.
5
 **Token scopes**: `accounting:read`
6
 */
7
export async function main(
8
	auth: RT.Deel,
9
	date_from?: string | undefined,
10
	date_to?: string | undefined,
11
	currencies?: string | undefined,
12
	entities?: string | undefined,
13
	statuses?: string | undefined
14
) {
15
	const url = new URL(`https://api.letsdeel.com/rest/v2/payments`)
16
	for (const [k, v] of [
17
		['date_from', date_from],
18
		['date_to', date_to],
19
		['currencies', currencies],
20
		['entities', entities],
21
		['statuses', statuses]
22
	]) {
23
		if (v !== undefined && v !== '') {
24
			url.searchParams.append(k, v)
25
		}
26
	}
27
	const response = await fetch(url, {
28
		method: 'GET',
29
		headers: {
30
			Authorization: 'Bearer ' + auth.apiKey
31
		},
32
		body: undefined
33
	})
34
	if (!response.ok) {
35
		const text = await response.text()
36
		throw new Error(`${response.status} ${text}`)
37
	}
38
	return await response.json()
39
}
40