0

Create a statistical account

by
Published Oct 17, 2025

Creates a new statistical account.

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 statistical account
7
 * Creates a new statistical account.
8
 */
9
export async function main(
10
	auth: SageIntacct,
11
	body: {
12
		key?: string
13
		id?: string
14
		name?: string
15
		reportType?: 'forPeriod' | 'cumulative'
16
		requireDimensions?: {
17
			class?: false | true
18
			contract?: false | true
19
			customer?: false | true
20
			department?: false | true
21
			employee?: false | true
22
			item?: false | true
23
			location?: false | true
24
			project?: false | true
25
			vendor?: false | true
26
			warehouse?: false | true
27
			asset?: false | true
28
			affiliateEntity?: false | true
29
		}
30
		isTaxable?: false | true
31
		category?: string
32
		status?: 'active' | 'inactive'
33
		audit?: {
34
			createdDateTime?: string
35
			modifiedDateTime?: string
36
			createdBy?: string
37
			modifiedBy?: string
38
		}
39
		href?: string
40
		entity?: { key?: string; id?: string; name?: string; href?: string }
41
	} & {}
42
) {
43
	const url = new URL(
44
		`https://api.intacct.com/ia/api/v1/objects/general-ledger/statistical-account`
45
	)
46

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