0

Approve/Reject time-off requests

by
Published Oct 17, 2025

Approve/Reject time-off requests in batch. The request body should contain a list of time-off IDs and the desired status (either APPROVED or REJECTED). The response will indicate which requests were successfully processed and which ones encountered... **Token scopes**: `time-off:write`

Script deel Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
/**
3
 * Approve/Reject time-off requests
4
 * Approve/Reject time-off requests in batch. The request body should contain a list of time-off IDs and the desired status (either APPROVED or REJECTED). The response will indicate which requests were successfully processed and which ones encountered...
5
 **Token scopes**: `time-off:write`
6
 */
7
export async function main(auth: RT.Deel, body: Body) {
8
	const url = new URL(`https://api.letsdeel.com/rest/v2/time_offs/review`)
9

10
	const response = await fetch(url, {
11
		method: 'POST',
12
		headers: {
13
			'Content-Type': 'application/json',
14
			Authorization: 'Bearer ' + auth.apiKey
15
		},
16
		body: JSON.stringify(body)
17
	})
18
	if (!response.ok) {
19
		const text = await response.text()
20
		throw new Error(`${response.status} ${text}`)
21
	}
22
	return await response.json()
23
}
24

25
/* eslint-disable */
26
/**
27
 * This file was automatically generated by json-schema-to-typescript.
28
 * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
29
 * and run json-schema-to-typescript to regenerate this file.
30
 */
31

32
export interface Body {
33
	/**
34
	 * Array of time-offs to be reviewed
35
	 *
36
	 * @minItems 1
37
	 * @maxItems 100
38
	 */
39
	data: {
40
		/**
41
		 * Time off id
42
		 */
43
		id: string
44
		/**
45
		 * Decision on whether the time off request was approved or rejected
46
		 */
47
		status: 'APPROVED' | 'REJECTED'
48
		[k: string]: unknown
49
	}[]
50
	[k: string]: unknown
51
}
52