0

Delete Invites

by
Published Oct 17, 2025

Removes a list of invitations to join a Workspace. • When called, this endpoint may generate one or more of the following audit trail events:* Invite Deleted * Group Memberships Deleted The rate limit for this endpoint is 60 requests per minute, which is lower than the default due to access pattern restrictions. Once reached, this endpoint will respond with the 429 HTTP status code with headers indicating the limit parameters. See Rate Limiting for more information.

Script segment Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Segment = {
3
  token: string;
4
  baseUrl: string;
5
};
6
/**
7
 * Delete Invites
8
 * Removes a list of invitations to join a Workspace.
9

10

11

12
• When called, this endpoint may generate one or more of the following audit trail events:* Invite Deleted
13
* Group Memberships Deleted
14
      
15

16

17
The rate limit for this endpoint is 60 requests per minute, which is lower than the default due to access pattern restrictions. Once reached, this endpoint will respond with the 429 HTTP status code with headers indicating the limit parameters. See Rate Limiting for more information.
18
 */
19
export async function main(auth: Segment, emails: string | undefined) {
20
  const url = new URL(`${auth.baseUrl}/invites`);
21
  for (const [k, v] of [["emails", emails]]) {
22
    if (v !== undefined && v !== "" && k !== undefined) {
23
      url.searchParams.append(k, v);
24
    }
25
  }
26
  const response = await fetch(url, {
27
    method: "DELETE",
28
    headers: {
29
      Authorization: "Bearer " + auth.token,
30
    },
31
    body: undefined,
32
  });
33
  if (!response.ok) {
34
    const text = await response.text();
35
    throw new Error(`${response.status} ${text}`);
36
  }
37
  return await response.json();
38
}
39