0

Update a kit component

by
Published Oct 17, 2025

Updates an existing kit component by setting field values. Any fields not provided remain unchanged.

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 kit component
7
 * Updates an existing kit component by setting field values. Any fields not provided remain unchanged.
8
 */
9
export async function main(
10
	auth: SageIntacct,
11
	key: string,
12
	body: {
13
		key?: string
14
		id?: string
15
		kit?: { key?: string; id?: string; href?: string }
16
		component?: {
17
			key?: string
18
			id?: string
19
			href?: string
20
			name?: string
21
			costMethod?: 'standard' | 'average' | 'FIFO' | 'LIFO'
22
			itemType?:
23
				| 'inventory'
24
				| 'nonInventory'
25
				| 'purchaseOnlyNonInventory'
26
				| 'salesOnlyNonInventory'
27
				| 'kit'
28
				| 'stockableKit'
29
			standardCost?: string
30
			unitOfMeasure?: string
31
		}
32
		numberOfUnits?: number
33
		revenuePercentage?: number
34
		defaultDeliveryStatus?: 'delivered' | 'undelivered'
35
		defaultDeferralStatus?: 'deferUntilItemIsDelivered' | 'deferBundleUntilItemIsDelivered'
36
		lineNumber?: number
37
		href?: string
38
		audit?: {
39
			createdDateTime?: string
40
			modifiedDateTime?: string
41
			createdBy?: string
42
			modifiedBy?: string
43
		}
44
	} & { id?: {} }
45
) {
46
	const url = new URL(
47
		`https://api.intacct.com/ia/api/v1/objects/inventory-control/kit-component/${key}`
48
	)
49

50
	const response = await fetch(url, {
51
		method: 'PATCH',
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