0

Update a shift

by
Published Oct 17, 2025

Update specific fields of an existing shift by its unique `external_id`. This includes shift summary details, description etc. **Token scopes**: `time-tracking:write`

Script deel Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
/**
3
 * Update a shift
4
 * Update specific fields of an existing shift by its unique `external_id`. This includes shift summary details, description etc.
5
 **Token scopes**: `time-tracking:write`
6
 */
7
export async function main(auth: RT.Deel, external_id: string, body: Body) {
8
	const url = new URL(`https://api.letsdeel.com/rest/v2/time_tracking/shifts/${external_id}`)
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
		summary?: {
35
			/**
36
			 * Time unit
37
			 */
38
			time_unit?: 'HOUR' | 'DAY' | 'WEEK' | 'MONTH'
39
			/**
40
			 * Time amount
41
			 */
42
			time_amount?: number
43
			/**
44
			 * Total break hours
45
			 */
46
			total_break_hours?: number
47
			/**
48
			 * Payable break hours
49
			 */
50
			payable_break_hours?: number
51
			/**
52
			 * Total payable hours
53
			 */
54
			total_payable_hours?: number
55
			/**
56
			 * Shift duration hours
57
			 */
58
			shift_duration_hours?: number
59
			/**
60
			 * Shift Rate external ID
61
			 */
62
			shift_rate_external_id?: string
63
			[k: string]: unknown
64
		}
65
		/**
66
		 * Description of the shift.
67
		 */
68
		description?: string
69
		/**
70
		 * The date of the shift.
71
		 */
72
		date_of_work?: string
73
		payroll_cycle_ref?: {
74
			/**
75
			 * Date in ISO 8601 format that helps referencing a payroll cycle
76
			 */
77
			date: string
78
			[k: string]: unknown
79
		}
80
		[k: string]: unknown
81
	}
82
	[k: string]: unknown
83
}
84