0

Update a Member's licensed status

by
Published Oct 30, 2023

This endpoint is used to update whether the provided Member should use one of the Enterprise's available licenses or not. Revoking a license will deactivate a Member of an Enterprise. NOTE: Revoking of licenses is not possible for enterprises that have opted in to user management via AdminHub.

Script trello Verified

The script

Submitted by hugo697 Typescript (fetch-only)
Verified 399 days ago
1
type Trello = {
2
  key: string;
3
  token: string;
4
};
5
/**
6
 * Update a Member's licensed status
7
 * This endpoint is used to update whether the provided Member should use one of the Enterprise's available licenses or not. Revoking a license will deactivate a Member of an Enterprise. 
8

9
 NOTE: Revoking of licenses is not possible for enterprises that have opted in to user management via AdminHub.
10
 */
11
export async function main(
12
  auth: Trello,
13
  id: string,
14
  idMember: string,
15
  value: string | undefined
16
) {
17
  const url = new URL(
18
    `https://api.trello.com/1/enterprises/${id}/members/${idMember}/licensed`
19
  );
20
  for (const [k, v] of [
21
    ["value", value],
22
    ["key", auth.key],
23
    ["token", auth.token],
24
  ]) {
25
    if (v !== undefined && v !== "") {
26
      url.searchParams.append(k, v);
27
    }
28
  }
29
  const response = await fetch(url, {
30
    method: "PUT",
31
    headers: {
32
      Authorization: undefined,
33
    },
34
    body: undefined,
35
  });
36
  if (!response.ok) {
37
    const text = await response.text();
38
    throw new Error(`${response.status} ${text}`);
39
  }
40
  return await response.json();
41
}
42