0

Create a department

by
Published Oct 17, 2025

Creates a new department. Permissions and other requirements SubscriptionCompany User typeBusiness user with admin privileges PermissionsAdd Department

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 department
7
 * Creates a new department.
8

9

10
Permissions and other requirements
11

12
SubscriptionCompany
13
User typeBusiness user with admin privileges
14
PermissionsAdd Department
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
		number?: string
27
		reportTitle?: string
28
		parent?: { key?: string; id?: string; name?: string; href?: string }
29
		supervisor?: { key?: string; id?: string; name?: string; href?: string }
30
		status?: 'active' | 'activeNonPosting' | 'inactive'
31
		audit?: {
32
			createdDateTime?: string
33
			modifiedDateTime?: string
34
			createdBy?: string
35
			modifiedBy?: string
36
		}
37
		href?: string
38
	} & {}
39
) {
40
	const url = new URL(`https://api.intacct.com/ia/api/v1/objects/company-config/department`)
41

42
	const response = await fetch(url, {
43
		method: 'POST',
44
		headers: {
45
			'Content-Type': 'application/json',
46
			Authorization: 'Bearer ' + auth.token
47
		},
48
		body: JSON.stringify(body)
49
	})
50
	if (!response.ok) {
51
		const text = await response.text()
52
		throw new Error(`${response.status} ${text}`)
53
	}
54
	return await response.json()
55
}
56