0

Update a recurring invoice

by
Published Oct 17, 2025

Updates an existing recurring invoice by setting field values. Any fields not provided remain unchanged. Permissions and other requirements SubscriptionAccounts Receivable User typeBusiness PermissionsList, View, Edit 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
 * Update a recurring invoice
7
 * Updates an existing recurring invoice by setting field values. Any fields not provided remain unchanged.
8

9

10
Permissions and other requirements
11

12
SubscriptionAccounts Receivable
13
User typeBusiness
14
PermissionsList, View, Edit Recurring invoices
15

16

17

18

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

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