0

Delete the email domain restriction on who can be invited to the Workspace

by
Published Oct 30, 2023

Remove the email domain restriction on who can be invited to the Workspace

Script trello Verified

The script

Submitted by hugo697 Typescript (fetch-only)
Verified 398 days ago
1
type Trello = {
2
  key: string;
3
  token: string;
4
};
5
/**
6
 * Delete the email domain restriction on who can be invited to the Workspace
7
 * Remove the email domain restriction on who can be invited to the Workspace
8
 */
9
export async function main(auth: Trello, id: string) {
10
  const url = new URL(
11
    `https://api.trello.com/1/organizations/${id}/prefs/orgInviteRestrict`
12
  );
13
  for (const [k, v] of [
14
    ["key", auth.key],
15
    ["token", auth.token],
16
  ]) {
17
    if (v !== undefined && v !== "") {
18
      url.searchParams.append(k, v);
19
    }
20
  }
21
  const response = await fetch(url, {
22
    method: "DELETE",
23
    headers: {
24
      Authorization: undefined,
25
    },
26
    body: undefined,
27
  });
28
  if (!response.ok) {
29
    const text = await response.text();
30
    throw new Error(`${response.status} ${text}`);
31
  }
32
  return await response.text();
33
}
34