0

Update a project resource

by
Published Oct 17, 2025

Updates an existing project resource by setting field values. Any fields not provided remain unchanged.

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 project resource
7
 * Updates an existing project resource by setting field values. Any fields not provided remain unchanged.
8
 */
9
export async function main(
10
	auth: SageIntacct,
11
	key: string,
12
	body: {
13
		key?: string
14
		id?: string
15
		href?: string
16
		description?: string
17
		startDate?: string
18
		employee?: {
19
			href?: string
20
			key?: string
21
			id?: string
22
			startDate?: string
23
			endDate?: string
24
		}
25
		employeeContact?: { key?: string; id?: string; href?: string }
26
		item?: { href?: string; key?: string; id?: string; name?: string }
27
		pricing?: {
28
			laborPricingMethod?: 'billingRate' | 'costPlusFee'
29
			laborRate?: number
30
			expensePricingMethod?: 'billingRate' | 'costPlusFee'
31
			expenseRate?: number
32
			apPurchasingPricingMethod?: 'costPlusFee'
33
			apPurchasingRate?: number
34
		}
35
		project?: { href?: string; key?: string; id?: string; name?: string }
36
		audit?: {
37
			createdDateTime?: string
38
			modifiedDateTime?: string
39
			createdBy?: string
40
			modifiedBy?: string
41
		}
42
	}
43
) {
44
	const url = new URL(`https://api.intacct.com/ia/api/v1/objects/projects/project-resource/${key}`)
45

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