0

Create an employee

by
Published Oct 17, 2025

Creates a new employee. If the employee is also a user in Sage Intacct (which is required if they will be entering time or expenses), set the `primaryContact` to the same contact that is associated with the user. Permissions and other requirements SubscriptionCompany User typeBusiness user with admin privileges PermissionsAdd Employees

Script sage_intacct Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type SageIntacct = {
3
	token: string
4
}
5
/**
6
 * Create an employee
7
 * Creates a new employee. If the employee is also a user in Sage Intacct (which is required if they will be entering time or expenses), set the `primaryContact` to the same contact that is associated with the user.
8

9

10
Permissions and other requirements
11

12
SubscriptionCompany
13
User typeBusiness user with admin privileges
14
PermissionsAdd Employees
15

16

17

18

19
 */
20
export async function main(
21
	auth: SageIntacct,
22
	body: {
23
		key?: string
24
		id?: string
25
		name?: string
26
		startDate?: string
27
		jobTitle?: string
28
		status?: 'active' | 'inactive'
29
		birthDate?: string
30
		endDate?: string
31
		postActualCostWithVariance?: false | true
32
		mergePaymentRequests?: false | true
33
		sendAutomaticPaymentNotification?: false | true
34
		manager?: { key?: string; id?: string; name?: string; href?: string }
35
		gender?: 'female' | 'male'
36
		location?: { key?: string; id?: string; name?: string; href?: string }
37
		department?: { key?: string; id?: string; name?: string; href?: string }
38
		class?: { key?: string; id?: string; name?: string; href?: string }
39
		defaultCurrency?: string
40
		primaryContact?: {
41
			key?: string
42
			id?: string
43
			lastName?: string
44
			firstName?: string
45
			middleName?: string
46
			prefix?: string
47
			email1?: string
48
			email2?: string
49
			phone1?: string
50
			phone2?: string
51
			mobile?: string
52
			pager?: string
53
			fax?: string
54
			URL1?: string
55
			URL2?: string
56
			companyName?: string
57
			printAs?: string
58
			mailingAddress?: {
59
				addressLine1?: string
60
				addressLine2?: string
61
				city?: string
62
				state?: string
63
				postCode?: string
64
				country?: string
65
				isoCountryCode?: string
66
			}
67
			href?: string
68
		}
69
		employeeType?: { key?: string; id?: string; href?: string }
70
		earningType?: { key?: string; id?: string; href?: string }
71
		SSN?: string
72
		employeePosition?: {
73
			key?: string
74
			id?: string
75
			name?: string
76
			href?: string
77
		}
78
		terminationType?: 'voluntary' | 'involuntary' | 'deceased' | 'disability' | 'retired'
79
		form1099?: { name?: string; type?: string; box?: string }
80
		ach?: {
81
			enabled?: false | true
82
			bankRoutingNumber?: string
83
			accountNumber?: string
84
			accountType?: 'checkingAccount' | 'savingsAccount'
85
			remittanceType?: 'personalPPD' | 'businessCCD' | 'businessCTX'
86
		}
87
		isPlaceholderResource?: false | true
88
		filePaymentService?: 'ach' | 'bankFile' | 'none'
89
		bankFile?: {
90
			paymentCountryCode?:
91
				| 'us'
92
				| 'af'
93
				| 'ax'
94
				| 'al'
95
				| 'dz'
96
				| 'as'
97
				| 'ad'
98
				| 'ao'
99
				| 'ai'
100
				| 'aq'
101
				| 'ag'
102
				| 'ar'
103
				| 'am'
104
				| 'aw'
105
				| 'au'
106
				| 'at'
107
				| 'az'
108
				| 'bs'
109
				| 'bh'
110
				| 'bd'
111
				| 'bb'
112
				| 'by'
113
				| 'be'
114
				| 'bz'
115
				| 'bj'
116
				| 'bm'
117
				| 'bt'
118
				| 'bo'
119
				| 'bq'
120
				| 'ba'
121
				| 'bw'
122
				| 'bv'
123
				| 'br'
124
				| 'io'
125
				| 'bn'
126
				| 'bg'
127
				| 'bf'
128
				| 'bi'
129
				| 'kh'
130
				| 'cm'
131
				| 'ca'
132
				| 'cv'
133
				| 'ky'
134
				| 'cf'
135
				| 'td'
136
				| 'cl'
137
				| 'cn'
138
				| 'cx'
139
				| 'cc'
140
				| 'co'
141
				| 'km'
142
				| 'cg'
143
				| 'cd'
144
				| 'ck'
145
				| 'cr'
146
				| 'ci'
147
				| 'hr'
148
				| 'cu'
149
				| 'cw'
150
				| 'cy'
151
				| 'cz'
152
				| 'dk'
153
				| 'dj'
154
				| 'dm'
155
				| 'do'
156
				| 'ec'
157
				| 'eg'
158
				| 'sv'
159
				| 'gq'
160
				| 'er'
161
				| 'ee'
162
				| 'sz'
163
				| 'et'
164
				| 'fk'
165
				| 'fo'
166
				| 'fj'
167
				| 'fi'
168
				| 'fr'
169
				| 'gf'
170
				| 'pf'
171
				| 'tf'
172
				| 'ga'
173
				| 'gm'
174
				| 'ge'
175
				| 'de'
176
				| 'gh'
177
				| 'gi'
178
				| 'gr'
179
				| 'gl'
180
				| 'gd'
181
				| 'gp'
182
				| 'gu'
183
				| 'gt'
184
				| 'gg'
185
				| 'gn'
186
				| 'gw'
187
				| 'gy'
188
				| 'ht'
189
				| 'hm'
190
				| 'hn'
191
				| 'hk'
192
				| 'hu'
193
				| 'is'
194
				| 'in'
195
				| 'id'
196
				| 'ir'
197
				| 'iq'
198
				| 'ie'
199
				| 'im'
200
				| 'il'
201
				| 'it'
202
				| 'jm'
203
				| 'jp'
204
				| 'je'
205
				| 'jo'
206
				| 'kz'
207
				| 'ke'
208
				| 'ki'
209
				| 'kr'
210
				| 'kp'
211
				| 'xk'
212
				| 'kw'
213
				| 'kg'
214
				| 'la'
215
				| 'lv'
216
				| 'lb'
217
				| 'ls'
218
				| 'lr'
219
				| 'ly'
220
				| 'li'
221
				| 'lt'
222
				| 'lu'
223
				| 'mo'
224
				| 'mk'
225
				| 'mg'
226
				| 'mw'
227
				| 'my'
228
				| 'mv'
229
				| 'ml'
230
				| 'mt'
231
				| 'mh'
232
				| 'mq'
233
				| 'mr'
234
				| 'mu'
235
				| 'yt'
236
				| 'mx'
237
				| 'fm'
238
				| 'md'
239
				| 'mc'
240
				| 'mn'
241
				| 'me'
242
				| 'ms'
243
				| 'ma'
244
				| 'mz'
245
				| 'mm'
246
				| 'na'
247
				| 'nr'
248
				| 'np'
249
				| 'nl'
250
				| 'an'
251
				| 'nc'
252
				| 'nz'
253
				| 'ni'
254
				| 'ne'
255
				| 'ng'
256
				| 'nu'
257
				| 'nf'
258
				| 'mp'
259
				| 'no'
260
				| 'om'
261
				| 'pk'
262
				| 'pw'
263
				| 'ps'
264
				| 'pa'
265
				| 'pg'
266
				| 'py'
267
				| 'pe'
268
				| 'ph'
269
				| 'pn'
270
				| 'pl'
271
				| 'pt'
272
				| 'pr'
273
				| 'qa'
274
				| 're'
275
				| 'ro'
276
				| 'ru'
277
				| 'rw'
278
				| 'bl'
279
				| 'sh'
280
				| 'kn'
281
				| 'lc'
282
				| 'mf'
283
				| 'pm'
284
				| 'vc'
285
				| 'ws'
286
				| 'sm'
287
				| 'st'
288
				| 'sa'
289
				| 'sn'
290
				| 'rs'
291
				| 'sc'
292
				| 'sl'
293
				| 'sg'
294
				| 'sx'
295
				| 'sk'
296
				| 'si'
297
				| 'sb'
298
				| 'so'
299
				| 'za'
300
				| 'gs'
301
				| 'es'
302
				| 'lk'
303
				| 'sd'
304
				| 'ss'
305
				| 'sr'
306
				| 'sj'
307
				| 'se'
308
				| 'ch'
309
				| 'sy'
310
				| 'tw'
311
				| 'tj'
312
				| 'tz'
313
				| 'th'
314
				| 'tl'
315
				| 'tg'
316
				| 'tk'
317
				| 'to'
318
				| 'tt'
319
				| 'tn'
320
				| 'tr'
321
				| 'tm'
322
				| 'tc'
323
				| 'tv'
324
				| 'ug'
325
				| 'ua'
326
				| 'ae'
327
				| 'gb'
328
				| 'um'
329
				| 'uy'
330
				| 'uz'
331
				| 'vu'
332
				| 'va'
333
				| 've'
334
				| 'vn'
335
				| 'vg'
336
				| 'vi'
337
				| 'wf'
338
				| 'eh'
339
				| 'ye'
340
				| 'zm'
341
				| 'zw'
342
			paymentCurrency?: string
343
		}
344
		bankFileSetup?: {
345
			key?: string
346
			id?: string
347
			bankAccountNumber?: string
348
			bankAccountName?: string
349
			bsbNumber?: string
350
			sortCode?: string
351
			paymentReference?: string
352
			branchCode?: string
353
			bankAccountType?: string
354
			bankAccountCode?: string
355
			printPaymentProof?: false | true
356
			businessIdCode?: string
357
			creditorCode?: string
358
			secondaryIdentifier?: string
359
			employee?: { key?: string; id?: string; href?: string }
360
			href?: string
361
		}[]
362
		preferredPaymentMethod?: 'ach' | 'printedCheck' | 'eft' | 'cash'
363
		attachmentFolder?: { key?: string; id?: string; href?: string }
364
		employeeRates?: {
365
			key?: string
366
			id?: string
367
			href?: string
368
			hourlyRate?: string
369
			annualSalary?: string
370
			startDate?: string
371
			endDate?: string
372
			employee?: { id?: string; key?: string; name?: string; href?: string }
373
			audit?: {
374
				createdDateTime?: string
375
				modifiedDateTime?: string
376
				createdBy?: string
377
				modifiedBy?: string
378
			}
379
		}[]
380
		positionSkills?: { key?: string; id?: string; href?: string }[]
381
		audit?: {
382
			createdDateTime?: string
383
			modifiedDateTime?: string
384
			createdBy?: string
385
			modifiedBy?: string
386
		}
387
		entity?: { key?: string; id?: string; name?: string; href?: string }
388
		href?: string
389
	} & {}
390
) {
391
	const url = new URL(`https://api.intacct.com/ia/api/v1/objects/company-config/employee`)
392

393
	const response = await fetch(url, {
394
		method: 'POST',
395
		headers: {
396
			'Content-Type': 'application/json',
397
			Authorization: 'Bearer ' + auth.token
398
		},
399
		body: JSON.stringify(body)
400
	})
401
	if (!response.ok) {
402
		const text = await response.text()
403
		throw new Error(`${response.status} ${text}`)
404
	}
405
	return await response.json()
406
}
407