0

Create a warehouse

by
Published Oct 17, 2025

Creates a new warehouse. For a warehouse hierarchy, create the parent warehouses before adding child warehouses. Permissions and other requirements SubscriptionInventory Control User typeBusiness PermissionsList, View, Add Warehouses

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 warehouse
7
 * Creates a new warehouse. For a warehouse hierarchy, create the parent warehouses before adding child warehouses.
8

9

10
Permissions and other requirements
11

12
SubscriptionInventory Control
13
User typeBusiness
14
PermissionsList, View, Add Warehouses
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' | 'inactive'
28
		isReplenishmentEnabled?: false | true
29
		enableNegativeInv?: false | true
30
		location?: { id?: string; key?: string; href?: string }
31
		parent?: { id?: string; key?: string; href?: string }
32
		manager?: { id?: string; key?: string; href?: string }
33
		contacts?: {
34
			primary?: { id?: string; key?: string; href?: string }
35
			shipTo?: { id?: string; key?: string; href?: string }
36
		}
37
		audit?: {
38
			createdDateTime?: string
39
			modifiedDateTime?: string
40
			createdBy?: string
41
			modifiedBy?: string
42
		}
43
		entity?: { key?: string; id?: string; name?: string; href?: string }
44
	} & {}
45
) {
46
	const url = new URL(`https://api.intacct.com/ia/api/v1/objects/inventory-control/warehouse`)
47

48
	const response = await fetch(url, {
49
		method: 'POST',
50
		headers: {
51
			'Content-Type': 'application/json',
52
			Authorization: 'Bearer ' + auth.token
53
		},
54
		body: JSON.stringify(body)
55
	})
56
	if (!response.ok) {
57
		const text = await response.text()
58
		throw new Error(`${response.status} ${text}`)
59
	}
60
	return await response.json()
61
}
62