0

Create bank feed account mapping

by
Published Oct 17, 2025

The *Create bank account mapping* endpoint creates a new mapping between a source bank account and a potential account in the accounting software (target account).

Script codat Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Codat = {
3
	encodedKey: string
4
}
5
/**
6
 * Create bank feed account mapping
7
 * The *Create bank account mapping* endpoint creates a new mapping between a source bank account and a potential account in the accounting software (target account).
8
 */
9
export async function main(
10
	auth: Codat,
11
	companyId: string,
12
	connectionId: string,
13
	body: {
14
		sourceAccountId: string
15
		targetAccountId?: string
16
		feedStartDate?: string
17
	}
18
) {
19
	const url = new URL(
20
		`https://api.codat.io/companies/${companyId}/connections/${connectionId}/bankFeedAccounts/mapping`
21
	)
22

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