0

Update a billback template

by
Published Oct 17, 2025

Updates an existing billback template 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 billback template
7
 * Updates an existing billback template 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
		href?: string
16
		description?: string
17
		enableInterEntityPostings?: false | true
18
		status?: 'active' | 'inactive'
19
		entity?: { key?: string; id?: string; name?: string; href?: string }
20
		lines?: {
21
			key?: string
22
			id?: string
23
			href?: string
24
			lineNumber?: string
25
			memo?: string
26
			invoiceGLAccount?: {
27
				key?: string
28
				id?: string
29
				name?: string
30
				href?: string
31
			}
32
			billGLAccount?: {
33
				key?: string
34
				id?: string
35
				name?: string
36
				href?: string
37
			}
38
			department?: { key?: string; id?: string; name?: string; href?: string }
39
			billbackTemplate?: { id?: string; key?: string; href?: string }
40
		}[]
41
	} & { id?: {} }
42
) {
43
	const url = new URL(
44
		`https://api.intacct.com/ia/api/v1/objects/accounts-receivable/billback-template/${key}`
45
	)
46

47
	const response = await fetch(url, {
48
		method: 'PATCH',
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