0

Create an exchange rate

by
Published Oct 17, 2025

Creates a new exchange rate.

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 an exchange rate
7
 * Creates a new exchange rate.
8
 */
9
export async function main(
10
	auth: SageIntacct,
11
	body: {
12
		key?: string
13
		id?: string
14
		href?: string
15
		fromCurrency?: string
16
		toCurrency?: string
17
		exchangeRateType?: {
18
			key?: string
19
			id?: string
20
			name?: string
21
			href?: string
22
		}
23
		lines?: {
24
			key?: string
25
			id?: string
26
			href?: string
27
			effectiveStartDate?: string
28
			rate?: number
29
			reciprocalRate?: number
30
			exchangeRate?: { key?: string; id?: string; href?: string }
31
			audit?: {
32
				createdDateTime?: string
33
				modifiedDateTime?: string
34
				createdBy?: string
35
				modifiedBy?: string
36
			}
37
		}[]
38
		audit?: {
39
			createdDateTime?: string
40
			modifiedDateTime?: string
41
			createdBy?: string
42
			modifiedBy?: string
43
		}
44
	} & {}
45
) {
46
	const url = new URL(`https://api.intacct.com/ia/api/v1/objects/company-config/exchange-rate`)
47

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