0

Update PTO policy

by
Published Oct 17, 2025

Update the PTO policy of a Global Payroll employee. **Token scopes**: `people:write`

Script deel Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
/**
3
 * Update PTO policy
4
 * Update the PTO policy of a Global Payroll employee.
5
 **Token scopes**: `people:write`
6
 */
7
export async function main(auth: RT.Deel, worker_id: string, body: Body) {
8
	const url = new URL(`https://api.letsdeel.com/rest/v2/gp/workers/${worker_id}/pto-policy`)
9

10
	const response = await fetch(url, {
11
		method: 'PATCH',
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
	data: {
34
		/**
35
		 * Enter the number of holidays. Example: '15' for 15 days.
36
		 */
37
		yearly_allowance: string
38
		/**
39
		 * Short date in format ISO-8601 (YYYY-MM-DD). For example: '2022-12-31'.
40
		 */
41
		accrual_start_date: string
42
		[k: string]: unknown
43
	}
44
	[k: string]: unknown
45
}
46