0

Initiate EOR contract termination request

by
Published Oct 17, 2025

Enables clients to initiate a request for the termination of an Employee of Record (EOR) contract for members of their team. **Token scopes**: `contracts:write`

Script deel Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
/**
3
 * Initiate EOR contract termination request
4
 * Enables clients to initiate a request for the termination of an Employee of Record (EOR) contract for members of their team.
5
 **Token scopes**: `contracts:write`
6
 */
7
export async function main(auth: RT.Deel, contract_id: string, body: Body) {
8
	const url = new URL(
9
		`https://api.letsdeel.com/rest/v2/eor/contracts/${contract_id}/offboarding/termination`
10
	)
11

12
	const formData = new FormData()
13
	for (const [k, v] of Object.entries(body)) {
14
		if (v !== undefined && v !== '') {
15
			formData.append(k, String(v))
16
		}
17
	}
18
	const response = await fetch(url, {
19
		method: 'POST',
20
		headers: {
21
			Authorization: 'Bearer ' + auth.apiKey
22
		},
23
		body: formData
24
	})
25
	if (!response.ok) {
26
		const text = await response.text()
27
		throw new Error(`${response.status} ${text}`)
28
	}
29
	return await response.json()
30
}
31

32
/* eslint-disable */
33
/**
34
 * This file was automatically generated by json-schema-to-typescript.
35
 * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
36
 * and run json-schema-to-typescript to regenerate this file.
37
 */
38

39
export interface Body {
40
	data: {
41
		/**
42
		 * Reason why the contract is being terminated
43
		 */
44
		reason:
45
			| 'DEEL_COLLECTIONS'
46
			| 'STATUS_CHANGE'
47
			| 'RELOCATION'
48
			| 'COMPENSATION'
49
			| 'RETIREMENT'
50
			| 'JOB_ABANDONMENT'
51
			| 'WORK_RELATED'
52
			| 'PERSONAL'
53
			| 'OTHER_OPPORTUNITY'
54
			| 'NON_RENEWAL'
55
			| 'PROBATION'
56
			| 'ASSIGNMENT_ENDED'
57
			| 'POSITION_ELIMINATION'
58
			| 'FORCE_REDUCTION'
59
			| 'DEATH'
60
			| 'FOR_CAUSE'
61
			| 'PERFORMANCE'
62
			| 'MEDICAL'
63
			| 'PERFORMANCE_ISSUES'
64
			| 'ATTENDANCE_ISSUES'
65
			| 'REORGANIZATION_DOWNSIZING_BUDGET_OR_REDUCTION_OF_WORKFORCE'
66
			| 'ROLE_BECAME_REDUNDANT_OR_ROLE_CHANGED'
67
			| 'OFFER_WAS_REVOKED'
68
			| 'EXITING_THE_MARKET'
69
			| 'NO_LONGER_WISH_TO_WORK_WITH_DEEL'
70
			| 'COMPANY_ACQUIRED'
71
			| 'STEALING'
72
			| 'MISCONDUCT'
73
			| 'FALSIFYING'
74
			| 'HARASSMENT'
75
			| 'VIOLENCE'
76
			| 'REORGANIZATION_DOWNSIZING_BUDGET_OR_REDUCTION_OF_WORKFORCE_OR_ROLE_BECAME_REDUNDANT_OR_ROLE_CHANGED'
77
			| 'UNAUTHORIZED_ABSENCES_OR_LACK_OF_ATTENDANCE'
78
			| 'STANDARD_RESELLER_PRACTICE'
79
			| 'MOVING_EMPLOYEE_TO_INTERNAL_ENTITY'
80
			| 'MOVING_EMPLOYEE_TO_DEEL_PEO'
81
			| 'OTHER'
82
		/**
83
		 * This field allows for uploading multiple files at once. Attach any document that is important for the request to terminate the contract. Includes common image formats (JPG, JPEG, PNG, HEIC) and PDF documents.
84
		 */
85
		attachments?: string
86
		/**
87
		 * Defines whether the termination is sensitive. In this case, only the person requesting the termination will be able to view the termination, receive emails or notifications.
88
		 */
89
		is_sensitive?: boolean
90
		/**
91
		 * Field to better explain how communication with the employee will be and/or their reaction to the communication, or other necessary information
92
		 */
93
		reason_detail: string
94
		used_time_off: {
95
			/**
96
			 * Type of time off tracking - whether it's tracked on Deel platform or off platform
97
			 */
98
			tracking_type?: 'ON_PLATFORM' | 'OFF_PLATFORM'
99
			/**
100
			 * Required when tracking_type is OFF_PLATFORM, null otherwise
101
			 */
102
			off_platform_used_time_off?: {
103
				/**
104
				 * Array of time off entitlements for different tracking periods
105
				 */
106
				entitlements: {
107
					/**
108
					 * Amount of time off used in the period
109
					 */
110
					used: number
111
					/**
112
					 * Start date of the tracking period
113
					 */
114
					tracking_period: string
115
					/**
116
					 * End date of the tracking period
117
					 */
118
					tracking_period_end_date: string
119
					[k: string]: unknown
120
				}[]
121
				/**
122
				 * Total amount of time off scheduled until the end date
123
				 */
124
				total_scheduled: number
125
				/**
126
				 * Unit of measurement for the time off entitlements
127
				 */
128
				entitlement_unit: 'BUSINESS_DAY' | 'CALENDAR_DAY' | 'HOUR' | 'WEEK' | 'MONTH' | 'YEAR'
129
				[k: string]: unknown
130
			}
131
			[k: string]: unknown
132
		}
133
		/**
134
		 * The type of severance selected by the client. It's an optional field
135
		 */
136
		severance_type?: 'DAYS' | 'WEEKS' | 'MONTHS' | 'CASH'
137
		/**
138
		 * The desired end date of the contract. If the date is not provided, Deel HRX team will select the nearest possible date.
139
		 */
140
		desired_end_date?: string
141
		/**
142
		 * The amount of severance needed
143
		 */
144
		severance_amount?: number
145
		/**
146
		 * An additional reason can be provided in case the reason selected is NO_LONGER_WISH_TO_WORK_WITH_DEEL
147
		 */
148
		additional_reason?:
149
			| 'DISSATISFIED_WITH_DEEL_SERVICE'
150
			| 'DISSATISFIED_WITH_DEEL_PRICING'
151
			| 'DISSATISFIED_WITH_DEEL_PRODUCT'
152
		/**
153
		 * Additional notes can be provided regarding the termination for Deel, like questions and doubts
154
		 */
155
		termination_notes?: string[]
156
		/**
157
		 * Parameter to inform whether it would be possible for the client to hire the employee again
158
		 */
159
		eligible_for_rehire?: 'YES' | 'NO' | 'DONT_KNOW'
160
		/**
161
		 * Defines if employee was informed by client or not before the termination
162
		 */
163
		is_employee_notified: boolean
164
		/**
165
		 * For some countries some data is needed to help to process the termination. The questions comes from another endpoint to get the required information. See GET /eor/:oid/offboarding/required-information to get the questions.
166
		 */
167
		required_information?: {
168
			/**
169
			 * The answer to the question
170
			 */
171
			answer: boolean
172
			/**
173
			 * The question to be answered
174
			 */
175
			question: string
176
			[k: string]: unknown
177
		}[]
178
		/**
179
		 * Termination impact data if there is some configured on HR module
180
		 */
181
		termination_impact_id?: string
182
		/**
183
		 * If it's an termination contract ending and employee was already informed, should detail the notification to the employee
184
		 */
185
		employee_notification_detail?: string
186
		/**
187
		 * This field allows for uploading multiple files at once. Any proof such as correspondence, documentation of previous warnings or attendance records for the reason select above. Includes common image formats (JPG, JPEG, PNG, HEIC) and PDF documents.
188
		 */
189
		additional_supporting_documents?: string
190
		[k: string]: unknown
191
	}
192
	[k: string]: unknown
193
}
194