0

Get Excel report status

by
Published Oct 17, 2025

The *Get Excel report status* returns the status of the report mostly recently requested for Excel generation. It does not return the status of any historical report requests. Poll this endpoint to check the progress of the report once you have requested its generation. This will not affect the generation of the report. When the report generation completes successfully, the `inProgress` property will be marked as `false` and the `success` field will be marked as `true`.

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 Excel report status
7
 * The *Get Excel report status* returns the status of the report mostly recently requested for Excel generation. It does not return the status of any historical report requests. 
8

9
Poll this endpoint to check the progress of the report once you have requested its generation. This will not affect the generation of the report. 
10

11
When the report generation completes successfully, the `inProgress` property will be marked as `false` and the `success` field will be marked as `true`.
12
 */
13
export async function main(
14
	auth: Codat,
15
	companyId: string,
16
	reportType: 'audit' | 'enhancedFinancials' | 'enhancedInvoices' | 'enhancedCashFlow' | undefined
17
) {
18
	const url = new URL(`https://api.codat.io/data/companies/${companyId}/assess/excel`)
19
	for (const [k, v] of [['reportType', reportType]]) {
20
		if (v !== undefined && v !== '' && k !== undefined) {
21
			url.searchParams.append(k, v)
22
		}
23
	}
24

25
	const response = await fetch(url, {
26
		method: 'GET',
27
		headers: {
28
			Authorization: `Basic ${auth.encodedKey}`
29
		},
30
		body: undefined
31
	})
32
	if (!response.ok) {
33
		const text = await response.text()
34
		throw new Error(`${response.status} ${text}`)
35
	}
36
	return await response.json()
37
}
38