0

Revokes an invitation

by
Published Apr 8, 2025

Revokes the given invitation. Revoking an invitation will prevent the user from using the invitation link that was sent to them. However, it doesn't prevent the user from signing up if they follow the sign up flow. Only active (i.e. non-revoked) invitations can be revoked.

Script clerk Verified

The script

Submitted by hugo697 Bun
Verified 428 days ago
1
//native
2
type Clerk = {
3
  apiKey: string;
4
};
5
/**
6
 * Revokes an invitation
7
 * Revokes the given invitation.
8
Revoking an invitation will prevent the user from using the invitation link that was sent to them.
9
However, it doesn't prevent the user from signing up if they follow the sign up flow.
10
Only active (i.e. non-revoked) invitations can be revoked.
11
 */
12
export async function main(auth: Clerk, invitation_id: string) {
13
  const url = new URL(
14
    `https://api.clerk.com/v1/invitations/${invitation_id}/revoke`,
15
  );
16

17
  const response = await fetch(url, {
18
    method: "POST",
19
    headers: {
20
      Authorization: "Bearer " + auth.apiKey,
21
    },
22
    body: undefined,
23
  });
24
  if (!response.ok) {
25
    const text = await response.text();
26
    throw new Error(`${response.status} ${text}`);
27
  }
28
  return await response.json();
29
}
30