0

Update an email template

by
Published Oct 17, 2025

Updates an existing 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 an email template
7
 * Updates an existing 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
		status?: 'active' | 'inactive'
17
		name?: string
18
		description?: string
19
		email?: { replyTo?: string; to?: string; cc?: string; bcc?: string }
20
		subject?: string
21
		body?: string
22
		logo?: {
23
			isLogoIncluded?: false | true
24
			verticalPosition?: 'top' | 'bottom'
25
			horizontalPosition?: 'left' | 'right'
26
		}
27
		includeTxnAttachments?: false | true
28
		includeProjectInvoiceTxnAttachments?: false | true
29
		templateType?: 'arInvoice' | 'arStatement' | 'Contract' | 'orderEntryTxn' | 'purchasingTxn'
30
		useSendersPreferredDateFormat?: false | true
31
		audit?: {
32
			createdDateTime?: string
33
			modifiedDateTime?: string
34
			createdBy?: string
35
			modifiedBy?: string
36
		}
37
	} & { id?: {} }
38
) {
39
	const url = new URL(
40
		`https://api.intacct.com/ia/api/v1/objects/company-config/email-template/${key}`
41
	)
42

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