0

Create a contract

by
Published Oct 17, 2025

Create a Global Payroll contract. **Token scopes**: `contracts:write`

Script deel Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
/**
3
 * Create a contract
4
 * Create a Global Payroll 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/gp`)
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
	data: {
34
		client: {
35
			team: {
36
				/**
37
				 * Refers to Groups in the platform. Working groups that reflect the organization's structure.
38
				 */
39
				id: string
40
				[k: string]: unknown
41
			}
42
			legal_entity: {
43
				/**
44
				 * Unique identifier of this resource.
45
				 */
46
				id: string
47
				[k: string]: unknown
48
			}
49
			[k: string]: unknown
50
		}
51
		employee: {
52
			/**
53
			 * Worker's email address.
54
			 */
55
			email: string
56
			address: {
57
				/**
58
				 * Zip code.
59
				 */
60
				zip: string
61
				/**
62
				 * City name.
63
				 */
64
				city: string
65
				/**
66
				 * State code.
67
				 */
68
				state?: string
69
				/**
70
				 * Street and number.
71
				 */
72
				street: string
73
				/**
74
				 * Country code.
75
				 */
76
				country: string
77
				[k: string]: unknown
78
			}
79
			/**
80
			 * Employee's last name.
81
			 */
82
			last_name: string
83
			/**
84
			 * Employee's first name.
85
			 */
86
			first_name: string
87
			/**
88
			 * Worker's email address.
89
			 */
90
			work_email: string
91
			/**
92
			 * Employee's nationality.
93
			 */
94
			nationality?: string
95
			/**
96
			 * Employee's number.
97
			 */
98
			employee_number?: string
99
			[k: string]: unknown
100
		}
101
		/**
102
		 * Employee's job title.
103
		 */
104
		job_title: string
105
		employment: {
106
			/**
107
			 * Is it a full-time contract or a part-time contract?
108
			 */
109
			type: 'Full-time' | 'Part-time'
110
			holidays: {
111
				/**
112
				 * Enter the number of holidays.
113
				 */
114
				allowance: number
115
				/**
116
				 * Short date in format ISO-8601 (YYYY-MM-DD). For example: 2022-12-31.
117
				 */
118
				start_date: string
119
				[k: string]: unknown
120
			}
121
			/**
122
			 * Short date in format ISO-8601 (YYYY-MM-DD). For example: 2022-12-31.
123
			 */
124
			start_date: string
125
			[k: string]: unknown
126
		}
127
		compensation_details: {
128
			/**
129
			 * Defines the scale at which the salary is paid.
130
			 */
131
			scale: 'YEAR' | 'MONTH'
132
			/**
133
			 * Employee's gross annual/month salary.
134
			 */
135
			salary: number
136
			currency?: string
137
			[k: string]: unknown
138
		}
139
		/**
140
		 * Defines whether the employee should be invited to join the platform. When set to true, and if the employee app is enabled, an invitation will be sent to the employee to onboard them into the platform.
141
		 */
142
		invite_employee_to_app?: boolean
143
		[k: string]: unknown
144
	}
145
	[k: string]: unknown
146
}
147