0

Bulk accept a set of organizations to an Enterprise.

by
Published Oct 30, 2023

Accept an array of organizations to an enterprise. NOTE: For enterprises that have opted in to user management via AdminHub, this endpoint will result in organizations being added to the enterprise asynchronously. A 200 response only indicates receipt of the request, it does not indicate successful addition to the enterprise.

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
 * Bulk accept a set of organizations to an Enterprise.
7
 * Accept an array of organizations to an enterprise.
8

9
 NOTE: For enterprises that have opted in to user management via AdminHub, this endpoint will result in organizations being added to the enterprise asynchronously. A 200 response only indicates receipt of the request, it does not indicate successful addition to the enterprise.
10
 */
11
export async function main(auth: Trello, id: string, idOrganizations: string) {
12
  const url = new URL(
13
    `https://api.trello.com/1/enterprises/${id}/organizations/bulk/${idOrganizations}`
14
  );
15
  for (const [k, v] of [
16
    ["key", auth.key],
17
    ["token", auth.token],
18
  ]) {
19
    if (v !== undefined && v !== "") {
20
      url.searchParams.append(k, v);
21
    }
22
  }
23
  const response = await fetch(url, {
24
    method: "GET",
25
    headers: {
26
      Authorization: undefined,
27
    },
28
    body: undefined,
29
  });
30
  if (!response.ok) {
31
    const text = await response.text();
32
    throw new Error(`${response.status} ${text}`);
33
  }
34
  return await response.json();
35
}
36