0

Update file request

by
Published Oct 17, 2025

Updates a file request. This can be used to activate or deactivate a file request.

Script box Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Box = {
3
  token: string;
4
};
5
/**
6
 * Update file request
7
 * Updates a file request. This can be used to activate or
8
deactivate a file request.
9
 */
10
export async function main(
11
  auth: Box,
12
  file_request_id: string,
13
  if_match: string,
14
  body: {
15
    title?: string;
16
    description?: string;
17
    status?: "active" | "inactive";
18
    is_email_required?: false | true;
19
    is_description_required?: false | true;
20
    expires_at?: string;
21
  },
22
) {
23
  const url = new URL(
24
    `https://api.box.com/2.0/file_requests/${file_request_id}`,
25
  );
26

27
  const response = await fetch(url, {
28
    method: "PUT",
29
    headers: {
30
      "if-match": if_match,
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