0

Update an item

by
Published Oct 17, 2025

Updates an existing item 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 an item
7
 * Updates an existing item 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
		name?: string
16
		status?: 'active' | 'inactive'
17
		itemType?:
18
			| 'inventory'
19
			| 'nonInventory'
20
			| 'purchaseOnlyNonInventory'
21
			| 'salesOnlyNonInventory'
22
			| 'kit'
23
			| 'stockableKit'
24
		enableFulfillment?: false | true
25
		isItemEnabledForMRR?: false | true
26
		productLine?: { key?: string; id?: string; href?: string }
27
		costMethod?: 'standard' | 'average' | 'FIFO' | 'LIFO'
28
		extendedDescription?: string
29
		poDescription?: string
30
		soDescription?: string
31
		unitOfMeasureGroup?: { key?: string; id?: string; href?: string }
32
		notes?: string
33
		dateLastSold?: string
34
		dateLastReceived?: string
35
		isSuppliesItem?: false | true
36
		quantityOnOrder?: string
37
		quantityInTransit?: string
38
		quantityOnHand?: string
39
		quantityOnHold?: string
40
		quantityReserved?: string
41
		quantityAllocated?: string
42
		quantityUncommitted?: string
43
		inventory?: {
44
			shippingWeight?: number
45
			autoPrintLabel?: false | true
46
			glGroup?: {
47
				id?: string
48
				key?: string
49
				defaultRevenueRecognitionTemplate?: string
50
				incomeGLAccount?: string
51
				inventoryGLAccount?: string
52
				expenseGLAccount?: string
53
				cogsGLAccount?: string
54
				arGLAccountNumber?: string
55
				apGLAccountNumber?: string
56
				deferredRevenueGLAccountNumber?: string
57
				href?: string
58
			}
59
		}
60
		vsoeCategory?:
61
			| 'productSpecified'
62
			| 'software'
63
			| 'productUnspecified'
64
			| 'upgradeUnspecified'
65
			| 'upgradeSpecified'
66
			| 'services'
67
			| 'postContractSupport'
68
		vsoeDefaultDeliveryStatus?: 'delivered' | 'undelivered'
69
		vsoeDefaultDeferralStatus?: 'deferUntilItemIsDelivered' | 'deferBundleUntilItemIsDelivered'
70
		substituteItemId?: string
71
		tracking?: {
72
			enableSerialNo?: false | true
73
			serialMask?: string
74
			enableLotCategory?: false | true
75
			lotCategory?: string
76
			enableBins?: false | true
77
			enableExpiration?: false | true
78
		}
79
		precision?: {
80
			upc?: string
81
			inventoryPrecision?: number
82
			salesPrecision?: number
83
			purchasingPrecision?: number
84
		}
85
		landedCost?: { enableLandedCost?: false | true }
86
		itemLandedCost?: {
87
			key?: string
88
			id?: string
89
			href?: string
90
			distributionMethod?: 'volume' | 'weight' | 'count'
91
			distributionMethodBaseUnit?: string
92
			landedCostValue?: string
93
			active?: false | true
94
			item?: { key?: string; id?: string; href?: string }
95
		}[]
96
		replenishment?: {
97
			enableReplenishment?: false | true
98
			unitOfMeasureDefault?: string
99
			safetyStock?: number
100
			maximumOrderQuantity?: number
101
			replenishmentMethod?:
102
				| ''
103
				| 'demandForecastBySingleValue'
104
				| 'reorderPoint'
105
				| 'demandForecastByFluctuatingValues'
106
			reorderPoint?: number
107
			reorderQuantity?: number
108
			forecastDemandInLeadTime?: number
109
		}
110
		itemDetails?: {
111
			primaryCountryOfOrigin?: string
112
			condition?: string
113
			engineeringAlert?: string
114
			specification1?: string
115
			specification2?: string
116
			specification3?: string
117
			universalProductCode?: number
118
			internationalArticleNumber?: number
119
			isSafetyItem?: false | true
120
			isRestrictedItem?: false | true
121
			isCompliantItem?: false | true
122
			isApprovedByEngineering?: false | true
123
			isApprovedByQualityControl?: false | true
124
			isApprovedBySales?: false | true
125
		}
126
		measurements?: {
127
			weightUnitOfMeasure?: { id?: string; key?: string; href?: string }
128
			netWeight?: number
129
			lengthWidthHeightUnitOfMeasure?: {
130
				id?: string
131
				key?: string
132
				href?: string
133
			}
134
			length?: number
135
			width?: number
136
			height?: number
137
			thicknessUnitOfMeasure?: { id?: string; key?: string; href?: string }
138
			thickness?: number
139
			minimumThickness?: number
140
			maximumThickness?: number
141
			areaUnitOfMeasure?: { id?: string; key?: string; href?: string }
142
			area?: number
143
			volumeUnitOfMeasure?: { id?: string; key?: string; href?: string }
144
			volume?: number
145
			densityUnitOfMeasure?: string
146
			density?: number
147
			durometerUnitOfMeasure?: string
148
			diameterUnitOfMeasure?: { id?: string; key?: string; href?: string }
149
			innerDiameter?: number
150
			outerDiameter?: number
151
		}
152
		commercial?: {
153
			brand?: string
154
			subBrand?: string
155
			category?: string
156
			subCategory?: string
157
			catalogReference?: string
158
			color?: string
159
			size1?: string
160
			size2?: string
161
			style?: string
162
			webName?: string
163
			webShortDiscription?: string
164
			webLongDescription?: string
165
			isGiftCard?: false | true
166
			isWebEnabled?: false | true
167
		}
168
		defaultConversionType?: 'quantity' | 'price'
169
		purchasing?: { standardCost?: string }
170
		sales?: {
171
			isTaxable?: false | true
172
			basePrice?: string
173
			isAvailableForDropShip?: false | true
174
			isAvailableForBuyToOrder?: false | true
175
			taxGroup?: { key?: string; id?: string; href?: string }
176
			taxSolution?: { key?: string; id?: string; href?: string }
177
			allowMultipleTaxGroups?: false | true
178
		}
179
		itemTaxMap?: {
180
			key?: string
181
			id?: string
182
			href?: string
183
			item?: { key?: string; id?: string; href?: string }
184
			taxSolution?: { key?: string; id?: string; href?: string }
185
			taxGroup?: { key?: string; id?: string; href?: string }
186
		}[]
187
		warehouseInfo?: {
188
			key?: string
189
			id?: string
190
			item?: { key?: string; id?: string; href?: string }
191
			warehouse?: { key?: string; id?: string; href?: string }
192
			storageArea?: string
193
			inventoryCycle?: { key?: string; id?: string; href?: string }
194
			economicOrderQuantity?: number
195
			standardCost?: string
196
			lastCost?: string
197
			averageCost?: string
198
			reorderMethod?: 'reorderPoint' | 'economicQuantity' | 'maxStockLevel'
199
			reorderPoint?: number
200
			reorderQuantity?: number
201
			minOrderQuantity?: number
202
			maxOrderQuantity?: number
203
			maximumStock?: number
204
			minimumStock?: number
205
			lastSoldDate?: string
206
			lastReceivedDate?: string
207
			defaultBin?: { key?: string; id?: string; href?: string }
208
			warehouseLocation?: {
209
				key?: string
210
				id?: string
211
				currency?: string
212
				href?: string
213
			}
214
			safetyStock?: number
215
			replenishmentMethod?:
216
				| 'demandForecastBySingleValue'
217
				| 'reorderPoint'
218
				| 'demandForecastByFluctuatingValues'
219
			enableReplenishment?: false | true
220
			onOrder?: number
221
			inTransit?: number
222
			onHand?: number
223
			onHold?: number
224
			reserved?: number
225
			allocated?: number
226
			unCommitted?: number
227
			href?: string
228
			itemWarehouseVendor?: {
229
				key?: string
230
				id?: string
231
				itemWarehouse?: { key?: string; id?: string; href?: string }
232
				vendor?: { key?: string; id?: string; href?: string }
233
				stockNumber?: string
234
				leadTime?: number
235
				demandForecastDuringLeadTime?: number
236
				economicalOrderQuantity?: number
237
				vendorMinimumOrderQuantity?: number
238
				bestPrice?: string
239
				latestPrice?: string
240
				unitOfMeasure?: { key?: string; id?: string; href?: string }
241
				conversionFactor?: string
242
				isPreferredVendor?: false | true
243
				href?: string
244
			}[]
245
			standardCostEntries?: {
246
				key?: string
247
				id?: string
248
				href?: string
249
				effectiveStartDate?: string
250
				standardCost?: string
251
				itemWarehouse?: {
252
					key?: string
253
					id?: string
254
					href?: string
255
					itemId?: string
256
					warehouseId?: string
257
				}
258
				audit?: {
259
					createdDateTime?: string
260
					modifiedDateTime?: string
261
					createdBy?: string
262
					modifiedBy?: string
263
				}
264
			}[]
265
			audit?: {
266
				createdDateTime?: string
267
				modifiedDateTime?: string
268
				createdBy?: string
269
				modifiedBy?: string
270
			}
271
		}[]
272
		itemVendor?: {
273
			key?: string
274
			id?: string
275
			item?: { key?: string; id?: string; href?: string }
276
			vendor?: { key?: string; id?: string; href?: string }
277
			stockNumber?: string
278
			leadTime?: number
279
			demandForecastDuringLeadTime?: number
280
			economicalOrderQuantity?: number
281
			vendorMinimumOrderQuantity?: number
282
			bestPrice?: string
283
			latestPrice?: string
284
			unitOfMeasure?: { key?: string; id?: string; href?: string }
285
			conversionFactor?: string
286
			isPreferredVendor?: false | true
287
			href?: string
288
		}[]
289
		isEnabledForContracts?: false | true
290
		kitRevenuePosting?: 'componentLevel' | 'kitLevel'
291
		kitRevenuePrinting?: 'kit' | 'individualComponents'
292
		kitComponents?: {
293
			key?: string
294
			id?: string
295
			kit?: { key?: string; id?: string; href?: string }
296
			component?: {
297
				key?: string
298
				id?: string
299
				href?: string
300
				name?: string
301
				costMethod?: 'standard' | 'average' | 'FIFO' | 'LIFO'
302
				itemType?:
303
					| 'inventory'
304
					| 'nonInventory'
305
					| 'purchaseOnlyNonInventory'
306
					| 'salesOnlyNonInventory'
307
					| 'kit'
308
					| 'stockableKit'
309
				standardCost?: string
310
				unitOfMeasure?: string
311
			}
312
			numberOfUnits?: number
313
			revenuePercentage?: number
314
			defaultDeliveryStatus?: 'delivered' | 'undelivered'
315
			defaultDeferralStatus?: 'deferUntilItemIsDelivered' | 'deferBundleUntilItemIsDelivered'
316
			lineNumber?: number
317
			href?: string
318
			audit?: {
319
				createdDateTime?: string
320
				modifiedDateTime?: string
321
				createdBy?: string
322
				modifiedBy?: string
323
			}
324
		}[]
325
		contractTerm?: {
326
			isStartDateAndEndDateEnabled?: false | true
327
			periodsMeasuredIn?: 'days' | 'weeks' | 'months' | 'years'
328
			numberOfPeriods?: number
329
			isProratedPricingAllowed?: false | true
330
			defaultRenewalTemplate?: { key?: string; id?: string; href?: string }
331
		}
332
		contractDefault?: {
333
			billingTemplate?: { key?: string; id?: string; href?: string }
334
			revRecTemplate1?: { key?: string; id?: string; href?: string }
335
			revRecTemplate2?: { key?: string; id?: string; href?: string }
336
			expenseTemplate1?: { key?: string; id?: string; href?: string }
337
			expenseTemplate2?: { key?: string; id?: string; href?: string }
338
			contractFairValueCategory?: { key?: string; id?: string; href?: string }
339
			defaultContractDeliveryStatus?: 'delivered' | 'undelivered'
340
			defaultContractDeferralStatus?:
341
				| 'deferRevenueUntilItemIsDelivered'
342
				| 'deferRevenueUntilAllItemsAreDelivered'
343
			isDefaultBundle?: false | true
344
		}
345
		itemCrossReference?: {
346
			key?: string
347
			id?: string
348
			href?: string
349
			referenceType?: 'customer' | 'vendor' | 'substitute' | 'upgrade' | 'downgrade' | 'complement'
350
			itemAliasId?: string
351
			itemAliasDescription?: string
352
			unitOfMeasure?: { key?: string; id?: string; href?: string }
353
			referenceTypeContext?: 'internal' | 'external'
354
			alternateItem?: {
355
				key?: string
356
				id?: string
357
				name?: string
358
				href?: string
359
			}
360
			customer?: { key?: string; id?: string; name?: string; href?: string }
361
			item?: { key?: string; id?: string; name?: string; href?: string }
362
			vendor?: { key?: string; id?: string; name?: string; href?: string }
363
			audit?: {
364
				createdDateTime?: string
365
				modifiedDateTime?: string
366
				createdBy?: string
367
				modifiedBy?: string
368
			}
369
		}[]
370
		href?: string
371
		entity?: { key?: string; id?: string; name?: string; href?: string }
372
		audit?: {
373
			createdDateTime?: string
374
			modifiedDateTime?: string
375
			createdBy?: string
376
			modifiedBy?: string
377
		}
378
	} & { id?: {}; costMethod?: {}; itemType?: {} }
379
) {
380
	const url = new URL(`https://api.intacct.com/ia/api/v1/objects/inventory-control/item/${key}`)
381

382
	const response = await fetch(url, {
383
		method: 'PATCH',
384
		headers: {
385
			'Content-Type': 'application/json',
386
			Authorization: 'Bearer ' + auth.token
387
		},
388
		body: JSON.stringify(body)
389
	})
390
	if (!response.ok) {
391
		const text = await response.text()
392
		throw new Error(`${response.status} ${text}`)
393
	}
394
	return await response.json()
395
}
396