0

Get create/update customer model

by
Published Oct 17, 2025

The *Get create/update customer model* endpoint returns the expected data for the request payload when creating and updating a [customer](https://docs.codat.io/accounting-api#/schemas/Customer) for a given company and integration. [Customers](https://docs.codat.io/accounting-api#/schemas/Customer) are people or organizations that buy goods or services from the SMB. **Integration-specific behaviour** See the *response examples* for integration-specific indicative models.

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 create/update customer model
7
 * The *Get create/update customer model* endpoint returns the expected data for the request payload when creating and updating a [customer](https://docs.codat.io/accounting-api#/schemas/Customer) for a given company and integration.
8

9
[Customers](https://docs.codat.io/accounting-api#/schemas/Customer) are people or organizations that buy goods or services from the SMB.
10

11
**Integration-specific behaviour**
12

13
See the *response examples* for integration-specific indicative models.
14

15
 */
16
export async function main(auth: Codat, companyId: string, connectionId: string) {
17
	const url = new URL(
18
		`https://api.codat.io/companies/${companyId}/connections/${connectionId}/options/customers`
19
	)
20

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