0

Create a bill

by
Published Oct 17, 2025

Creates a new bill. After you create a bill, it can be moved through the normal Accounts Payable workflow. Permissions and other requirements SubscriptionAccounts Payable User typeBusiness PermissionsList, View, Add Bills

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 bill
7
 * Creates a new bill. After you create a bill, it can be moved through the normal Accounts Payable workflow.
8

9

10
Permissions and other requirements
11

12
SubscriptionAccounts Payable
13
User typeBusiness
14
PermissionsList, View, Add Bills
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
		billNumber?: string
27
		state?:
28
			| 'reversed'
29
			| 'reversal'
30
			| 'analyzing'
31
			| 'partiallyApproved'
32
			| 'submitted'
33
			| 'declined'
34
			| 'noValue'
35
			| 'posted'
36
			| 'paid'
37
			| 'partiallyPaid'
38
			| 'selected'
39
			| 'draft'
40
		recordType?: string
41
		vendor?: {
42
			key?: string
43
			id?: string
44
			name?: string
45
			href?: string
46
			vendorDue?: string
47
			form1099?: {
48
				type?: string
49
				box?: string
50
				vendorTypeForm1099Type?: string
51
			}
52
		}
53
		term?: { key?: string; id?: string; href?: string }
54
		referenceNumber?: string
55
		description?: string
56
		dueInDays?: string
57
		postingDate?: string
58
		discountCutOffDate?: string
59
		dueDate?: string
60
		recommendedPaymentDate?: string
61
		createdDate?: string
62
		isOnHold?: false | true
63
		isTaxInclusive?: false | true
64
		paymentPriority?: 'urgent' | 'high' | 'normal' | 'low'
65
		totalBaseAmount?: string
66
		totalBaseAmountDue?: string
67
		totalTxnAmount?: string
68
		totalTxnAmountDue?: string
69
		isSystemGenerated?: false | true
70
		purchasing?: { id?: string; key?: string; href?: string }
71
		recurringSchedule?: { key?: string; id?: string; href?: string }
72
		contacts?: {
73
			payTo?: {
74
				key?: string
75
				id?: string
76
				tax?: {
77
					taxId?: string
78
					group?: { key?: string; id?: string; href?: string }
79
				}
80
				href?: string
81
			}
82
			returnTo?: { key?: string; id?: string; href?: string }
83
		}
84
		currency?: {
85
			baseCurrency?: string
86
			txnCurrency?: string
87
			exchangeRate?: { date?: string; rate?: number; typeId?: string }
88
		}
89
		taxSolution?: {
90
			key?: string
91
			id?: string
92
			showMultiLineTax?: string
93
			taxCalculationMethod?: string
94
			method?: string
95
			href?: string
96
		}
97
		billSummary?: {
98
			key?: string
99
			id?: string
100
			name?: string
101
			isSummaryOpen?: 'open' | 'closed'
102
			isSummaryPosted?: string
103
			href?: string
104
		}
105
		sourceModule?: 'accountsPayable' | 'purchasing'
106
		paymentInformation?: {
107
			fullyPaidDate?: string
108
			totalBaseAmountPaid?: string
109
			totalBaseAmountSelectedForPayment?: string
110
			totalTxnAmountSelectedForPayment?: string
111
			totalTxnAmountPaid?: string
112
		}
113
		retainage?: {
114
			defaultPercentage?: string
115
			totalTxnAmountRetained?: string
116
			totalTxnAmountReleased?: string
117
			totalBaseAmountRetained?: string
118
		}
119
		billBackTemplate?: {
120
			key?: string
121
			id?: string
122
			enableInterEntityPostings?: false | true
123
			href?: string
124
		}
125
		attachment?: { key?: string; id?: string; href?: string }
126
		location?: { key?: string; id?: string; name?: string; href?: string }
127
		lines?: {
128
			id?: string
129
			key?: string
130
			href?: string
131
			lineNumber?: string
132
			hasForm1099?: string
133
			form1099?: { type?: string; box?: string }
134
			createdDate?: string
135
			glAccount?: { key?: string; id?: string; name?: string; href?: string }
136
			overrideOffsetGLAccount?: {
137
				key?: string
138
				id?: string
139
				name?: string
140
				href?: string
141
			}
142
			accountLabel?: { key?: string; id?: string; href?: string }
143
			baseAmount?: string
144
			txnAmount?: string
145
			totalTxnAmount?: string
146
			memo?: string
147
			allocation?: { key?: string; id?: string; href?: string }
148
			currency?: {
149
				baseCurrency?: string
150
				txnCurrency?: string
151
				exchangeRate?: { date?: string; rate?: number; typeId?: string }
152
			}
153
			paymentInformation?: {
154
				totalBaseAmountPaid?: string
155
				totalTxnAmountPaid?: string
156
				totalBaseAmountSelectedForPayment?: string
157
				totalTxnAmountSelectedForPayment?: string
158
			}
159
			releaseToPay?: false | true
160
			isSubTotal?: 'subtotal' | 'tax'
161
			baseLocation?: {
162
				key?: string
163
				id?: string
164
				name?: string
165
				href?: string
166
			} & { key?: string }
167
			retainage?: {
168
				hasRetainage?: false | true
169
				percentage?: string
170
				baseAmountRetained?: string
171
				txnAmountRetained?: string
172
				txnAmountReleased?: string
173
				release?: false | true
174
			}
175
			project?: { isBillable?: false | true; isBilled?: false | true }
176
			fixedAsset?: {
177
				nameOfAcquiredAsset?: string
178
				includeTaxInAssetCost?: false | true
179
			}
180
			purchasing?: {
181
				document?: { key?: string; id?: string; href?: string }
182
				documentLine?: { key?: string; id?: string; href?: string }
183
			}
184
			taxEntries?: {
185
				key?: string
186
				id?: string
187
				baseTaxAmount?: string
188
				txnTaxAmount?: string
189
				taxRate?: number
190
			} & {
191
				purchasingTaxDetail?: { key?: string; id?: string; href?: string }
192
				billLine?: { id?: string; key?: string; href?: string }
193
				isPartialExemption?: false | true
194
			}[]
195
			dimensions?: {
196
				location?: { key?: string; id?: string; name?: string; href?: string }
197
				department?: {
198
					key?: string
199
					id?: string
200
					name?: string
201
					href?: string
202
				}
203
				employee?: { key?: string; id?: string; name?: string; href?: string }
204
				project?: { key?: string; id?: string; name?: string; href?: string }
205
				customer?: { key?: string; id?: string; name?: string; href?: string }
206
				vendor?: { key?: string; id?: string; name?: string; href?: string }
207
				item?: { key?: string; id?: string; name?: string; href?: string }
208
				warehouse?: { key?: string; id?: string; name?: string; href?: string }
209
				class?: { key?: string; id?: string; name?: string; href?: string }
210
				task?: { id?: string; key?: string; name?: string; href?: string }
211
				costType?: { id?: string; key?: string; name?: string; href?: string }
212
				asset?: { id?: string; key?: string; name?: string; href?: string }
213
				contract?: { id?: string; key?: string; name?: string; href?: string }
214
				affiliateEntity?: {
215
					key?: string
216
					id?: string
217
					href?: string
218
					name?: string
219
				}
220
			} & {
221
				location?: { key?: string; id?: string; name?: string; href?: string }
222
				department?: {
223
					key?: string
224
					id?: string
225
					name?: string
226
					href?: string
227
				}
228
			}
229
			bill?: { id?: string; key?: string; href?: string }
230
		}[]
231
		entity?: { key?: string; id?: string; name?: string; href?: string }
232
		audit?: {
233
			createdDateTime?: string
234
			modifiedDateTime?: string
235
			createdBy?: string
236
			modifiedBy?: string
237
		}
238
	} & { vendor?: {}; currency?: {}; lines?: { dimensions?: {} }[] }
239
) {
240
	const url = new URL(`https://api.intacct.com/ia/api/v1/objects/accounts-payable/bill`)
241

242
	const response = await fetch(url, {
243
		method: 'POST',
244
		headers: {
245
			'Content-Type': 'application/json',
246
			Authorization: 'Bearer ' + auth.token
247
		},
248
		body: JSON.stringify(body)
249
	})
250
	if (!response.ok) {
251
		const text = await response.text()
252
		throw new Error(`${response.status} ${text}`)
253
	}
254
	return await response.json()
255
}
256