0

Update a tax authority

by
Published Oct 17, 2025

Updates an existing tax authority 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 a tax authority
7
 * Updates an existing tax authority 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
		description?: string
16
		href?: string
17
		vendorId?: string
18
		parent?: { id?: string; key?: string; href?: string }
19
	} & { id?: {} }
20
) {
21
	const url = new URL(`https://api.intacct.com/ia/api/v1/objects/tax/tax-authority/${key}`)
22

23
	const response = await fetch(url, {
24
		method: 'PATCH',
25
		headers: {
26
			'Content-Type': 'application/json',
27
			Authorization: 'Bearer ' + auth.token
28
		},
29
		body: JSON.stringify(body)
30
	})
31
	if (!response.ok) {
32
		const text = await response.text()
33
		throw new Error(`${response.status} ${text}`)
34
	}
35
	return await response.json()
36
}
37