0

Download categorized bank statement Excel

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. Use the *Download categorized bank statement Excel* endpoint to download the categorized bank statement Excel file. 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
 * Download categorized bank statement Excel
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
Use the *Download categorized bank statement Excel* endpoint to download the categorized bank statement Excel file. 
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
) {
21
	const url = new URL(
22
		`https://api.codat.io/companies/${companyId}/reports/categorizedBankStatement/${reportId}/excel`
23
	)
24
	for (const [k, v] of [['maxAge', maxAge]]) {
25
		if (v !== undefined && v !== '' && k !== undefined) {
26
			url.searchParams.append(k, v)
27
		}
28
	}
29

30
	const response = await fetch(url, {
31
		method: 'GET',
32
		headers: {
33
			Authorization: `Basic ${auth.encodedKey}`
34
		},
35
		body: undefined
36
	})
37
	if (!response.ok) {
38
		const text = await response.text()
39
		throw new Error(`${response.status} ${text}`)
40
	}
41
	return await response.text()
42
}
43