0

Create a folder

by
Published Oct 17, 2025

Creates a new folder for attachments. Permissions and other requirements SubscriptionCompany User typeBusiness PermissionsAdd Attachment Folders

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
 * Create a folder
7
 * Creates a new folder for attachments.
8

9

10
Permissions and other requirements
11

12
SubscriptionCompany
13
User typeBusiness
14
PermissionsAdd Attachment Folders
15

16

17

18

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

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