0

Update a customer email template

by
Published Oct 17, 2025

Updates an existing customer email template 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 customer email template
7
 * Updates an existing customer email template 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
		customer?: { key?: string; id?: string; href?: string }
17
		txnDefinition?: { href?: string; key?: string; id?: string }
18
		emailTemplate?: {
19
			key?: string
20
			id?: string
21
			name?: string
22
			templateType?: 'arInvoice' | 'arStatement' | 'contract' | 'orderEntryTxn' | 'purchasingTxn'
23
			href?: string
24
		}
25
	} & { id?: {} }
26
) {
27
	const url = new URL(
28
		`https://api.intacct.com/ia/api/v1/objects/accounts-receivable/customer-email-template/${key}`
29
	)
30

31
	const response = await fetch(url, {
32
		method: 'PATCH',
33
		headers: {
34
			'Content-Type': 'application/json',
35
			Authorization: 'Bearer ' + auth.token
36
		},
37
		body: JSON.stringify(body)
38
	})
39
	if (!response.ok) {
40
		const text = await response.text()
41
		throw new Error(`${response.status} ${text}`)
42
	}
43
	return await response.json()
44
}
45