0

Get create direct income model

by
Published Oct 17, 2025

The *Get create direct income model* endpoint returns the expected data for the request payload when creating a [direct income](https://docs.codat.io/accounting-api#/schemas/DirectIncome) for a given company and integration. [Direct incomes](https://docs.codat.io/accounting-api#/schemas/DirectIncome) are incomes received directly from the business' operations at the point of the sale. **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 direct income model
7
 * The *Get create direct income model* endpoint returns the expected data for the request payload when creating a [direct income](https://docs.codat.io/accounting-api#/schemas/DirectIncome) for a given company and integration.
8

9
[Direct incomes](https://docs.codat.io/accounting-api#/schemas/DirectIncome) are incomes received directly from the business' operations at the point of the sale.
10

11
**Integration-specific behaviour**
12

13
See the *response examples* for integration-specific indicative models.
14
 */
15
export async function main(auth: Codat, companyId: string, connectionId: string) {
16
	const url = new URL(
17
		`https://api.codat.io/companies/${companyId}/connections/${connectionId}/options/directIncomes`
18
	)
19

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