0

Update profile

by
Published Oct 17, 2025

Update your Codat profile

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 profile
7
 * Update your Codat profile
8
 */
9
export async function main(
10
	auth: Codat,
11
	body: {
12
		name: string
13
		logoUrl?: string
14
		iconUrl?: string
15
		redirectUrl: string
16
		whiteListUrls?: string[]
17
		apiKey?: string
18
		confirmCompanyName?: false | true
19
	}
20
) {
21
	const url = new URL(`https://api.codat.io/profile`)
22

23
	const response = await fetch(url, {
24
		method: 'PUT',
25
		headers: {
26
			'Content-Type': 'application/json',
27
			Authorization: `Basic ${auth.encodedKey}`
28
		},
29
		body: JSON.stringify(body)
30
	})
31
	if (!response.ok) {
32
		const text = await response.text()
33
		throw new Error(`${response.status} ${text}`)
34
	}
35
	return await response.json()
36
}
37