0

Create a document sequence

by
Published Oct 17, 2025

Creates a new document sequence.

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 document sequence
7
 * Creates a new document sequence.
8
 */
9
export async function main(
10
	auth: SageIntacct,
11
	body: {
12
		key?: string
13
		id?: string
14
		printTitle?: string
15
		type?: 'numeric' | 'alpha'
16
		fixedLength?: string
17
		fixedPrefix?: string
18
		prefixSeparator?: string
19
		fixedSuffix?: string
20
		suffixSeparator?: string
21
		startingNumber?: number
22
		endingNumber?: number
23
		nextNumber?: number
24
		startingSequence?: string
25
		endingSequence?: string
26
		nextSequence?: string
27
		whenModified?: string
28
		entity?: { key?: string; id?: string; name?: string; href?: string }
29
		rollover?: {
30
			isEnabled?: false | true
31
			enabledDate?: string
32
			fiscalYearAffixPosition?: 'none' | 'prefix' | 'suffix'
33
			separator?: string
34
			fiscalYears?: {
35
				key?: string
36
				id?: string
37
				href?: string
38
				documentSequence?: { key?: string; id?: string; href?: string }
39
				fiscalYear?: number
40
				nextNumber?: number
41
				nextSequence?: string
42
				audit?: {
43
					createdDateTime?: string
44
					modifiedDateTime?: string
45
					createdBy?: string
46
					modifiedBy?: string
47
				}
48
			}[]
49
		}
50
		status?: 'active' | 'inactive'
51
		href?: string
52
		audit?: {
53
			createdDateTime?: string
54
			modifiedDateTime?: string
55
			createdBy?: string
56
			modifiedBy?: string
57
		}
58
	} & {}
59
) {
60
	const url = new URL(`https://api.intacct.com/ia/api/v1/objects/company-config/document-sequence`)
61

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