0

Create a contract expense template

by
Published Oct 17, 2025

Creates a new contract expense 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 contract expense template
7
 * Creates a new contract expense 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
		amortizationSchedulePeriod?: 'monthly' | 'quarterly' | 'semiAnnually' | 'annually'
17
		postingDay?: number
18
		amortizationMethod?: 'straightLine' | 'dailyRate' | 'predefinedPercentages'
19
		defaultPostingType?: 'automatic' | 'manual'
20
		lines?: {
21
			key?: string
22
			id?: string
23
			href?: string
24
			periodOffset?: string
25
			percentToRecognize?: string
26
			contractExpenseTemplate?: { 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
				createdByUser?: { key?: string; id?: string; href?: string }
34
				modifiedByUser?: { key?: string; id?: string; href?: string }
35
			}
36
		}[]
37
		status?: 'active' | 'inactive'
38
		audit?: {
39
			createdDateTime?: string
40
			modifiedDateTime?: string
41
			createdBy?: string
42
			modifiedBy?: string
43
			createdByUser?: { key?: string; id?: string; href?: string }
44
			modifiedByUser?: { key?: string; id?: string; href?: string }
45
		}
46
	} & {}
47
) {
48
	const url = new URL(`https://api.intacct.com/ia/api/v1/objects/contracts/expense-template`)
49

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