0

Add product

by
Published Oct 17, 2025

Use the *Add product* endpoint to enable a product for the company specified by `companyId`. > Note: This feature is currently in alpha and available only to participants in the development program.

Script codat Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Codat = {
3
	encodedKey: string
4
}
5
/**
6
 * Add product
7
 * Use the *Add product* endpoint to enable a product for the company specified by `companyId`.
8

9
> Note: This feature is currently in alpha and available only to participants in the development program.
10
 */
11
export async function main(auth: Codat, companyId: string, productIdentifier: string) {
12
	const url = new URL(`https://api.codat.io/companies/${companyId}/products/${productIdentifier}`)
13

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