0

List of shifts

by
Published Oct 17, 2025

Retrieve a paginated list of shifts with details such as start and end times, breaks, metadata, and summary metrics. Supports pagination through `limit` and `offset` query parameters and filtering by `contractId`, date range (`fromDate` and `toDate`). **Token scopes**: `time-tracking:read`

Script deel Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
/**
3
 * List of shifts
4
 * Retrieve a paginated list of shifts with details such as start and end times, breaks, metadata, and summary metrics. Supports pagination through `limit` and `offset` query parameters and filtering by `contractId`, date range (`fromDate` and `toDate`).
5
 **Token scopes**: `time-tracking:read`
6
 */
7
export async function main(
8
	auth: RT.Deel,
9
	limit?: string | undefined,
10
	offset?: string | undefined,
11
	from_date?: string | undefined,
12
	to_date?: string | undefined,
13
	contract_id__?: string | undefined
14
) {
15
	const url = new URL(`https://api.letsdeel.com/rest/v2/time_tracking/shifts`)
16
	for (const [k, v] of [
17
		['limit', limit],
18
		['offset', offset],
19
		['from_date', from_date],
20
		['to_date', to_date],
21
		['contract_id[]', contract_id__]
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