0

Update a contract type

by
Published Oct 17, 2025

Updates an existing contract type 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 contract type
7
 * Updates an existing contract type 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
		description?: string
16
		href?: string
17
		parent?: { key?: string; id?: string; href?: string }
18
		entity?: { key?: string; id?: string; name?: string; href?: string }
19
		status?: 'active' | 'inactive'
20
		audit?: {
21
			createdDateTime?: string
22
			modifiedDateTime?: string
23
			createdBy?: string
24
			modifiedBy?: string
25
			createdByUser?: { key?: string; id?: string; href?: string }
26
			modifiedByUser?: { key?: string; id?: string; href?: string }
27
		}
28
	} & { id?: {} }
29
) {
30
	const url = new URL(`https://api.intacct.com/ia/api/v1/objects/contracts/contract-type/${key}`)
31

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