0

Update company

by
Published Oct 17, 2025

Use the *Update company* endpoint to update the name, description, or tags of the company. The *Update company* endpoint doesn't have any required fields. If any of the fields provided are `null` or not provided, they won't be included in the update. A [company](https://docs.codat.io/sync-for-payables-api#/schemas/Company) represents a business sharing access to their 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
 * Update company
7
 * Use the *Update company* endpoint to update the name, description, or tags of the company.
8

9
The *Update company* endpoint doesn't have any required fields. If any of the fields provided are `null` or not provided, they won't be included in the update.  
10

11
A [company](https://docs.codat.io/sync-for-payables-api#/schemas/Company) represents a business sharing access to their data.
12
 */
13
export async function main(
14
	auth: Codat,
15
	companyId: string,
16
	body: { name?: string; description?: string; tags?: {} }
17
) {
18
	const url = new URL(`https://api.codat.io/companies/${companyId}`)
19

20
	const response = await fetch(url, {
21
		method: 'PATCH',
22
		headers: {
23
			'Content-Type': 'application/json',
24
			Authorization: `Basic ${auth.encodedKey}`
25
		},
26
		body: JSON.stringify(body)
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