0

List file app item associations

by
Published Oct 17, 2025

**This is a beta feature, which means that its availability might be limited.** Returns all app items the file is associated with. This includes app items associated with ancestors of the file. Assuming the context user has access to the file, the type/ids are revealed even if the context user does not have **View** permission on the app item.

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 file app item associations
7
 * **This is a beta feature, which means that its availability might be limited.**
8
Returns all app items the file is associated with. This includes app items
9
associated with ancestors of the file. Assuming the context user has access
10
to the file, the type/ids are revealed even if the context user does not
11
have **View** permission on the app item.
12
 */
13
export async function main(
14
  auth: Box,
15
  file_id: string,
16
  limit: string | undefined,
17
  marker: string | undefined,
18
  application_type: string | undefined,
19
) {
20
  const url = new URL(
21
    `https://api.box.com/2.0/files/${file_id}/app_item_associations`,
22
  );
23
  for (const [k, v] of [
24
    ["limit", limit],
25
    ["marker", marker],
26
    ["application_type", application_type],
27
  ]) {
28
    if (v !== undefined && v !== "" && k !== undefined) {
29
      url.searchParams.append(k, v);
30
    }
31
  }
32
  const response = await fetch(url, {
33
    method: "GET",
34
    headers: {
35
      Authorization: "Bearer " + auth.token,
36
    },
37
    body: undefined,
38
  });
39
  if (!response.ok) {
40
    const text = await response.text();
41
    throw new Error(`${response.status} ${text}`);
42
  }
43
  return await response.json();
44
}
45