0

Create a parent worker relation with external id

by
Published Oct 17, 2025

Create a parent worker relation with external id. **Token scopes**: `profile:write`

Script deel Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
/**
3
 * Create a parent worker relation with external id
4
 * Create a parent worker relation with external id.
5
 **Token scopes**: `profile:write`
6
 */
7
export async function main(auth: RT.Deel, hrisProfileExternalId: string, body: Body) {
8
	const url = new URL(
9
		`https://api.letsdeel.com/rest/v2/hris/worker_relations/profile/external/${hrisProfileExternalId}/parent`
10
	)
11

12
	const response = await fetch(url, {
13
		method: 'PUT',
14
		headers: {
15
			'Content-Type': 'application/json',
16
			Authorization: 'Bearer ' + auth.apiKey
17
		},
18
		body: JSON.stringify(body)
19
	})
20
	if (!response.ok) {
21
		const text = await response.text()
22
		throw new Error(`${response.status} ${text}`)
23
	}
24
	return await response.json()
25
}
26

27
/* eslint-disable */
28
/**
29
 * This file was automatically generated by json-schema-to-typescript.
30
 * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
31
 * and run json-schema-to-typescript to regenerate this file.
32
 */
33

34
export interface Body {
35
	data?: {
36
		edit_reason?: {
37
			/**
38
			 * The reason for the edit
39
			 */
40
			reason_oid: string
41
			/**
42
			 * Additional information about the edit
43
			 */
44
			additional_info?: string
45
			[k: string]: unknown
46
		}
47
		/**
48
		 * The external id of the relation
49
		 */
50
		relation_external_id?: string
51
		/**
52
		 * The external id of the parent profile
53
		 */
54
		parent_profile_external_id?: string
55
		/**
56
		 * The external id of the relationship type
57
		 */
58
		hris_relationship_type_external_id?: string
59
		[k: string]: unknown
60
	}
61
	[k: string]: unknown
62
}
63