0

List categorized bank statement accounts

by
Published Oct 17, 2025

> **Available as beta release** > > This endpoint is part of a beta release. Please contact your account manager if you want to enable it. The *Get categorized bank statement accounts* endpoint returns a list of bank accounts associated with categorized transactions for a company. Before using it, you must call the [Generate report](https://docs.codat.io/lending-api#/operations/generate-report) endpoint of type `categorizedBankStatement`.

Script codat Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Codat = {
3
	encodedKey: string
4
}
5
/**
6
 * List categorized bank statement accounts
7
 * > **Available as beta release**
8
>
9
> This endpoint is part of a beta release. Please contact your account manager if you want to enable it.
10

11
The *Get categorized bank statement accounts* endpoint returns a list of bank accounts associated with categorized transactions for a company. 
12

13
Before using it, you must call the [Generate report](https://docs.codat.io/lending-api#/operations/generate-report) endpoint of type `categorizedBankStatement`.
14
 */
15
export async function main(
16
	auth: Codat,
17
	companyId: string,
18
	reportId: string,
19
	maxAge: string | undefined,
20
	page: string | undefined,
21
	pageSize: string | undefined,
22
	query: string | undefined,
23
	orderBy: string | undefined
24
) {
25
	const url = new URL(
26
		`https://api.codat.io/companies/${companyId}/reports/categorizedBankStatement/${reportId}/accounts`
27
	)
28
	for (const [k, v] of [
29
		['maxAge', maxAge],
30
		['page', page],
31
		['pageSize', pageSize],
32
		['query', query],
33
		['orderBy', orderBy]
34
	]) {
35
		if (v !== undefined && v !== '' && k !== undefined) {
36
			url.searchParams.append(k, v)
37
		}
38
	}
39

40
	const response = await fetch(url, {
41
		method: 'GET',
42
		headers: {
43
			Authorization: `Basic ${auth.encodedKey}`
44
		},
45
		body: undefined
46
	})
47
	if (!response.ok) {
48
		const text = await response.text()
49
		throw new Error(`${response.status} ${text}`)
50
	}
51
	return await response.json()
52
}
53