0

Update an item warehouse standard cost object

by
Published Oct 17, 2025

Updates an existing item warehouse standard cost object 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 warehouse standard cost object
7
 * Updates an existing item warehouse standard cost object 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
		href?: string
16
		effectiveStartDate?: string
17
		standardCost?: string
18
		itemWarehouse?: {
19
			key?: string
20
			id?: string
21
			href?: string
22
			itemId?: string
23
			warehouseId?: string
24
		}
25
		audit?: {
26
			createdDateTime?: string
27
			modifiedDateTime?: string
28
			createdBy?: string
29
			modifiedBy?: string
30
		}
31
	} & {}
32
) {
33
	const url = new URL(
34
		`https://api.intacct.com/ia/api/v1/objects/inventory-control/item-warehouse-standard-cost/${key}`
35
	)
36

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