0

Create a change request status

by
Published Oct 17, 2025

Creates a new change request status.

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 change request status
7
 * Creates a new change request status.
8
 */
9
export async function main(
10
	auth: SageIntacct,
11
	body: {
12
		key?: string
13
		id?: string
14
		href?: string
15
		workflowType?:
16
			| 'none'
17
			| 'original'
18
			| 'revision'
19
			| 'forecast'
20
			| 'approvedChange'
21
			| 'pendingChange'
22
			| 'other'
23
		status?: 'active' | 'inactive'
24
		audit?: {
25
			createdDateTime?: string
26
			modifiedDateTime?: string
27
			createdBy?: string
28
			modifiedBy?: string
29
		}
30
	} & {}
31
) {
32
	const url = new URL(
33
		`https://api.intacct.com/ia/api/v1/objects/construction/change-request-status`
34
	)
35

36
	const response = await fetch(url, {
37
		method: 'POST',
38
		headers: {
39
			'Content-Type': 'application/json',
40
			Authorization: 'Bearer ' + auth.token
41
		},
42
		body: JSON.stringify(body)
43
	})
44
	if (!response.ok) {
45
		const text = await response.text()
46
		throw new Error(`${response.status} ${text}`)
47
	}
48
	return await response.json()
49
}
50