0

Create a customer email template

by
Published Oct 17, 2025

Creates a new customer email template.

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 a customer email template
7
 * Creates a new customer email template.
8
 */
9
export async function main(
10
	auth: SageIntacct,
11
	body: {
12
		key?: string
13
		id?: string
14
		href?: string
15
		customer?: { key?: string; id?: string; href?: string }
16
		txnDefinition?: { href?: string; key?: string; id?: string }
17
		emailTemplate?: {
18
			key?: string
19
			id?: string
20
			name?: string
21
			templateType?: 'arInvoice' | 'arStatement' | 'contract' | 'orderEntryTxn' | 'purchasingTxn'
22
			href?: string
23
		}
24
	} & { customer?: {}; emailTemplate?: {} }
25
) {
26
	const url = new URL(
27
		`https://api.intacct.com/ia/api/v1/objects/accounts-receivable/customer-email-template`
28
	)
29

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