0

List metadata cascade policies

by
Published Oct 17, 2025

Retrieves a list of all the metadata cascade policies that are applied to a given folder. This can not be used on the root folder with ID `0`.

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 metadata cascade policies
7
 * Retrieves a list of all the metadata cascade policies
8
that are applied to a given folder. This can not be used on the root
9
folder with ID `0`.
10
 */
11
export async function main(
12
  auth: Box,
13
  folder_id: string | undefined,
14
  owner_enterprise_id: string | undefined,
15
  marker: string | undefined,
16
  offset: string | undefined,
17
) {
18
  const url = new URL(`https://api.box.com/2.0/metadata_cascade_policies`);
19
  for (const [k, v] of [
20
    ["folder_id", folder_id],
21
    ["owner_enterprise_id", owner_enterprise_id],
22
    ["marker", marker],
23
    ["offset", offset],
24
  ]) {
25
    if (v !== undefined && v !== "" && k !== undefined) {
26
      url.searchParams.append(k, v);
27
    }
28
  }
29
  const response = await fetch(url, {
30
    method: "GET",
31
    headers: {
32
      Authorization: "Bearer " + auth.token,
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