0

Create a timesheet line

by
Published Oct 17, 2025

Creates a new timesheet line. Permissions and other requirements SubscriptionTime & Expenses User typeBusiness, Project Manager, or Employee PermissionsAdd timesheets

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 timesheet line
7
 * Creates a new timesheet line.
8

9

10
Permissions and other requirements
11

12
SubscriptionTime & Expenses
13
User typeBusiness, Project Manager, or Employee
14
PermissionsAdd timesheets
15

16

17

18

19
 */
20
export async function main(
21
	auth: SageIntacct,
22
	body: {
23
		key?: string
24
		id?: string
25
		href?: string
26
		timesheet?: { key?: string; id?: string; href?: string }
27
		entryDate?: string
28
		quantity?: number
29
		lineNumber?: number
30
		description?: string
31
		notes?: string
32
		state?:
33
			| 'submitted'
34
			| 'approved'
35
			| 'partiallyApproved'
36
			| 'declined'
37
			| 'draft'
38
			| 'saved'
39
			| 'readyForApproval'
40
		timeType?: { key?: string; id?: string; href?: string }
41
		isBillable?: false | true
42
		isBilled?: 'true' | 'false' | 'partial'
43
		statisticalJournal?: { key?: string; id?: string; href?: string }
44
		billableUtilizedGLAccount?: { key?: string; id?: string; href?: string }
45
		nonBillableUtilizedGLAccount?: { key?: string; id?: string; href?: string }
46
		billableNonUtilizedGLAccount?: { key?: string; id?: string; href?: string }
47
		nonBillableNonUtilizedGLAccount?: {
48
			key?: string
49
			id?: string
50
			href?: string
51
		}
52
		hours?: {
53
			billable?: number
54
			nonBillable?: number
55
			approved?: number
56
			approvedBillable?: number
57
			approvedNonBillable?: number
58
			utilized?: number
59
			nonUtilized?: number
60
			approvedUtilized?: number
61
			approvedNonUtilized?: number
62
		}
63
		externalPayroll?: {
64
			costRate?: number
65
			billingRate?: number
66
			amount?: string
67
			employerTaxes?: number
68
			fringes?: number
69
			cashFringes?: number
70
		}
71
		laborClass?: { key?: string; id?: string; name?: string; href?: string }
72
		laborShift?: { key?: string; id?: string; name?: string; href?: string }
73
		laborUnion?: { key?: string; id?: string; name?: string; href?: string }
74
		dimensions?: {
75
			location?: { key?: string; id?: string; name?: string; href?: string }
76
			department?: { key?: string; id?: string; name?: string; href?: string }
77
			employee?: { key?: string; id?: string; name?: string; href?: string }
78
			project?: { key?: string; id?: string; name?: string; href?: string }
79
			customer?: { key?: string; id?: string; name?: string; href?: string }
80
			vendor?: { key?: string; id?: string; name?: string; href?: string }
81
			item?: { key?: string; id?: string; name?: string; href?: string }
82
			warehouse?: { key?: string; id?: string; name?: string; href?: string }
83
			class?: { key?: string; id?: string; name?: string; href?: string }
84
			task?: { id?: string; key?: string; name?: string; href?: string }
85
			costType?: { id?: string; key?: string; name?: string; href?: string }
86
			asset?: { id?: string; key?: string; name?: string; href?: string }
87
			contract?: { id?: string; key?: string; name?: string; href?: string }
88
			affiliateEntity?: {
89
				key?: string
90
				id?: string
91
				href?: string
92
				name?: string
93
			}
94
		} & {
95
			location?: { key?: string; id?: string; name?: string; href?: string }
96
			department?: { key?: string; id?: string; name?: string; href?: string }
97
		}
98
		audit?: {
99
			createdDateTime?: string
100
			modifiedDateTime?: string
101
			createdBy?: string
102
			modifiedBy?: string
103
		}
104
	} & {}
105
) {
106
	const url = new URL(`https://api.intacct.com/ia/api/v1/objects/time/timesheet-line`)
107

108
	const response = await fetch(url, {
109
		method: 'POST',
110
		headers: {
111
			'Content-Type': 'application/json',
112
			Authorization: 'Bearer ' + auth.token
113
		},
114
		body: JSON.stringify(body)
115
	})
116
	if (!response.ok) {
117
		const text = await response.text()
118
		throw new Error(`${response.status} ${text}`)
119
	}
120
	return await response.json()
121
}
122