0

Delete journal entry

by
Published Oct 17, 2025

> **Use with caution** > >Because journal entries underpin every transaction in an accounting software, deleting a journal entry can affect every transaction for a given company.

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 journal entry
7
 * > **Use with caution**
8
>
9
>Because journal entries underpin every transaction in an accounting software, deleting a journal entry can affect every transaction for a given company.
10
 */
11
export async function main(
12
	auth: Codat,
13
	companyId: string,
14
	connectionId: string,
15
	journalEntryId: string
16
) {
17
	const url = new URL(
18
		`https://api.codat.io/companies/${companyId}/connections/${connectionId}/push/journalEntries/${journalEntryId}`
19
	)
20

21
	const response = await fetch(url, {
22
		method: 'DELETE',
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