0

Update a standard cost type

by
Published Oct 17, 2025

Updates an existing standard cost type by setting field values. Any fields not provided remain unchanged. Permissions and other requirements SubscriptionProject Costing or Construction User typeBusiness, Project Manager PermissionsEdit Standard Cost Types

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

9

10
Permissions and other requirements
11

12
SubscriptionProject Costing or Construction
13
User typeBusiness, Project Manager
14
PermissionsEdit Standard Cost Types
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
		href?: string
27
		name?: string
28
		description?: string
29
		costUnitDescription?: string
30
		status?: 'active' | 'inactive'
31
		glAccount?: { key?: string; id?: string; href?: string }
32
		accumulationType?: { key?: string; id?: string; href?: string }
33
		parent?: { key?: string; id?: string; name?: string; href?: string }
34
		item?: { key?: string; id?: string; name?: string; href?: string }
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/construction/standard-cost-type/${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