0

Create a user

by
Published Oct 17, 2025

Creates a new user.

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 a user
7
 * Creates a new user.
8
 */
9
export async function main(
10
	auth: SageIntacct,
11
	body: {
12
		key?: string
13
		id?: string
14
		userName?: string
15
		accountEmail?: string
16
		userType?:
17
			| 'business'
18
			| 'employee'
19
			| 'viewOnly'
20
			| 'dashboard'
21
			| 'projectManager'
22
			| 'paymentApprover'
23
			| 'platform'
24
			| 'crm'
25
			| 'warehouse'
26
			| 'constructionManager'
27
		adminPrivileges?: 'off' | 'limited' | 'full'
28
		status?: 'active' | 'inactive' | 'lockedOut'
29
		webServices?: { isEnabled?: false | true; isRestricted?: false | true }
30
		password?: {
31
			neverExpires?: false | true
32
			requiresReset?: false | true
33
			disablePassword?: false | true
34
		}
35
		sso?: { isSSOEnabled?: false | true; federatedSSOId?: string }
36
		entityAccess?: {
37
			allowUnrestrictedAccess?: false | true
38
			allowToplevelAccess?: false | true
39
		}
40
		contact?: {
41
			key?: string
42
			id?: string
43
			href?: string
44
			lastName?: string
45
			firstName?: string
46
			middleName?: string
47
			prefix?: string
48
			printAs?: string
49
			email1?: string
50
			email2?: string
51
			phone1?: string
52
			phone2?: string
53
			mobile?: string
54
			pager?: string
55
			fax?: string
56
			URL1?: string
57
			URL2?: string
58
			companyName?: string
59
			mailingAddress?: {
60
				addressLine1?: string
61
				addressLine2?: string
62
				addressLine3?: string
63
				city?: string
64
				state?: string
65
				postCode?: string
66
				country?: string
67
			}
68
		} & {}
69
		trustedDevices?: 'companyDefault' | 'always' | 'never'
70
		isChatterDisabled?: false | true
71
		hideOtherDepartmentTransactions?: false | true
72
		locations?: { key?: string; id?: string; href?: string }[]
73
		departments?: { key?: string; id?: string; href?: string }[]
74
		territories?: { key?: string; id?: string; href?: string }[]
75
		roles?: { key?: string; id?: string; href?: string }[]
76
		permissionAssignments?: {
77
			permission?: { key?: string; id?: string; href?: string }
78
			accessRights?:
79
				| 'ach'
80
				| 'achSetup'
81
				| 'add'
82
				| 'addExpense'
83
				| 'apiProxy'
84
				| 'approvalLevel1'
85
				| 'approvalLevel2'
86
				| 'approvalLevel3'
87
				| 'approvalLevel4'
88
				| 'approvalLevel5'
89
				| 'approvalLevel6'
90
				| 'authorize'
91
				| 'cancel'
92
				| 'calendar'
93
				| 'clone'
94
				| 'close'
95
				| 'config'
96
				| 'confirm'
97
				| 'delete'
98
				| 'deleteExpense'
99
				| 'edit'
100
				| 'editExpense'
101
				| 'enable'
102
				| 'export'
103
				| 'final'
104
				| 'financial'
105
				| 'group'
106
				| 'ignore'
107
				| 'import'
108
				| 'impersonate'
109
				| 'level1'
110
				| 'level2'
111
				| 'level3'
112
				| 'level4'
113
				| 'level5'
114
				| 'level6'
115
				| 'list'
116
				| 'listExpenses'
117
				| 'manualMatch'
118
				| 'mapAccount'
119
				| 'menu'
120
				| 'modify'
121
				| 'offsetAccount'
122
				| 'open'
123
				| 'overrideException'
124
				| 'permission'
125
				| 'post'
126
				| 'print'
127
				| 'readonly'
128
				| 'readonlyExpense'
129
				| 'receipts'
130
				| 'reclass'
131
				| 'reclassExpense'
132
				| 'reconcile'
133
				| 'refresh'
134
				| 'release'
135
				| 'reopen'
136
				| 'report'
137
				| 'resend'
138
				| 'reversalEdit'
139
				| 'reverse'
140
				| 'reverseExpense'
141
				| 'run'
142
				| 'statutoryReportingPeriod'
143
				| 'submit'
144
				| 'subscribe'
145
				| 'template'
146
				| 'uncancel'
147
				| 'unmask'
148
				| 'upload'
149
				| 'view'
150
				| 'viewAll'
151
				| 'void'[]
152
		}[]
153
		audit?: {
154
			createdDateTime?: string
155
			modifiedDateTime?: string
156
			createdBy?: string
157
			modifiedBy?: string
158
		}
159
		entity?: { key?: string; id?: string; name?: string; href?: string }
160
		href?: string
161
	} & {}
162
) {
163
	const url = new URL(`https://api.intacct.com/ia/api/v1/objects/company-config/user`)
164

165
	const response = await fetch(url, {
166
		method: 'POST',
167
		headers: {
168
			'Content-Type': 'application/json',
169
			Authorization: 'Bearer ' + auth.token
170
		},
171
		body: JSON.stringify(body)
172
	})
173
	if (!response.ok) {
174
		const text = await response.text()
175
		throw new Error(`${response.status} ${text}`)
176
	}
177
	return await response.json()
178
}
179