0

Get data integrity summary

by
Published Oct 17, 2025

Gets match summary for a given company and datatype, optionally restricted by a Codat query string.

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 data integrity summary
7
 * Gets match summary for a given company and datatype, optionally restricted by a Codat query string.
8
 */
9
export async function main(
10
	auth: Codat,
11
	companyId: string,
12
	dataType: 'banking-accounts' | 'banking-transactions' | 'bankAccounts' | 'accountTransactions',
13
	query: string | undefined
14
) {
15
	const url = new URL(
16
		`https://api.codat.io/data/companies/${companyId}/assess/dataTypes/${dataType}/dataIntegrity/summaries`
17
	)
18
	for (const [k, v] of [['query', query]]) {
19
		if (v !== undefined && v !== '' && k !== undefined) {
20
			url.searchParams.append(k, v)
21
		}
22
	}
23

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