0

Update a statistical account

by
Published Oct 17, 2025

Updates an existing statistical account by setting field values. Any fields not provided remain unchanged. Permissions and other requirements SubscriptionCompany User typeBusiness user with admin privileges PermissionsEdit Statistical Accounts

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
 * Update a statistical account
7
 * Updates an existing statistical account by setting field values. Any fields not provided remain unchanged.
8

9

10
Permissions and other requirements
11

12
SubscriptionCompany
13
User typeBusiness user with admin privileges
14
PermissionsEdit Statistical Accounts
15

16

17

18

19
 */
20
export async function main(
21
	auth: SageIntacct,
22
	key: string,
23
	body: {
24
		key?: string
25
		id?: string
26
		name?: string
27
		reportType?: 'forPeriod' | 'cumulative'
28
		requireDimensions?: {
29
			class?: false | true
30
			contract?: false | true
31
			customer?: false | true
32
			department?: false | true
33
			employee?: false | true
34
			item?: false | true
35
			location?: false | true
36
			project?: false | true
37
			vendor?: false | true
38
			warehouse?: false | true
39
			asset?: false | true
40
			affiliateEntity?: false | true
41
		}
42
		isTaxable?: false | true
43
		category?: string
44
		status?: 'active' | 'inactive'
45
		audit?: {
46
			createdDateTime?: string
47
			modifiedDateTime?: string
48
			createdBy?: string
49
			modifiedBy?: string
50
		}
51
		href?: string
52
		entity?: { key?: string; id?: string; name?: string; href?: string }
53
	}
54
) {
55
	const url = new URL(
56
		`https://api.intacct.com/ia/api/v1/objects/general-ledger/statistical-account/${key}`
57
	)
58

59
	const response = await fetch(url, {
60
		method: 'PATCH',
61
		headers: {
62
			'Content-Type': 'application/json',
63
			Authorization: 'Bearer ' + auth.token
64
		},
65
		body: JSON.stringify(body)
66
	})
67
	if (!response.ok) {
68
		const text = await response.text()
69
		throw new Error(`${response.status} ${text}`)
70
	}
71
	return await response.json()
72
}
73