0

Update custom field value

by
Published Oct 17, 2025

Update custom field value. **Token scopes**: `people:write`

Script deel Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
/**
3
 * Update custom field value
4
 * Update custom field value.
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/people/${worker_id}/custom_fields`)
9

10
	const response = await fetch(url, {
11
		method: 'PUT',
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.text()
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
		 * UUID for the custom field value
36
		 */
37
		id: string
38
		data:
39
			| {
40
					/**
41
					 * Text type
42
					 */
43
					value?: string
44
					[k: string]: unknown
45
			  }
46
			| {
47
					/**
48
					 * Number type
49
					 */
50
					value?: number
51
					[k: string]: unknown
52
			  }
53
			| {
54
					/**
55
					 * Date type: YYYY-MM-DD
56
					 */
57
					value?: string
58
					[k: string]: unknown
59
			  }
60
			| {
61
					/**
62
					 * Percentage type
63
					 */
64
					value?: number
65
					[k: string]: unknown
66
			  }
67
			| {
68
					amount?: number
69
					/**
70
					 * Important: When currency type is fixed, the currency field is ignored.
71
					 */
72
					currency?: string
73
					[k: string]: unknown
74
			  }
75
			| {
76
					/**
77
					 * Option type
78
					 */
79
					option?: string
80
					[k: string]: unknown
81
			  }
82
			| {
83
					options?: string[]
84
					[k: string]: unknown
85
			  }
86
		[k: string]: unknown
87
	}
88
	[k: string]: unknown
89
}
90