0

List terms of service user statuses

by
Published Oct 17, 2025

Retrieves an overview of users and their status for a terms of service, including Whether they have accepted the terms and when.

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 terms of service user statuses
7
 * Retrieves an overview of users and their status for a
8
terms of service, including Whether they have accepted
9
the terms and when.
10
 */
11
export async function main(
12
  auth: Box,
13
  tos_id: string | undefined,
14
  user_id: string | undefined,
15
) {
16
  const url = new URL(`https://api.box.com/2.0/terms_of_service_user_statuses`);
17
  for (const [k, v] of [
18
    ["tos_id", tos_id],
19
    ["user_id", user_id],
20
  ]) {
21
    if (v !== undefined && v !== "" && k !== undefined) {
22
      url.searchParams.append(k, v);
23
    }
24
  }
25
  const response = await fetch(url, {
26
    method: "GET",
27
    headers: {
28
      Authorization: "Bearer " + auth.token,
29
    },
30
    body: undefined,
31
  });
32
  if (!response.ok) {
33
    const text = await response.text();
34
    throw new Error(`${response.status} ${text}`);
35
  }
36
  return await response.json();
37
}
38