//native
type Xata = {
apiKey: string
}
/**
* Invite a user to join the workspace
* Invite some user to join the workspace with the given role
*/
export async function main(
auth: Xata,
workspace_id: string,
body: { email: string; role: 'owner' | 'maintainer' }
) {
const url = new URL(`https://api.xata.io/workspaces/${workspace_id}/invites`)
const response = await fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: 'Bearer ' + auth.apiKey
},
body: JSON.stringify(body)
})
if (!response.ok) {
const text = await response.text()
throw new Error(`${response.status} ${text}`)
}
return await response.json()
}
Submitted by hugo697 428 days ago