0

Create a customer

by
Published Oct 17, 2025

Creates a new customer. Permissions and other requirements SubscriptionAccounts Receivable User typeBusiness PermissionsList, View, Add Customers

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

9

10
Permissions and other requirements
11

12
SubscriptionAccounts Receivable
13
User typeBusiness
14
PermissionsList, View, Add Customers
15

16

17

18

19
 */
20
export async function main(
21
	auth: SageIntacct,
22
	body: {
23
		key?: string
24
		id?: string
25
		name?: string
26
		href?: string
27
		status?: 'active' | 'activeNonPosting' | 'inactive'
28
		customerType?: { key?: string; id?: string; href?: string }
29
		parent?: { key?: string; id?: string; name?: string; href?: string }
30
		salesRepresentative?: {
31
			key?: string
32
			id?: string
33
			name?: string
34
			href?: string
35
		}
36
		taxId?: string
37
		defaultRevenueGLAccount?: {
38
			key?: string
39
			id?: string
40
			name?: string
41
			href?: string
42
		}
43
		shippingMethod?: { key?: string; id?: string; href?: string }
44
		creditLimit?: number
45
		isOnHold?: false | true
46
		contacts?: {
47
			default?: {
48
				key?: string
49
				id?: string
50
				href?: string
51
				lastName?: string
52
				firstName?: string
53
				middleName?: string
54
				prefix?: string
55
				printAs?: string
56
				email1?: string
57
				email2?: string
58
				phone1?: string
59
				phone2?: string
60
				mobile?: string
61
				pager?: string
62
				fax?: string
63
				URL1?: string
64
				URL2?: string
65
				companyName?: string
66
				mailingAddress?: {
67
					addressLine1?: string
68
					addressLine2?: string
69
					addressLine3?: string
70
					city?: string
71
					state?: string
72
					postCode?: string
73
					country?: string
74
				}
75
			} & {
76
				showInContactList?: false | true
77
				tax?: {
78
					isTaxable?: false | true
79
					group?: { key?: string; id?: string; href?: string }
80
				}
81
				electronicInvoiceDetails?: {
82
					legalCategory?: string
83
					mainActivity?: string
84
					typeOfCompany?: string
85
					registeredCapital?: number
86
					valueAddedTaxRegime?: string
87
				}
88
				internationalTaxId?: string
89
			}
90
			primary?: { key?: string; id?: string; href?: string }
91
			billTo?: { key?: string; id?: string; href?: string }
92
			shipTo?: { key?: string; id?: string; href?: string }
93
		}
94
		contactList?: {
95
			key?: string
96
			id?: string
97
			categoryName?: string
98
			href?: string
99
			contact?: { key?: string; id?: string; href?: string }
100
			audit?: {
101
				createdDateTime?: string
102
				modifiedDateTime?: string
103
				createdBy?: string
104
				modifiedBy?: string
105
			}
106
			customer?: { key?: string; id?: string; href?: string }
107
		}[]
108
		audit?: {
109
			createdDateTime?: string
110
			modifiedDateTime?: string
111
			createdBy?: string
112
			modifiedBy?: string
113
		}
114
		customerEmailTemplates?: {
115
			key?: string
116
			id?: string
117
			href?: string
118
			customer?: { key?: string; id?: string; href?: string }
119
			txnDefinition?: { href?: string; key?: string; id?: string }
120
			emailTemplate?: {
121
				key?: string
122
				id?: string
123
				name?: string
124
				templateType?: 'arInvoice' | 'arStatement' | 'contract' | 'orderEntryTxn' | 'purchasingTxn'
125
				href?: string
126
			}
127
		}[]
128
		discountPercent?: string
129
		term?: { key?: string; id?: string; href?: string }
130
		advanceBillBy?: string
131
		advanceBillByType?: '' | 'days' | 'months'
132
		totalDue?: string
133
		lastInvoiceCreatedDate?: string
134
		lastStatementGeneratedDate?: string
135
		resaleNumber?: number
136
		deliveryOptions?: 'print' | 'email' | 'both'
137
		overridePriceList?: 'customer' | 'billingContact' | 'shippingContact'
138
		customerMessage?: {
139
			key?: string
140
			id?: string
141
			message?: string
142
			href?: string
143
		}
144
		currency?: string
145
		emailOptIn?: false | true
146
		activationDate?: string
147
		subscriptionEndDate?: string
148
		territory?: { key?: string; id?: string; name?: string; href?: string }
149
		enableOnlineACHPayment?: false | true
150
		enableOnlineCardPayment?: false | true
151
		isOneTimeUse?: false | true
152
		accountGroup?: { key?: string; id?: string; href?: string }
153
		accountLabel?: { key?: string; id?: string; href?: string }
154
		attachment?: { key?: string; id?: string; href?: string }
155
		retainagePercentage?: number
156
		notes?: string
157
		priceList?: { key?: string; id?: string; href?: string }
158
		priceSchedule?: { key?: string; id?: string; href?: string }
159
		overrideOffsetGLAccount?: {
160
			key?: string
161
			id?: string
162
			name?: string
163
			href?: string
164
		}
165
		customerRestriction?: 'unrestricted' | 'rootOnly' | 'restricted'
166
		restrictedLocations?: {
167
			key?: string
168
			id?: string
169
			href?: string
170
			location?: { key?: string; id?: string; href?: string }
171
			locationGroup?: { key?: string; id?: string; href?: string }
172
			customer?: { key?: string; id?: string; href?: string }
173
		}[]
174
		restrictedDepartments?: {
175
			key?: string
176
			id?: string
177
			href?: string
178
			department?: { key?: string; id?: string; href?: string }
179
			departmentGroup?: { key?: string; id?: string; href?: string }
180
			customer?: { key?: string; id?: string; href?: string }
181
		}[]
182
		entity?: { key?: string; id?: string; name?: string; href?: string }
183
	} & {}
184
) {
185
	const url = new URL(`https://api.intacct.com/ia/api/v1/objects/accounts-receivable/customer`)
186

187
	const response = await fetch(url, {
188
		method: 'POST',
189
		headers: {
190
			'Content-Type': 'application/json',
191
			Authorization: 'Bearer ' + auth.token
192
		},
193
		body: JSON.stringify(body)
194
	})
195
	if (!response.ok) {
196
		const text = await response.text()
197
		throw new Error(`${response.status} ${text}`)
198
	}
199
	return await response.json()
200
}
201