0

List folder locks

by
Published Oct 17, 2025

Retrieves folder lock details for a given folder. You must be authenticated as the owner or co-owner of the folder to use this endpoint.

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 folder locks
7
 * Retrieves folder lock details for a given folder.
8

9
You must be authenticated as the owner or co-owner of the folder to
10
use this endpoint.
11
 */
12
export async function main(auth: Box, folder_id: string | undefined) {
13
  const url = new URL(`https://api.box.com/2.0/folder_locks`);
14
  for (const [k, v] of [["folder_id", folder_id]]) {
15
    if (v !== undefined && v !== "" && k !== undefined) {
16
      url.searchParams.append(k, v);
17
    }
18
  }
19
  const response = await fetch(url, {
20
    method: "GET",
21
    headers: {
22
      Authorization: "Bearer " + auth.token,
23
    },
24
    body: undefined,
25
  });
26
  if (!response.ok) {
27
    const text = await response.text();
28
    throw new Error(`${response.status} ${text}`);
29
  }
30
  return await response.json();
31
}
32