0

Create a contact

by
Published Oct 17, 2025

Creates a new contact. The contact's `entity` fields will be set to the entity that the OAuth access token is associated with when the contact is created. Permissions and other requirements SubscriptionCompany User typeBusiness user with admin privileges PermissionsAdd Contacts

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 contact
7
 * Creates a new contact. The contact's `entity` fields will be set to the entity that the OAuth access token is associated with when the contact is created.
8

9

10
Permissions and other requirements
11

12
SubscriptionCompany
13
User typeBusiness user with admin privileges
14
PermissionsAdd Contacts
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
		lastName?: string
27
		firstName?: string
28
		middleName?: string
29
		prefix?: string
30
		email1?: string
31
		email2?: string
32
		phone1?: string
33
		phone2?: string
34
		mobile?: string
35
		pager?: string
36
		fax?: string
37
		URL1?: string
38
		URL2?: string
39
		companyName?: string
40
		printAs?: string
41
		showInContactList?: false | true
42
		discount?: string
43
		status?: 'active' | 'inactive'
44
		entity?: { key?: string; id?: string; name?: string; href?: string }
45
		mailingAddress?: {
46
			addressLine1?: string
47
			addressLine2?: string
48
			addressLine3?: string
49
			city?: string
50
			state?: string
51
			postCode?: string
52
			country?: string
53
			isoCountryCode?: string
54
		}
55
		priceList?: { key?: string; id?: string; href?: string }
56
		priceSchedule?: { key?: string; id?: string; href?: string }
57
		tax?: {
58
			isTaxable?: false | true
59
			taxId?: string
60
			group?: { key?: string; id?: string; href?: string }
61
		}
62
	} & {}
63
) {
64
	const url = new URL(`https://api.intacct.com/ia/api/v1/objects/company-config/contact`)
65

66
	const response = await fetch(url, {
67
		method: 'POST',
68
		headers: {
69
			'Content-Type': 'application/json',
70
			Authorization: 'Bearer ' + auth.token
71
		},
72
		body: JSON.stringify(body)
73
	})
74
	if (!response.ok) {
75
		const text = await response.text()
76
		throw new Error(`${response.status} ${text}`)
77
	}
78
	return await response.json()
79
}
80