0

Create Hourly Report Root Preset

by
Published Oct 17, 2025

Create a new hourly report root preset. **Token scopes**: `timesheets:write`

Script deel Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
/**
3
 * Create Hourly Report Root Preset
4
 * Create a new hourly report root preset.
5
 **Token scopes**: `timesheets:write`
6
 */
7
export async function main(auth: RT.Deel, body: Body) {
8
	const url = new URL(`https://api.letsdeel.com/rest/v2/timesheets/root-presets`)
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
	 * Optional file attachment for the root preset
35
	 */
36
	file?: string
37
	/**
38
	 * The type of preset, RATE – indicates a preset that overrides the default contract rate, TRACKING - used exclusively for tracking, applying the default contract rate
39
	 */
40
	type?: 'RATE' | 'TRACKING'
41
	/**
42
	 * The title of the hourly report root preset (maximum 255 characters)
43
	 */
44
	title: string
45
	/**
46
	 * Detailed description of the root preset's purpose and usage (maximum 30000 characters)
47
	 */
48
	description?: string
49
	/**
50
	 * Array of preset configurations to be created along with the root preset
51
	 */
52
	hourly_report_presets?: {
53
		/**
54
		 * Optional file attachment for this specific preset instance
55
		 */
56
		file?: string
57
		/**
58
		 * The hourly rate for this preset (must be greater than 0)
59
		 */
60
		rate?: number
61
		/**
62
		 * The title for this specific preset instance (maximum 255 characters)
63
		 */
64
		title?: string
65
		/**
66
		 * The action to perform with this preset (currently only ADD is supported)
67
		 */
68
		action_type?: 'ADD'
69
		/**
70
		 * The unique identifier of the contract this preset is associated with
71
		 */
72
		contract_id: string
73
		/**
74
		 * Detailed description for this specific preset instance (maximum 30000 characters)
75
		 */
76
		description?: string
77
		[k: string]: unknown
78
	}[]
79
	/**
80
	 * Determines whether presets should be processed synchronously or asynchronously
81
	 */
82
	hourly_report_presets_processing_type?: 'ASYNC' | 'SYNC'
83
	[k: string]: unknown
84
}
85