0

Update a reporting period

by
Published Oct 17, 2025

Updates an existing reporting period by setting field values. Any fields not provided remain unchanged. Permissions and other requirements SubscriptionGeneral Ledger User typeBusiness PermissionsEdit Reporting Periods

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 reporting period
7
 * Updates an existing reporting period by setting field values. Any fields not provided remain unchanged.
8

9

10
Permissions and other requirements
11

12
SubscriptionGeneral Ledger
13
User typeBusiness
14
PermissionsEdit Reporting Periods
15

16

17

18

19
 */
20
export async function main(
21
	auth: SageIntacct,
22
	key: string,
23
	body: {
24
		key?: string
25
		id?: string
26
		columnHeader1?: string
27
		columnHeader2?: string
28
		startDate?: string
29
		endDate?: string
30
		isBudgetable?: false | true
31
		reportingPeriodType?: 'standard' | 'custom'
32
		dateType?: number
33
		href?: string
34
		status?: 'active' | 'inactive'
35
		audit?: {
36
			createdDateTime?: string
37
			modifiedDateTime?: string
38
			createdBy?: string
39
			modifiedBy?: string
40
		}
41
	} & { id?: {} }
42
) {
43
	const url = new URL(
44
		`https://api.intacct.com/ia/api/v1/objects/general-ledger/reporting-period/${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