0

Update a time type

by
Published Oct 17, 2025

Updates an existing time type by setting field values. Any fields not provided remain unchanged. Permissions and other requirements SubscriptionProjects User typeBusiness, Project Manager, Employee PermissionsList, View, Edit Time 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 time type
7
 * Updates an existing time type by setting field values. Any fields not provided remain unchanged.
8

9

10
Permissions and other requirements
11

12
SubscriptionProjects
13
User typeBusiness, Project Manager, Employee
14
PermissionsList, View, Edit Time 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
		earningType?: { href?: string; key?: string; id?: string }
28
		glAccount?: { href?: string; key?: string; id?: string; name?: string }
29
		offsetGLAccount?: {
30
			href?: string
31
			key?: string
32
			id?: string
33
			name?: string
34
		}
35
		status?: 'active' | 'inactive'
36
		entity?: { key?: string; id?: string; name?: string; href?: string }
37
	} & { id?: {} }
38
) {
39
	const url = new URL(`https://api.intacct.com/ia/api/v1/objects/time/time-type/${key}`)
40

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