0

Create a recurring invoice

by
Published Oct 17, 2025

Creates a new recurring invoice. Permissions and other requirements SubscriptionAccounts Receivable User typeBusiness/Admin, Employee, Approver PermissionsList, View, Add Recurring invoices

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 recurring invoice
7
 * Creates a new recurring invoice.
8

9

10
Permissions and other requirements
11

12
SubscriptionAccounts Receivable
13
User typeBusiness/Admin, Employee, Approver
14
PermissionsList, View, Add Recurring invoices
15

16

17

18

19
 */
20
export async function main(
21
	auth: SageIntacct,
22
	body: {
23
		key?: string
24
		id?: string
25
		href?: string
26
		invoiceNumber?: string
27
		totalEntered?: string
28
		taxSolution?: { key?: string; id?: string; href?: string }
29
		description?: string
30
		referenceNumber?: string
31
		scheduledOperation?: { key?: string; id?: string; href?: string }
32
		schedule?: {
33
			startDate?: string
34
			endDate?: string
35
			repeatCount?: string
36
			repeatInterval?: string
37
			repeatBy?: 'none' | 'day' | 'week' | 'month' | 'year' | 'endOfMonth'
38
			scheduleEnd?: 'never' | 'numberOfOccurrences' | 'endDate'
39
			nextExecutionDate?: string
40
			lastExecutionDate?: string
41
			txnCount?: number
42
		}
43
		term?: { key?: string; id?: string; href?: string }
44
		contract?: { id?: string; description?: string }
45
		currency?: {
46
			baseCurrency?: string
47
			txnCurrency?: string
48
			exchangeRate?: number
49
			exchangeRateTypeId?: string
50
		}
51
		customerMessage?: {
52
			key?: string
53
			id?: string
54
			message?: string
55
			href?: string
56
		}
57
		txnTotalEntered?: string
58
		contacts?: {
59
			billTo?: { key?: string; id?: string; href?: string }
60
			shipTo?: {
61
				key?: string
62
				id?: string
63
				tax?: {
64
					taxId?: string
65
					group?: { key?: string; id?: string; href?: string }
66
				}
67
				href?: string
68
			}
69
		}
70
		customer?: { key?: string; id?: string; name?: string; href?: string }
71
		payment?: {
72
			paymentMethod?:
73
				| 'none'
74
				| 'printedCheck'
75
				| 'creditCard'
76
				| 'eft'
77
				| 'cash'
78
				| 'onlineChargeCard'
79
				| 'onlineAchDebit'
80
			paymentAmount?: string
81
			creditCardType?: 'visa' | 'mc' | 'discover' | 'amex' | 'diners' | 'other'
82
			accountType?: 'bank' | 'undepositedFundsAccount'
83
			payInFull?: false | true
84
			bankAccountID?: string
85
			undepositedFundsAccountId?: string
86
			customerCreditCard?: { key?: string; id?: string }
87
		}
88
		attachment?: { key?: string; id?: string; href?: string }
89
		lines?: {
90
			key?: string
91
			id?: string
92
			href?: string
93
			description?: string
94
			amount?: string
95
			lineNumber?: number
96
			txnAmount?: string
97
			totalTxnAmount?: string
98
			isBillable?: false | true
99
			currency?: {
100
				baseCurrency?: string
101
				txnCurrency?: string
102
				exchangeRateDate?: string
103
				exchangeRate?: number
104
				exchangeRateTypeId?: string
105
			}
106
			isTax?: false | true
107
			isSubTotal?: false | true
108
			allocation?: { key?: string; id?: string; href?: string }
109
			accountLabel?: { key?: string; id?: string; href?: string }
110
			taxDetail?: {
111
				key?: string
112
				id?: string
113
				taxRate?: string
114
				href?: string
115
			}
116
			startDate?: string
117
			endDate?: string
118
			deferredRevenueGLAccount?: {
119
				key?: string
120
				id?: string
121
				name?: string
122
				href?: string
123
			}
124
			glAccount?: { key?: string; id?: string; name?: string; href?: string }
125
			dimensions?: {
126
				location?: { key?: string; id?: string; name?: string; href?: string }
127
				department?: {
128
					key?: string
129
					id?: string
130
					name?: string
131
					href?: string
132
				}
133
				employee?: { key?: string; id?: string; name?: string; href?: string }
134
				project?: { key?: string; id?: string; name?: string; href?: string }
135
				customer?: { key?: string; id?: string; name?: string; href?: string }
136
				vendor?: { key?: string; id?: string; name?: string; href?: string }
137
				item?: { key?: string; id?: string; name?: string; href?: string }
138
				warehouse?: { key?: string; id?: string; name?: string; href?: string }
139
				class?: { key?: string; id?: string; name?: string; href?: string }
140
				task?: { id?: string; key?: string; name?: string; href?: string }
141
				costType?: { id?: string; key?: string; name?: string; href?: string }
142
				asset?: { id?: string; key?: string; name?: string; href?: string }
143
				contract?: { id?: string; key?: string; name?: string; href?: string }
144
				affiliateEntity?: {
145
					key?: string
146
					id?: string
147
					href?: string
148
					name?: string
149
				}
150
			} & {
151
				location?: { key?: string; id?: string; name?: string; href?: string }
152
				department?: {
153
					key?: string
154
					id?: string
155
					name?: string
156
					href?: string
157
				}
158
			}
159
			offsetGLAccount?: {
160
				key?: string
161
				id?: string
162
				name?: string
163
				href?: string
164
			}
165
			taxEntries?: {
166
				key?: string
167
				id?: string
168
				baseTaxAmount?: string
169
				txnTaxAmount?: string
170
				taxRate?: number
171
			} & {
172
				orderEntryTaxDetail?: { key?: string; id?: string; href?: string }
173
				recurringInvoiceLine?: { id?: string; key?: string; href?: string }
174
			}[]
175
			recurringInvoice?: { id?: string; key?: string; href?: string }
176
			status?: 'active' | 'inactive'
177
			audit?: {
178
				createdDateTime?: string
179
				modifiedDateTime?: string
180
				createdBy?: string
181
				modifiedBy?: string
182
			}
183
		}[]
184
		audit?: {
185
			createdDateTime?: string
186
			modifiedDateTime?: string
187
			createdBy?: string
188
			modifiedBy?: string
189
		}
190
		status?: 'active' | 'inactive'
191
		entity?: { key?: string; id?: string; name?: string; href?: string }
192
	} & {
193
		customer?: {}
194
		term?: {}
195
		currency?: {}
196
		schedule?: {}
197
		lines?: { glAccount?: {} }[]
198
	}
199
) {
200
	const url = new URL(
201
		`https://api.intacct.com/ia/api/v1/objects/accounts-receivable/recurring-invoice`
202
	)
203

204
	const response = await fetch(url, {
205
		method: 'POST',
206
		headers: {
207
			'Content-Type': 'application/json',
208
			Authorization: 'Bearer ' + auth.token
209
		},
210
		body: JSON.stringify(body)
211
	})
212
	if (!response.ok) {
213
		const text = await response.text()
214
		throw new Error(`${response.status} ${text}`)
215
	}
216
	return await response.json()
217
}
218