0

List supplier attachments

by
Published Oct 17, 2025

The *List supplier attachments* endpoint returns a list of attachments available to download for given `supplierId`. [Suppliers](https://docs.codat.io/lending-api#/schemas/Supplier) are people or organizations that provide something, such as a product or service.

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

9
[Suppliers](https://docs.codat.io/lending-api#/schemas/Supplier) are people or organizations that provide something, such as a product or service.
10

11
 */
12
export async function main(
13
	auth: Codat,
14
	companyId: string,
15
	connectionId: string,
16
	supplierId: string
17
) {
18
	const url = new URL(
19
		`https://api.codat.io/companies/${companyId}/connections/${connectionId}/data/suppliers/${supplierId}/attachments`
20
	)
21

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