//native
type Grist = {
apiKey: string;
host: string;
};
/**
* Delete a user from Grist
* This action also deletes the user's personal organisation and all the workspaces and documents it contains.
Currently, only the users themselves are allowed to delete their own accounts.
⚠️ **This action cannot be undone, please be cautious when using this endpoint** ⚠️
*/
export async function main(
auth: Grist,
userId: string,
body: { name: string },
) {
const url = new URL(`https://${auth.host}/api/users/${userId}`);
const response = await fetch(url, {
method: "DELETE",
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.text();
}
Submitted by hugo697 428 days ago