Edits history of script submission #12048 for ' Revokes an invitation (clerk)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Clerk = {
      apiKey: string;
    };
    /**
     * Revokes an invitation
     * 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.
     */
    export async function main(auth: Clerk, invitation_id: string) {
      const url = new URL(
        `https://api.clerk.com/v1/invitations/${invitation_id}/revoke`,
      );
    
      const response = await fetch(url, {
        method: "POST",
        headers: {
          Authorization: "Bearer " + auth.apiKey,
        },
        body: undefined,
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.json();
    }
    

    Submitted by hugo697 428 days ago