0

List group collaborations

by
Published Oct 17, 2025

Retrieves all the collaborations for a group. The user must have admin permissions to inspect enterprise's groups. Each collaboration object has details on which files or folders the group has access to and with what role.

Script box Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Box = {
3
  token: string;
4
};
5
/**
6
 * List group collaborations
7
 * Retrieves all the collaborations for a group. The user
8
must have admin permissions to inspect enterprise's groups.
9

10
Each collaboration object has details on which files or
11
folders the group has access to and with what role.
12
 */
13
export async function main(
14
  auth: Box,
15
  group_id: string,
16
  limit: string | undefined,
17
  offset: string | undefined,
18
) {
19
  const url = new URL(
20
    `https://api.box.com/2.0/groups/${group_id}/collaborations`,
21
  );
22
  for (const [k, v] of [
23
    ["limit", limit],
24
    ["offset", offset],
25
  ]) {
26
    if (v !== undefined && v !== "" && k !== undefined) {
27
      url.searchParams.append(k, v);
28
    }
29
  }
30
  const response = await fetch(url, {
31
    method: "GET",
32
    headers: {
33
      Authorization: "Bearer " + auth.token,
34
    },
35
    body: undefined,
36
  });
37
  if (!response.ok) {
38
    const text = await response.text();
39
    throw new Error(`${response.status} ${text}`);
40
  }
41
  return await response.json();
42
}
43