0

Get retention on file

by
Published Oct 17, 2025

Returns information about a file version retention. **Note**: File retention API is now **deprecated**. To get information about files and file versions under retention, see [files under retention](e://get-retention-policy-assignments-id-files-under-retention) or [file versions under retention](e://get-retention-policy-assignments-id-file-versions-under-retention) endpoints.

Script box Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Box = {
3
  token: string;
4
};
5
/**
6
 * Get retention on file
7
 * Returns information about a file version retention.
8

9
**Note**:
10
File retention API is now **deprecated**. 
11
To get information about files and file versions under retention,
12
see [files under retention](e://get-retention-policy-assignments-id-files-under-retention) or [file versions under retention](e://get-retention-policy-assignments-id-file-versions-under-retention) endpoints.
13
 */
14
export async function main(auth: Box, file_version_retention_id: string) {
15
  const url = new URL(
16
    `https://api.box.com/2.0/file_version_retentions/${file_version_retention_id}`,
17
  );
18

19
  const response = await fetch(url, {
20
    method: "GET",
21
    headers: {
22
      Authorization: "Bearer " + auth.token,
23
    },
24
    body: undefined,
25
  });
26
  if (!response.ok) {
27
    const text = await response.text();
28
    throw new Error(`${response.status} ${text}`);
29
  }
30
  return await response.json();
31
}
32