0

Create a new contract

by
Published Oct 17, 2025

Create a new Deel contract. **Token scopes**: `contracts:write`

Script deel Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
/**
3
 * Create a new contract
4
 * Create a new Deel contract.
5
 **Token scopes**: `contracts:write`
6
 */
7
export async function main(auth: RT.Deel, body: Body) {
8
	const url = new URL(`https://api.letsdeel.com/rest/v2/contracts`)
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 type PAY_AS_YOU_GO_TIME_BASED = {
33
	/**
34
	 * Additional custom info about a contract
35
	 */
36
	meta: {
37
		/**
38
		 * Flag to indicate if the contract is the main income for the contractor.
39
		 */
40
		is_main_income?: boolean
41
		/**
42
		 * Require the contractor to upload necessary compliance documents as per their country’s labor laws.
43
		 */
44
		documents_required: boolean
45
		[k: string]: unknown
46
	}
47
	/**
48
	 * The title of the contract.
49
	 */
50
	title: string
51
	client: {
52
		/**
53
		 * Choose the Deel team for this contract. Use teams endpoint to retrieve a list of teams in your organization.
54
		 */
55
		team: {
56
			/**
57
			 * Unique identifier of this resource.
58
			 */
59
			id: string | number
60
			[k: string]: unknown
61
		}
62
		/**
63
		 * Choose the Deel legal entity for this contract. Use legal entity endpoint to retrieve a list of legal entities in your organization.
64
		 */
65
		legal_entity: {
66
			/**
67
			 * Unique identifier of this resource.
68
			 */
69
			id: string | number
70
			[k: string]: unknown
71
		}
72
		[k: string]: unknown
73
	}
74
	/**
75
	 * Worker properties
76
	 */
77
	worker?: {
78
		/**
79
		 * Worker's last name
80
		 */
81
		last_name?: string
82
		/**
83
		 * Worker's first name
84
		 */
85
		first_name: string
86
		/**
87
		 * Worker's email address.
88
		 */
89
		expected_email: string
90
		[k: string]: unknown
91
	}
92
	/**
93
	 * Worker's job title. You can enter a custom job title or use a pre-defined job title using the Id retrieved in job-titles endpoint.
94
	 */
95
	job_title: {
96
		/**
97
		 * Unique identifier of this resource.
98
		 */
99
		id?: string | number
100
		/**
101
		 * Job title. Please leave it blank when entering an Id.
102
		 */
103
		name?: string
104
		[k: string]: unknown
105
	}
106
	/**
107
	 * Job seniority level. Please use the seniority levels endpoint to retrieve the list of seniority levels.
108
	 */
109
	seniority?: {
110
		/**
111
		 * Unique identifier of this resource.
112
		 */
113
		id?: string | number
114
		[k: string]: unknown
115
	}
116
	/**
117
	 * The state or province code. Use country lookup endpoint to retrieve state codes.
118
	 */
119
	state_code?: string
120
	/**
121
	 * External Id.
122
	 */
123
	external_id?: string
124
	/**
125
	 * Flag to indicate who is supposed to provide regular reports
126
	 */
127
	who_reports?: 'both' | 'client' | 'contractor'
128
	/**
129
	 * Country code.
130
	 */
131
	country_code?: string
132
	/**
133
	 * Days before to notice the termination of contract for either party.
134
	 */
135
	notice_period?: number
136
	/**
137
	 * Describe the work to be performed.
138
	 */
139
	scope_of_work?: string
140
	/**
141
	 * Enter any special clause you may have.
142
	 */
143
	special_clause?: string
144
	/**
145
	 * Short date in format ISO-8601 (YYYY-MM-DD). For example: 2022-12-31.
146
	 */
147
	termination_date?: string
148
	/**
149
	 * Contract Template Id.
150
	 */
151
	contract_template_id?: string
152
	[k: string]: unknown
153
} & {
154
	/**
155
	 * Type of contract
156
	 */
157
	type: 'pay_as_you_go_time_based'
158
	/**
159
	 * Short date in format ISO-8601 (YYYY-MM-DD). For example: 2022-12-31.
160
	 */
161
	start_date: string
162
	[k: string]: unknown
163
} & {
164
	compensation_details: {
165
		/**
166
		 * Amount to be paid. This field can be excluded when creating a Pay-as-you-go task-based or Milestone contracts.
167
		 */
168
		amount?: number
169
		/**
170
		 * Date invoice cycle ends.
171
		 */
172
		cycle_end: number
173
		/**
174
		 * Scale of the invoice cycle.
175
		 */
176
		frequency: 'weekly' | 'monthly' | 'biweekly' | 'semimonthly' | 'calendar-month'
177
		/**
178
		 * Currency code.
179
		 */
180
		currency_code: string
181
		/**
182
		 * First payment amount.
183
		 */
184
		first_payment?: number
185
		/**
186
		 * Days before to notice the termination of contract for either party.
187
		 */
188
		notice_period?: number
189
		/**
190
		 * Cycle end can be weekly 1-7 (Monday = 1) or monthly 1-31.
191
		 */
192
		cycle_end_type: 'DAY_OF_WEEK' | 'DAY_OF_LAST_WEEK' | 'DAY_OF_MONTH'
193
		/**
194
		 * Number of days to pay the invoice.
195
		 */
196
		payment_due_days: number
197
		/**
198
		 * Type of payment due. If the payment is due on the last day of month, enter 'WITHIN_MONTH'.
199
		 */
200
		payment_due_type: 'REGULAR' | 'WITHIN_MONTH'
201
		/**
202
		 * Short date in format ISO-8601 (YYYY-MM-DD). For example: 2022-12-31.
203
		 */
204
		first_payment_date?: string
205
		/**
206
		 * If the payment due is on a weekend, pay on Friday.
207
		 */
208
		pay_before_weekends?: boolean
209
		[k: string]: unknown
210
	} & {
211
		/**
212
		 * Defines the scale at which the amount is paid. For example, enter 'hourly' to define the amount per hour. This field can be excluded when creating a Pay-as-you-go task-based or Milestone contracts.
213
		 */
214
		scale: 'hourly' | 'daily' | 'weekly' | 'monthly' | 'biweekly' | 'semimonthly' | 'custom'
215
		/**
216
		 * Amount to be paid. This field can be excluded when creating a Pay-as-you-go task-based or Milestone contracts.
217
		 */
218
		amount: number
219
		[k: string]: unknown
220
	}
221
	[k: string]: unknown
222
}
223
export type PAYG_TASKS = {
224
	/**
225
	 * Additional custom info about a contract
226
	 */
227
	meta: {
228
		/**
229
		 * Flag to indicate if the contract is the main income for the contractor.
230
		 */
231
		is_main_income?: boolean
232
		/**
233
		 * Require the contractor to upload necessary compliance documents as per their country’s labor laws.
234
		 */
235
		documents_required: boolean
236
		[k: string]: unknown
237
	}
238
	/**
239
	 * The title of the contract.
240
	 */
241
	title: string
242
	client: {
243
		/**
244
		 * Choose the Deel team for this contract. Use teams endpoint to retrieve a list of teams in your organization.
245
		 */
246
		team: {
247
			/**
248
			 * Unique identifier of this resource.
249
			 */
250
			id: string | number
251
			[k: string]: unknown
252
		}
253
		/**
254
		 * Choose the Deel legal entity for this contract. Use legal entity endpoint to retrieve a list of legal entities in your organization.
255
		 */
256
		legal_entity: {
257
			/**
258
			 * Unique identifier of this resource.
259
			 */
260
			id: string | number
261
			[k: string]: unknown
262
		}
263
		[k: string]: unknown
264
	}
265
	/**
266
	 * Worker properties
267
	 */
268
	worker?: {
269
		/**
270
		 * Worker's last name
271
		 */
272
		last_name?: string
273
		/**
274
		 * Worker's first name
275
		 */
276
		first_name: string
277
		/**
278
		 * Worker's email address.
279
		 */
280
		expected_email: string
281
		[k: string]: unknown
282
	}
283
	/**
284
	 * Worker's job title. You can enter a custom job title or use a pre-defined job title using the Id retrieved in job-titles endpoint.
285
	 */
286
	job_title: {
287
		/**
288
		 * Unique identifier of this resource.
289
		 */
290
		id?: string | number
291
		/**
292
		 * Job title. Please leave it blank when entering an Id.
293
		 */
294
		name?: string
295
		[k: string]: unknown
296
	}
297
	/**
298
	 * Job seniority level. Please use the seniority levels endpoint to retrieve the list of seniority levels.
299
	 */
300
	seniority?: {
301
		/**
302
		 * Unique identifier of this resource.
303
		 */
304
		id?: string | number
305
		[k: string]: unknown
306
	}
307
	/**
308
	 * The state or province code. Use country lookup endpoint to retrieve state codes.
309
	 */
310
	state_code?: string
311
	/**
312
	 * External Id.
313
	 */
314
	external_id?: string
315
	/**
316
	 * Flag to indicate who is supposed to provide regular reports
317
	 */
318
	who_reports?: 'both' | 'client' | 'contractor'
319
	/**
320
	 * Country code.
321
	 */
322
	country_code?: string
323
	/**
324
	 * Days before to notice the termination of contract for either party.
325
	 */
326
	notice_period?: number
327
	/**
328
	 * Describe the work to be performed.
329
	 */
330
	scope_of_work?: string
331
	/**
332
	 * Enter any special clause you may have.
333
	 */
334
	special_clause?: string
335
	/**
336
	 * Short date in format ISO-8601 (YYYY-MM-DD). For example: 2022-12-31.
337
	 */
338
	termination_date?: string
339
	/**
340
	 * Contract Template Id.
341
	 */
342
	contract_template_id?: string
343
	[k: string]: unknown
344
} & {
345
	/**
346
	 * Type of contract
347
	 */
348
	type: 'payg_tasks'
349
	/**
350
	 * Short date in format ISO-8601 (YYYY-MM-DD). For example: 2022-12-31.
351
	 */
352
	start_date: string
353
	[k: string]: unknown
354
} & {
355
	compensation_details: {
356
		/**
357
		 * Amount to be paid. This field can be excluded when creating a Pay-as-you-go task-based or Milestone contracts.
358
		 */
359
		amount?: number
360
		/**
361
		 * Date invoice cycle ends.
362
		 */
363
		cycle_end: number
364
		/**
365
		 * Scale of the invoice cycle.
366
		 */
367
		frequency: 'weekly' | 'monthly' | 'biweekly' | 'semimonthly' | 'calendar-month'
368
		/**
369
		 * Currency code.
370
		 */
371
		currency_code: string
372
		/**
373
		 * First payment amount.
374
		 */
375
		first_payment?: number
376
		/**
377
		 * Days before to notice the termination of contract for either party.
378
		 */
379
		notice_period?: number
380
		/**
381
		 * Cycle end can be weekly 1-7 (Monday = 1) or monthly 1-31.
382
		 */
383
		cycle_end_type: 'DAY_OF_WEEK' | 'DAY_OF_LAST_WEEK' | 'DAY_OF_MONTH'
384
		/**
385
		 * Number of days to pay the invoice.
386
		 */
387
		payment_due_days: number
388
		/**
389
		 * Type of payment due. If the payment is due on the last day of month, enter 'WITHIN_MONTH'.
390
		 */
391
		payment_due_type: 'REGULAR' | 'WITHIN_MONTH'
392
		/**
393
		 * Short date in format ISO-8601 (YYYY-MM-DD). For example: 2022-12-31.
394
		 */
395
		first_payment_date?: string
396
		/**
397
		 * If the payment due is on a weekend, pay on Friday.
398
		 */
399
		pay_before_weekends?: boolean
400
		[k: string]: unknown
401
	}
402
	[k: string]: unknown
403
}
404
export type PAYG_MILESTONES = {
405
	/**
406
	 * Additional custom info about a contract
407
	 */
408
	meta: {
409
		/**
410
		 * Flag to indicate if the contract is the main income for the contractor.
411
		 */
412
		is_main_income?: boolean
413
		/**
414
		 * Require the contractor to upload necessary compliance documents as per their country’s labor laws.
415
		 */
416
		documents_required: boolean
417
		[k: string]: unknown
418
	}
419
	/**
420
	 * The title of the contract.
421
	 */
422
	title: string
423
	client: {
424
		/**
425
		 * Choose the Deel team for this contract. Use teams endpoint to retrieve a list of teams in your organization.
426
		 */
427
		team: {
428
			/**
429
			 * Unique identifier of this resource.
430
			 */
431
			id: string | number
432
			[k: string]: unknown
433
		}
434
		/**
435
		 * Choose the Deel legal entity for this contract. Use legal entity endpoint to retrieve a list of legal entities in your organization.
436
		 */
437
		legal_entity: {
438
			/**
439
			 * Unique identifier of this resource.
440
			 */
441
			id: string | number
442
			[k: string]: unknown
443
		}
444
		[k: string]: unknown
445
	}
446
	/**
447
	 * Worker properties
448
	 */
449
	worker?: {
450
		/**
451
		 * Worker's last name
452
		 */
453
		last_name?: string
454
		/**
455
		 * Worker's first name
456
		 */
457
		first_name: string
458
		/**
459
		 * Worker's email address.
460
		 */
461
		expected_email: string
462
		[k: string]: unknown
463
	}
464
	/**
465
	 * Worker's job title. You can enter a custom job title or use a pre-defined job title using the Id retrieved in job-titles endpoint.
466
	 */
467
	job_title: {
468
		/**
469
		 * Unique identifier of this resource.
470
		 */
471
		id?: string | number
472
		/**
473
		 * Job title. Please leave it blank when entering an Id.
474
		 */
475
		name?: string
476
		[k: string]: unknown
477
	}
478
	/**
479
	 * Job seniority level. Please use the seniority levels endpoint to retrieve the list of seniority levels.
480
	 */
481
	seniority?: {
482
		/**
483
		 * Unique identifier of this resource.
484
		 */
485
		id?: string | number
486
		[k: string]: unknown
487
	}
488
	/**
489
	 * The state or province code. Use country lookup endpoint to retrieve state codes.
490
	 */
491
	state_code?: string
492
	/**
493
	 * External Id.
494
	 */
495
	external_id?: string
496
	/**
497
	 * Flag to indicate who is supposed to provide regular reports
498
	 */
499
	who_reports?: 'both' | 'client' | 'contractor'
500
	/**
501
	 * Country code.
502
	 */
503
	country_code?: string
504
	/**
505
	 * Days before to notice the termination of contract for either party.
506
	 */
507
	notice_period?: number
508
	/**
509
	 * Describe the work to be performed.
510
	 */
511
	scope_of_work?: string
512
	/**
513
	 * Enter any special clause you may have.
514
	 */
515
	special_clause?: string
516
	/**
517
	 * Short date in format ISO-8601 (YYYY-MM-DD). For example: 2022-12-31.
518
	 */
519
	termination_date?: string
520
	/**
521
	 * Contract Template Id.
522
	 */
523
	contract_template_id?: string
524
	[k: string]: unknown
525
} & {
526
	/**
527
	 * Type of contract
528
	 */
529
	type: 'payg_milestones'
530
	/**
531
	 * Short date in format ISO-8601 (YYYY-MM-DD). For example: 2022-12-31.
532
	 */
533
	start_date?: string
534
	[k: string]: unknown
535
} & {
536
	compensation_details: {
537
		/**
538
		 * Amount to be paid. This field can be excluded when creating a Pay-as-you-go task-based or Milestone contracts.
539
		 */
540
		amount?: number
541
		/**
542
		 * Date invoice cycle ends.
543
		 */
544
		cycle_end: number
545
		/**
546
		 * Scale of the invoice cycle.
547
		 */
548
		frequency: 'weekly' | 'monthly' | 'biweekly' | 'semimonthly' | 'calendar-month'
549
		/**
550
		 * Currency code.
551
		 */
552
		currency_code: string
553
		/**
554
		 * First payment amount.
555
		 */
556
		first_payment?: number
557
		/**
558
		 * Days before to notice the termination of contract for either party.
559
		 */
560
		notice_period?: number
561
		/**
562
		 * Cycle end can be weekly 1-7 (Monday = 1) or monthly 1-31.
563
		 */
564
		cycle_end_type: 'DAY_OF_WEEK' | 'DAY_OF_LAST_WEEK' | 'DAY_OF_MONTH'
565
		/**
566
		 * Number of days to pay the invoice.
567
		 */
568
		payment_due_days: number
569
		/**
570
		 * Type of payment due. If the payment is due on the last day of month, enter 'WITHIN_MONTH'.
571
		 */
572
		payment_due_type: 'REGULAR' | 'WITHIN_MONTH'
573
		/**
574
		 * Short date in format ISO-8601 (YYYY-MM-DD). For example: 2022-12-31.
575
		 */
576
		first_payment_date?: string
577
		/**
578
		 * If the payment due is on a weekend, pay on Friday.
579
		 */
580
		pay_before_weekends?: boolean
581
		[k: string]: unknown
582
	}
583
	[k: string]: unknown
584
}
585
export type ONGOING_TIME_BASED = {
586
	/**
587
	 * Additional custom info about a contract
588
	 */
589
	meta: {
590
		/**
591
		 * Flag to indicate if the contract is the main income for the contractor.
592
		 */
593
		is_main_income?: boolean
594
		/**
595
		 * Require the contractor to upload necessary compliance documents as per their country’s labor laws.
596
		 */
597
		documents_required: boolean
598
		[k: string]: unknown
599
	}
600
	/**
601
	 * The title of the contract.
602
	 */
603
	title: string
604
	client: {
605
		/**
606
		 * Choose the Deel team for this contract. Use teams endpoint to retrieve a list of teams in your organization.
607
		 */
608
		team: {
609
			/**
610
			 * Unique identifier of this resource.
611
			 */
612
			id: string | number
613
			[k: string]: unknown
614
		}
615
		/**
616
		 * Choose the Deel legal entity for this contract. Use legal entity endpoint to retrieve a list of legal entities in your organization.
617
		 */
618
		legal_entity: {
619
			/**
620
			 * Unique identifier of this resource.
621
			 */
622
			id: string | number
623
			[k: string]: unknown
624
		}
625
		[k: string]: unknown
626
	}
627
	/**
628
	 * Worker properties
629
	 */
630
	worker?: {
631
		/**
632
		 * Worker's last name
633
		 */
634
		last_name?: string
635
		/**
636
		 * Worker's first name
637
		 */
638
		first_name: string
639
		/**
640
		 * Worker's email address.
641
		 */
642
		expected_email: string
643
		[k: string]: unknown
644
	}
645
	/**
646
	 * Worker's job title. You can enter a custom job title or use a pre-defined job title using the Id retrieved in job-titles endpoint.
647
	 */
648
	job_title: {
649
		/**
650
		 * Unique identifier of this resource.
651
		 */
652
		id?: string | number
653
		/**
654
		 * Job title. Please leave it blank when entering an Id.
655
		 */
656
		name?: string
657
		[k: string]: unknown
658
	}
659
	/**
660
	 * Job seniority level. Please use the seniority levels endpoint to retrieve the list of seniority levels.
661
	 */
662
	seniority?: {
663
		/**
664
		 * Unique identifier of this resource.
665
		 */
666
		id?: string | number
667
		[k: string]: unknown
668
	}
669
	/**
670
	 * The state or province code. Use country lookup endpoint to retrieve state codes.
671
	 */
672
	state_code?: string
673
	/**
674
	 * External Id.
675
	 */
676
	external_id?: string
677
	/**
678
	 * Flag to indicate who is supposed to provide regular reports
679
	 */
680
	who_reports?: 'both' | 'client' | 'contractor'
681
	/**
682
	 * Country code.
683
	 */
684
	country_code?: string
685
	/**
686
	 * Days before to notice the termination of contract for either party.
687
	 */
688
	notice_period?: number
689
	/**
690
	 * Describe the work to be performed.
691
	 */
692
	scope_of_work?: string
693
	/**
694
	 * Enter any special clause you may have.
695
	 */
696
	special_clause?: string
697
	/**
698
	 * Short date in format ISO-8601 (YYYY-MM-DD). For example: 2022-12-31.
699
	 */
700
	termination_date?: string
701
	/**
702
	 * Contract Template Id.
703
	 */
704
	contract_template_id?: string
705
	[k: string]: unknown
706
} & {
707
	/**
708
	 * Type of contract
709
	 */
710
	type: 'ongoing_time_based'
711
	/**
712
	 * Short date in format ISO-8601 (YYYY-MM-DD). For example: 2022-12-31.
713
	 */
714
	start_date: string
715
	[k: string]: unknown
716
} & {
717
	compensation_details: {
718
		/**
719
		 * Amount to be paid. This field can be excluded when creating a Pay-as-you-go task-based or Milestone contracts.
720
		 */
721
		amount?: number
722
		/**
723
		 * Date invoice cycle ends.
724
		 */
725
		cycle_end: number
726
		/**
727
		 * Scale of the invoice cycle.
728
		 */
729
		frequency: 'weekly' | 'monthly' | 'biweekly' | 'semimonthly' | 'calendar-month'
730
		/**
731
		 * Currency code.
732
		 */
733
		currency_code: string
734
		/**
735
		 * First payment amount.
736
		 */
737
		first_payment?: number
738
		/**
739
		 * Days before to notice the termination of contract for either party.
740
		 */
741
		notice_period?: number
742
		/**
743
		 * Cycle end can be weekly 1-7 (Monday = 1) or monthly 1-31.
744
		 */
745
		cycle_end_type: 'DAY_OF_WEEK' | 'DAY_OF_LAST_WEEK' | 'DAY_OF_MONTH'
746
		/**
747
		 * Number of days to pay the invoice.
748
		 */
749
		payment_due_days: number
750
		/**
751
		 * Type of payment due. If the payment is due on the last day of month, enter 'WITHIN_MONTH'.
752
		 */
753
		payment_due_type: 'REGULAR' | 'WITHIN_MONTH'
754
		/**
755
		 * Short date in format ISO-8601 (YYYY-MM-DD). For example: 2022-12-31.
756
		 */
757
		first_payment_date?: string
758
		/**
759
		 * If the payment due is on a weekend, pay on Friday.
760
		 */
761
		pay_before_weekends?: boolean
762
		[k: string]: unknown
763
	} & {
764
		/**
765
		 * Defines the scale at which the amount is paid. For example, enter 'hourly' to define the amount per hour. This field can be excluded when creating a Pay-as-you-go task-based or Milestone contracts.
766
		 */
767
		scale: 'hourly' | 'daily' | 'weekly' | 'monthly' | 'biweekly' | 'semimonthly' | 'custom'
768
		/**
769
		 * Amount to be paid. This field can be excluded when creating a Pay-as-you-go task-based or Milestone contracts.
770
		 */
771
		amount: number
772
		[k: string]: unknown
773
	}
774
	[k: string]: unknown
775
}
776

777
export interface Body {
778
	data: PAY_AS_YOU_GO_TIME_BASED | PAYG_TASKS | PAYG_MILESTONES | ONGOING_TIME_BASED
779
	[k: string]: unknown
780
}
781