0

List custom data type records

by
Published Oct 17, 2025

The *List custom data type records* endpoint returns a paginated list of records pulled for the specified custom data type you previously configured. A [custom data type](https://docs.codat.io/using-the-api/custom-data) is an additional data type you can create that is not included in Codat's standardized data model.s endpoint returns a paginated list of records whose schema is defined [Configure custom data type](https://docs.codat.io/platform-api#/operations/configure-custom-data-type)

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 custom data type records
7
 * The *List custom data type records* endpoint returns a paginated list of records pulled for the specified custom data type you previously configured.
8

9
A [custom data type](https://docs.codat.io/using-the-api/custom-data) is an additional data type you can create that is not included in Codat's standardized data model.s endpoint returns a paginated list of records whose schema is defined [Configure custom data type](https://docs.codat.io/platform-api#/operations/configure-custom-data-type)
10
 */
11
export async function main(
12
	auth: Codat,
13
	companyId: string,
14
	connectionId: string,
15
	customDataIdentifier: string,
16
	page: string | undefined,
17
	pageSize: string | undefined
18
) {
19
	const url = new URL(
20
		`https://api.codat.io/companies/${companyId}/connections/${connectionId}/data/custom/${customDataIdentifier}`
21
	)
22
	for (const [k, v] of [
23
		['page', page],
24
		['pageSize', pageSize]
25
	]) {
26
		if (v !== undefined && v !== '' && k !== undefined) {
27
			url.searchParams.append(k, v)
28
		}
29
	}
30

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