0

Create an account allocation group

by
Published Oct 17, 2025

Creates a new account allocation group.

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 account allocation group
7
 * Creates a new account allocation group.
8
 */
9
export async function main(
10
	auth: SageIntacct,
11
	body: {
12
		key?: string
13
		id?: string
14
		name?: string
15
		description?: string
16
		errorProcessingMethod?: 'stop' | 'skipAndContinue'
17
		lines?: {
18
			key?: string
19
			id?: string
20
			glAccountAllocation?: {
21
				key?: string
22
				id?: string
23
				name?: string
24
				href?: string
25
			}
26
			glAccountAllocationGroup?: { key?: string; id?: string; href?: string }
27
			status?: 'active' | 'inactive'
28
			audit?: {
29
				createdDateTime?: string
30
				modifiedDateTime?: string
31
				createdBy?: string
32
				modifiedBy?: string
33
			}
34
		}[]
35
		status?: 'active' | 'inactive'
36
		audit?: {
37
			createdDateTime?: string
38
			modifiedDateTime?: string
39
			createdBy?: string
40
			modifiedBy?: string
41
		}
42
		href?: string
43
	} & {}
44
) {
45
	const url = new URL(
46
		`https://api.intacct.com/ia/api/v1/objects/general-ledger/account-allocation-group`
47
	)
48

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