0

Create shield information barrier segment member

by
Published Oct 17, 2025

Creates a new shield information barrier segment member.

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 member
7
 * Creates a new shield information barrier segment member.
8
 */
9
export async function main(
10
  auth: Box,
11
  body: {
12
    type?: "shield_information_barrier_segment_member";
13
    shield_information_barrier?: {
14
      id?: string;
15
      type?: "shield_information_barrier";
16
    };
17
    shield_information_barrier_segment: {
18
      id?: string;
19
      type?: "shield_information_barrier_segment";
20
    };
21
    user: { id: string; type: "user" };
22
  },
23
) {
24
  const url = new URL(
25
    `https://api.box.com/2.0/shield_information_barrier_segment_members`,
26
  );
27

28
  const response = await fetch(url, {
29
    method: "POST",
30
    headers: {
31
      "Content-Type": "application/json",
32
      Authorization: "Bearer " + auth.token,
33
    },
34
    body: JSON.stringify(body),
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