0

Update an account allocation target

by
Published Oct 17, 2025

Updates an existing account allocation target by setting field values. Any fields not provided remain unchanged.

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 an account allocation target
7
 * Updates an existing account allocation target by setting field values. Any fields not provided remain unchanged.
8
 */
9
export async function main(
10
	auth: SageIntacct,
11
	key: string,
12
	body: {
13
		key?: string
14
		id?: string
15
		glAccountAllocation?: { key?: string; id?: string; href?: string }
16
		glAccountGroup?: { key?: string; id?: string; href?: string }
17
		isBillable?: false | true
18
		glAccount?: { key?: string; id?: string; name?: string; href?: string }
19
		journal?: { key?: string; id?: string; title?: string; href?: string }
20
		dimensions?: {
21
			class?: { key?: string; name?: string; id?: string; href?: string }
22
			customer?: { key?: string; name?: string; id?: string; href?: string }
23
			employee?: { key?: string; name?: string; id?: string; href?: string }
24
			department?: { key?: string; id?: string; name?: string; href?: string }
25
			location?: { key?: string; id?: string; name?: string; href?: string }
26
			project?: { key?: string; name?: string; id?: string; href?: string }
27
			vendor?: { key?: string; name?: string; id?: string; href?: string }
28
			warehouse?: { key?: string; name?: string; id?: string; href?: string }
29
			item?: { key?: string; name?: string; id?: string; href?: string }
30
			contract?: { key?: string; name?: string; id?: string; href?: string }
31
		}
32
		audit?: {
33
			createdDateTime?: string
34
			modifiedDateTime?: string
35
			createdBy?: string
36
			modifiedBy?: string
37
		}
38
		href?: string
39
	}
40
) {
41
	const url = new URL(
42
		`https://api.intacct.com/ia/api/v1/objects/general-ledger/account-allocation-target/${key}`
43
	)
44

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