0

Get push options

by
Published Oct 17, 2025

This is the generic documentation for creation and updating of data.

Script codat Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Codat = {
3
	encodedKey: string
4
}
5
/**
6
 * Get push options
7
 * This is the generic documentation for creation and updating of data.
8
 */
9
export async function main(
10
	auth: Codat,
11
	companyId: string,
12
	connectionId: string,
13
	dataType:
14
		| 'accountTransactions'
15
		| 'balanceSheet'
16
		| 'bankAccounts'
17
		| 'bankTransactions'
18
		| 'billCreditNotes'
19
		| 'billPayments'
20
		| 'bills'
21
		| 'cashFlowStatement'
22
		| 'chartOfAccounts'
23
		| 'company'
24
		| 'creditNotes'
25
		| 'customers'
26
		| 'directCosts'
27
		| 'directIncomes'
28
		| 'invoices'
29
		| 'itemReceipts'
30
		| 'items'
31
		| 'journalEntries'
32
		| 'journals'
33
		| 'paymentMethods'
34
		| 'payments'
35
		| 'profitAndLoss'
36
		| 'purchaseOrders'
37
		| 'salesOrders'
38
		| 'suppliers'
39
		| 'taxRates'
40
		| 'trackingCategories'
41
		| 'transfers'
42
		| 'banking-accountBalances'
43
		| 'banking-accounts'
44
		| 'banking-transactionCategories'
45
		| 'banking-transactions'
46
		| 'commerce-companyInfo'
47
		| 'commerce-customers'
48
		| 'commerce-disputes'
49
		| 'commerce-locations'
50
		| 'commerce-orders'
51
		| 'commerce-paymentMethods'
52
		| 'commerce-payments'
53
		| 'commerce-productCategories'
54
		| 'commerce-products'
55
		| 'commerce-taxComponents'
56
		| 'commerce-transactions'
57
) {
58
	const url = new URL(
59
		`https://api.codat.io/companies/${companyId}/connections/${connectionId}/options/${dataType}`
60
	)
61

62
	const response = await fetch(url, {
63
		method: 'GET',
64
		headers: {
65
			Authorization: `Basic ${auth.encodedKey}`
66
		},
67
		body: undefined
68
	})
69
	if (!response.ok) {
70
		const text = await response.text()
71
		throw new Error(`${response.status} ${text}`)
72
	}
73
	return await response.json()
74
}
75