0

Create a kit component

by
Published Oct 17, 2025

Creates a new kit component.

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

47
	const response = await fetch(url, {
48
		method: 'POST',
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