0

Update a vendor contact

by
Published Oct 17, 2025

Updates an existing vendor contact by setting field values. Any fields not provided remain unchanged. Changing a vendor contact only affects future transactions.

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

9
Changing a vendor contact only affects future transactions.
10
 */
11
export async function main(
12
	auth: SageIntacct,
13
	key: string,
14
	body: {
15
		key?: string
16
		id?: string
17
		href?: string
18
		categoryName?: string
19
		contact?: { key?: string; id?: string; href?: string }
20
		audit?: {
21
			createdDateTime?: string
22
			modifiedDateTime?: string
23
			createdBy?: string
24
			modifiedBy?: string
25
		}
26
		vendor?: { key?: string; id?: string; href?: string }
27
	} & { id?: {} }
28
) {
29
	const url = new URL(
30
		`https://api.intacct.com/ia/api/v1/objects/accounts-payable/vendor-contact/${key}`
31
	)
32

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