0

Transfer an Organization to an Enterprise.

by
Published Oct 30, 2023

Transfer an organization to an enterprise. NOTE: For enterprises that have opted in to user management via AdminHub, this endpoint will result in the organization 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
 * Transfer an Organization to an Enterprise.
7
 * Transfer an organization to an enterprise.
8

9
 NOTE: For enterprises that have opted in to user management via AdminHub, this endpoint will result in the organization 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(
12
  auth: Trello,
13
  id: string,
14
  idOrganization: string | undefined
15
) {
16
  const url = new URL(
17
    `https://api.trello.com/1/enterprises/${id}/organizations`
18
  );
19
  for (const [k, v] of [
20
    ["idOrganization", idOrganization],
21
    ["key", auth.key],
22
    ["token", auth.token],
23
  ]) {
24
    if (v !== undefined && v !== "") {
25
      url.searchParams.append(k, v);
26
    }
27
  }
28
  const response = await fetch(url, {
29
    method: "PUT",
30
    headers: {
31
      Authorization: undefined,
32
    },
33
    body: undefined,
34
  });
35
  if (!response.ok) {
36
    const text = await response.text();
37
    throw new Error(`${response.status} ${text}`);
38
  }
39
  return await response.json();
40
}
41