0

List enterprise device pins

by
Published Oct 17, 2025

Retrieves all the device pins within an enterprise. The user must have admin privileges, and the application needs the "manage enterprise" scope to make this call.

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 enterprise device pins
7
 * Retrieves all the device pins within an enterprise.
8

9
The user must have admin privileges, and the application
10
needs the "manage enterprise" scope to make this call.
11
 */
12
export async function main(
13
  auth: Box,
14
  enterprise_id: string,
15
  marker: string | undefined,
16
  limit: string | undefined,
17
  direction: "ASC" | "DESC" | undefined,
18
) {
19
  const url = new URL(
20
    `https://api.box.com/2.0/enterprises/${enterprise_id}/device_pinners`,
21
  );
22
  for (const [k, v] of [
23
    ["marker", marker],
24
    ["limit", limit],
25
    ["direction", direction],
26
  ]) {
27
    if (v !== undefined && v !== "" && k !== undefined) {
28
      url.searchParams.append(k, v);
29
    }
30
  }
31
  const response = await fetch(url, {
32
    method: "GET",
33
    headers: {
34
      Authorization: "Bearer " + auth.token,
35
    },
36
    body: undefined,
37
  });
38
  if (!response.ok) {
39
    const text = await response.text();
40
    throw new Error(`${response.status} ${text}`);
41
  }
42
  return await response.json();
43
}
44