0

List customer attachments

by
Published Oct 17, 2025

The *List customer attachments* endpoint returns a list of attachments avialable to download for given `customerId`. [Customers](https://docs.codat.io/lending-api#/schemas/Customer) are people or organizations that buy goods or services from the SMB.

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 customer attachments
7
 * The *List customer attachments* endpoint returns a list of attachments avialable to download for given `customerId`.
8

9
[Customers](https://docs.codat.io/lending-api#/schemas/Customer) are people or organizations that buy goods or services from the SMB.
10
 */
11
export async function main(
12
	auth: Codat,
13
	companyId: string,
14
	connectionId: string,
15
	customerId: string
16
) {
17
	const url = new URL(
18
		`https://api.codat.io/companies/${companyId}/connections/${connectionId}/data/customers/${customerId}/attachments`
19
	)
20

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