0

Update a customer type

by
Published Oct 17, 2025

Updates an existing customer type by setting field values. Any fields not provided remain unchanged. Permissions and other requirements SubscriptionAccounts Receivable User typeBusiness PermissionsList, View, Edit Customer Types

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 customer type
7
 * Updates an existing customer type by setting field values. Any fields not provided remain unchanged.
8

9

10
Permissions and other requirements
11

12
SubscriptionAccounts Receivable
13
User typeBusiness
14
PermissionsList, View, Edit Customer Types
15

16

17

18

19
 */
20
export async function main(
21
	auth: SageIntacct,
22
	key: string,
23
	body: {
24
		key?: string
25
		id?: string
26
		href?: string
27
		status?: 'active' | 'inactive'
28
		parent?: { key?: string; id?: string; href?: string }
29
		audit?: {
30
			createdDateTime?: string
31
			modifiedDateTime?: string
32
			createdBy?: string
33
			modifiedBy?: string
34
		}
35
		entity?: { key?: string; id?: string; name?: string; href?: string }
36
	} & { id?: {} }
37
) {
38
	const url = new URL(
39
		`https://api.intacct.com/ia/api/v1/objects/accounts-receivable/customer-type/${key}`
40
	)
41

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