0

Updates an existing invite

by
Published Apr 8, 2025

This operation provides a way to update an existing invite. Updates are performed in-place; they do not change the invite link, the expiry time, nor do they re-notify the recipient of the invite.

Script xata Verified

The script

Submitted by hugo697 Bun
Verified 428 days ago
1
//native
2
type Xata = {
3
	apiKey: string
4
}
5
/**
6
 * Updates an existing invite
7
 * This operation provides a way to update an existing invite. Updates are performed in-place; they do not change the invite link, the expiry time, nor do they re-notify the recipient of the invite.
8

9
 */
10
export async function main(
11
	auth: Xata,
12
	workspace_id: string,
13
	invite_id: string,
14
	body: { role: 'owner' | 'maintainer' }
15
) {
16
	const url = new URL(`https://api.xata.io/workspaces/${workspace_id}/invites/${invite_id}`)
17

18
	const response = await fetch(url, {
19
		method: 'PATCH',
20
		headers: {
21
			'Content-Type': 'application/json',
22
			Authorization: 'Bearer ' + auth.apiKey
23
		},
24
		body: JSON.stringify(body)
25
	})
26
	if (!response.ok) {
27
		const text = await response.text()
28
		throw new Error(`${response.status} ${text}`)
29
	}
30
	return await response.json()
31
}
32