0

Update an exchange rate

by
Published Oct 17, 2025

Updates an existing exchange rate 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 an exchange rate
7
 * Updates an existing exchange rate 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
		fromCurrency?: string
17
		toCurrency?: string
18
		exchangeRateType?: {
19
			key?: string
20
			id?: string
21
			name?: string
22
			href?: string
23
		}
24
		lines?: {
25
			key?: string
26
			id?: string
27
			href?: string
28
			effectiveStartDate?: string
29
			rate?: number
30
			reciprocalRate?: number
31
			exchangeRate?: { key?: string; id?: string; href?: string }
32
			audit?: {
33
				createdDateTime?: string
34
				modifiedDateTime?: string
35
				createdBy?: string
36
				modifiedBy?: string
37
			}
38
		}[]
39
		audit?: {
40
			createdDateTime?: string
41
			modifiedDateTime?: string
42
			createdBy?: string
43
			modifiedBy?: string
44
		}
45
	} & { exchangeRateType?: {}; toCurrency?: {} }
46
) {
47
	const url = new URL(
48
		`https://api.intacct.com/ia/api/v1/objects/company-config/exchange-rate/${key}`
49
	)
50

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