0

Create a billback template

by
Published Oct 17, 2025

Creates a new billback template.

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 billback template
7
 * Creates a new billback template.
8
 */
9
export async function main(
10
	auth: SageIntacct,
11
	body: {
12
		key?: string
13
		id?: string
14
		href?: string
15
		description?: string
16
		enableInterEntityPostings?: false | true
17
		status?: 'active' | 'inactive'
18
		entity?: { key?: string; id?: string; name?: string; href?: string }
19
		lines?: {
20
			key?: string
21
			id?: string
22
			href?: string
23
			lineNumber?: string
24
			memo?: string
25
			invoiceGLAccount?: {
26
				key?: string
27
				id?: string
28
				name?: string
29
				href?: string
30
			}
31
			billGLAccount?: {
32
				key?: string
33
				id?: string
34
				name?: string
35
				href?: string
36
			}
37
			department?: { key?: string; id?: string; name?: string; href?: string }
38
			billbackTemplate?: { id?: string; key?: string; href?: string }
39
		}[]
40
	} & { lines?: { invoiceGLAccount?: {}; billGLAccount?: {} }[] }
41
) {
42
	const url = new URL(
43
		`https://api.intacct.com/ia/api/v1/objects/accounts-receivable/billback-template`
44
	)
45

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