0

Create shield information barrier segment restriction

by
Published Oct 17, 2025

Creates a shield information barrier segment restriction object.

Script box Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Box = {
3
  token: string;
4
};
5
/**
6
 * Create shield information barrier segment restriction
7
 * Creates a shield information barrier
8
segment restriction object.
9
 */
10
export async function main(
11
  auth: Box,
12
  body: {
13
    type: "shield_information_barrier_segment_restriction";
14
    shield_information_barrier?: {
15
      id?: string;
16
      type?: "shield_information_barrier";
17
    };
18
    shield_information_barrier_segment: {
19
      id?: string;
20
      type?: "shield_information_barrier_segment";
21
    };
22
    restricted_segment: {
23
      id?: string;
24
      type?: "shield_information_barrier_segment";
25
    };
26
  },
27
) {
28
  const url = new URL(
29
    `https://api.box.com/2.0/shield_information_barrier_segment_restrictions`,
30
  );
31

32
  const response = await fetch(url, {
33
    method: "POST",
34
    headers: {
35
      "Content-Type": "application/json",
36
      Authorization: "Bearer " + auth.token,
37
    },
38
    body: JSON.stringify(body),
39
  });
40
  if (!response.ok) {
41
    const text = await response.text();
42
    throw new Error(`${response.status} ${text}`);
43
  }
44
  return await response.json();
45
}
46