0

Delete bill attachment

by
Published Oct 17, 2025

The *Delete bill attachment* endpoint allows you to delete a specified bill attachment from an accounting software.

Script codat Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Codat = {
3
	encodedKey: string
4
}
5
/**
6
 * Delete bill attachment
7
 * The *Delete bill attachment* endpoint allows you to delete a specified bill attachment from an accounting software.
8
 */
9
export async function main(
10
	auth: Codat,
11
	companyId: string,
12
	connectionId: string,
13
	billId: string,
14
	attachmentId: string
15
) {
16
	const url = new URL(
17
		`https://api.codat.io/companies/${companyId}/connections/${connectionId}/push/bills/${billId}/attachments/${attachmentId}`
18
	)
19

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