0

Get item

by
Published Oct 17, 2025

The *Get item* endpoint returns a single item for a given itemId. [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. Before using this endpoint, you must have [retrieved data for the company](https://docs.codat.io/codat-api#/operations/refresh-company-data).

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 item
7
 * The *Get item* endpoint returns a single item for a given itemId.
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
Before using this endpoint, you must have [retrieved data for the company](https://docs.codat.io/codat-api#/operations/refresh-company-data).
12

13
 */
14
export async function main(auth: Codat, companyId: string, itemId: string) {
15
	const url = new URL(`https://api.codat.io/companies/${companyId}/data/items/${itemId}`)
16

17
	const response = await fetch(url, {
18
		method: 'GET',
19
		headers: {
20
			Authorization: `Basic ${auth.encodedKey}`
21
		},
22
		body: undefined
23
	})
24
	if (!response.ok) {
25
		const text = await response.text()
26
		throw new Error(`${response.status} ${text}`)
27
	}
28
	return await response.json()
29
}
30