0

Update an attachment

by
Published Oct 17, 2025

Updates an existing attachment by setting field values. Any fields not provided remain unchanged. Use this operation to add, update, and delete files in attachments. Permissions and other requirements SubscriptionCompany User typeBusiness PermissionsEdit Attachments

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 attachment
7
 * Updates an existing attachment by setting field values. Any fields not provided remain unchanged. Use this operation to add, update, and delete files in attachments.
8

9

10
Permissions and other requirements
11

12
SubscriptionCompany
13
User typeBusiness
14
PermissionsEdit Attachments
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
		name?: string
27
		description?: string
28
		href?: string
29
		folder?: { key?: string; id?: string; href?: string }
30
		entity?: { key?: string; id?: string; name?: string; href?: string }
31
		files?: {
32
			key?: string
33
			id?: string
34
			href?: string
35
			name?: string
36
			size?: number
37
			data?: string
38
			attachment?: { id?: string; key?: string; href?: string }
39
		}[]
40
		audit?: {
41
			createdDate?: string
42
			modifiedDate?: string
43
			createdBy?: string
44
			modifiedBy?: string
45
		}
46
	} & { id?: {} }
47
) {
48
	const url = new URL(`https://api.intacct.com/ia/api/v1/objects/company-config/attachment/${key}`)
49

50
	const response = await fetch(url, {
51
		method: 'PATCH',
52
		headers: {
53
			'Content-Type': 'application/json',
54
			Authorization: 'Bearer ' + auth.token
55
		},
56
		body: JSON.stringify(body)
57
	})
58
	if (!response.ok) {
59
		const text = await response.text()
60
		throw new Error(`${response.status} ${text}`)
61
	}
62
	return await response.json()
63
}
64