0

Create retention policy

by
Published Oct 17, 2025

Creates a retention policy.

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 retention policy
7
 * Creates a retention policy.
8
 */
9
export async function main(
10
  auth: Box,
11
  body: {
12
    policy_name: string;
13
    description?: string;
14
    policy_type: "finite" | "indefinite";
15
    disposition_action: "permanently_delete" | "remove_retention";
16
    retention_length?: string | number;
17
    retention_type?: "modifiable" | "non_modifiable";
18
    can_owner_extend_retention?: false | true;
19
    are_owners_notified?: false | true;
20
    custom_notification_recipients?: { id: string; type: "user" } & {
21
      name?: string;
22
      login?: string;
23
    }[];
24
  },
25
) {
26
  const url = new URL(`https://api.box.com/2.0/retention_policies`);
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

Other submissions
  • Submitted by lakiali.2000003555 Bun
    Created 52 days ago
    1
    // import * as wmill from 'windmill-client'
    2
    
    
    3
    export async function main(x: string) {
    4
      return x
    5
    }