0

Update raw shift

by
Published Oct 17, 2025

Update specific fields of an existing raw shift by its unique `external_id`. This includes shift meta 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 raw shift
4
 * Update specific fields of an existing raw shift by its unique `external_id`. This includes shift meta 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/raw/${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
		meta?: {
35
			end?: {
36
				/**
37
				 * End date
38
				 */
39
				date?: string
40
				/**
41
				 * End time
42
				 */
43
				time?: string
44
				/**
45
				 * Is rest day
46
				 */
47
				is_rest_day?: boolean
48
				/**
49
				 * Is public holiday
50
				 */
51
				is_public_holiday?: boolean
52
				[k: string]: unknown
53
			}
54
			start?: {
55
				/**
56
				 * Start date
57
				 */
58
				date?: string
59
				/**
60
				 * Start time
61
				 */
62
				time?: string
63
				/**
64
				 * Is rest day
65
				 */
66
				is_rest_day?: boolean
67
				/**
68
				 * Is public holiday
69
				 */
70
				is_public_holiday?: boolean
71
				[k: string]: unknown
72
			}
73
			breaks?: {
74
				end?: {
75
					/**
76
					 * Break end date
77
					 */
78
					date?: string
79
					/**
80
					 * Break end time
81
					 */
82
					time?: string
83
					[k: string]: unknown
84
				}
85
				start?: {
86
					/**
87
					 * Break start date
88
					 */
89
					date?: string
90
					/**
91
					 * Break start time
92
					 */
93
					time?: string
94
					[k: string]: unknown
95
				}
96
				/**
97
				 * Is break paid
98
				 */
99
				is_paid?: boolean
100
				[k: string]: unknown
101
			}[]
102
			/**
103
			 * Approval date
104
			 */
105
			approval_date?: string
106
			[k: string]: unknown
107
		}
108
		/**
109
		 * Description of the shift.
110
		 */
111
		description?: string
112
		/**
113
		 * The date of the shift.
114
		 */
115
		date_of_work?: string
116
		[k: string]: unknown
117
	}
118
	[k: string]: unknown
119
}
120