0

List bank account transactions

by
Published Oct 17, 2025

The *List account bank transactions* endpoint returns a list of [bank account transactions](https://docs.codat.io/lending-api#/schemas/BankTransactions) for a given company's connection. [Bank account transactions](https://docs.codat.io/lending-api#/schemas/BankTransactions) are records of money that has moved in and out of an SMB's bank account. Before using this endpoint, you must have [retrieved data for the company](https://docs.codat.io/lending-api#/operations/refresh-company-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
 * List bank account transactions
7
 * The *List account bank transactions* endpoint returns a list of [bank account transactions](https://docs.codat.io/lending-api#/schemas/BankTransactions) for a given company's connection.
8

9
[Bank account transactions](https://docs.codat.io/lending-api#/schemas/BankTransactions) are records of money that has moved in and out of an SMB's bank account.
10

11
Before using this endpoint, you must have [retrieved data for the company](https://docs.codat.io/lending-api#/operations/refresh-company-data).
12

13
 */
14
export async function main(
15
	auth: Codat,
16
	companyId: string,
17
	connectionId: string,
18
	accountId: string,
19
	page: string | undefined,
20
	pageSize: string | undefined,
21
	query: string | undefined,
22
	orderBy: string | undefined
23
) {
24
	const url = new URL(
25
		`https://api.codat.io/companies/${companyId}/connections/${connectionId}/data/bankAccounts/${accountId}/bankTransactions`
26
	)
27
	for (const [k, v] of [
28
		['page', page],
29
		['pageSize', pageSize],
30
		['query', query],
31
		['orderBy', orderBy]
32
	]) {
33
		if (v !== undefined && v !== '' && k !== undefined) {
34
			url.searchParams.append(k, v)
35
		}
36
	}
37

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