0

Get supplier attachment

by
Published Oct 17, 2025

The *Get supplier attachment* endpoint returns a specific attachment for a given `supplierId` and `attachmentId`. [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
 * Get supplier attachment
7
 * The *Get supplier attachment* endpoint returns a specific attachment for a given `supplierId` and `attachmentId`.
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
	attachmentId: string
18
) {
19
	const url = new URL(
20
		`https://api.codat.io/companies/${companyId}/connections/${connectionId}/data/suppliers/${supplierId}/attachments/${attachmentId}`
21
	)
22

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