0

Get create item model

by
Published Oct 17, 2025

The *Get create item model* endpoint returns the expected data for the request payload when creating an [item](https://docs.codat.io/accounting-api#/schemas/Item) for a given company and integration. [Items](https://docs.codat.io/accounting-api#/schemas/Item) allow your customers to save and track details of the products and services that they buy and sell. **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 item model
7
 * The *Get create item model* endpoint returns the expected data for the request payload when creating an [item](https://docs.codat.io/accounting-api#/schemas/Item) for a given company and integration.
8

9
[Items](https://docs.codat.io/accounting-api#/schemas/Item) allow your customers to save and track details of the products and services that they buy and sell.
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/items`
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