A retention policy blocks permanent deletion of content for a specified amount of time. Admins can create retention policies and then later assign them to specific folders or their entire enterprise. To use this feature, you must have the manage retention policies scope enabled for your API key via your application management console.
- Create Retention Policy
- Get Retention Policy
- Update Retention Policy
- Get Enterprise Retention Policies
- Get Retention Policy Assignments
- Assign Retention Policy
- Get Retention Policy Assignment
- Get File Version Retention
- Get File Version Retentions (will be deprecated in the future, use Get Files Under Retention For Assignment and Get File Version Under Retention For Assignment instead)
- Get Files Under Retention For Assignment
- Get File Version Under Retention For Assignment
To create a new retention policy, call
RetentionPoliciesManager.CreateRetentionPolicyAsync(BoxRetentionPolicyRequest retentionPolicyRequest)
with the parameters for the new retention policy.
var policyParams = new BoxRetentionPolicyRequest()
{
PolicyName = "Important Documents!",
PolicyType = "finite",
RetentionLength = 365,
DispositionAction = "remove_retention"
};
BoxRetentionPolicy policy = await client.RetentionPoliciesManager
.CreateRetentionPolicyAsync(policyParams);
To retrieve information about a specific retention policy, call
RetentionPoliciesManager.GetRetentionPolicyAsync(string id, IEnumerable<string> fields = null)
with the ID of the policy.
BoxRetentionPolicy policy = await client.RetentionPoliciesManager.GetRetentionPolicyAsync("11111");
To update or modify an existing retention policy, call
RetentionPoliciesManager.UpdateRetentionPolicyAsync(string id, BoxRetentionPolicyRequest retentionPolicyRequest, IEnumerable<string> fields = null)
with the ID of the policy to update and the set of fields to update.
var updates = new BoxRetentionPolicyRequest()
{
PolicyName = "New Policy Name"
};
BoxRetentionPolicy updatedPolicy = await client.RetentionPoliciesManager
.UpdateRetentionPolicyAsync("11111", updates);
To retrieve all of the retention policies for the given enterprise, call
RetentionPoliciesManager.GetRetentionPoliciesAsync(string policyName = null, string policyType = null, string createdByUserId = null, IEnumerable<string> fields = null, int limit = 100, string marker = null, bool autoPaginate = false)
.
BoxCollectionMarkerBased<BoxRetentionPolicy> policies = await client.RetentionPoliciesManager
.GetRetentionPoliciesAsync();
To get a list of all retention policy assignments associated with a specified retention policy, call
RetentionPoliciesManager.GetRetentionPolicyAssignmentsAsync(string retentionPolicyId, string type = null, IEnumerable<string> fields = null, int limit = 100, string marker = null, bool autoPaginate = false)
with the ID of the policy to get asisgnments for.
BoxCollectionMarkerBased<BoxRetentionPolicyAssignment> assignments = await client.RetentionPoliciesManager
.GetRetentionPolicyAssignmentsAsync(retentionPolicyId: "11111");
To assign a retention policy, call
RetentionPoliciesManager.CreateRetentionPolicyAssignmentAsync(BoxRetentionPolicyAssignmentRequest policyAssignmentRequest, IEnumerable<string> fields = null)
with the parameters of the assignment.
var assignmentParams = new BoxRetentionPolicyAssignmentRequest()
{
PolicyId = "11111",
AssignTo = new BoxRequestEntity()
{
Type = BoxType.folder,
Id = "22222"
}
};
BoxRetentionPolicyAssignment assignment = await client.RetentionPoliciesManager
.CreateRetentionPolicyAssignmentAsync(assignmentParams);
To retrieve information about a retention policy assignment, call
RetentionPoliciesManager.GetRetentionPolicyAssignmentAsync(string retentionPolicyAssignmentId, IEnumerable<string> fields = null)
with the ID of the assignment.
BoxRetentionPolicyAssignment assignment = await client.RetentionPoliciesManager
.GetRetentionPolicyAssignmentAsync("33333");
A file version retention is a record for a retained file version. To get information
for a specific file version retention record, call the
RetentionPoliciesManager.GetFileVersionRetentionAsync(string fileVersionRetentionId, IEnumerable<string> fields = null)
method with the ID of the retention object.
BoxFileVersionRetention retention = await client.RetentionPoliciesManager
.GetFileVersionRetentionAsync("55555");
To retrieve a list of all file version retentions for the given enterprise or to filter for
some category of file version retention records, call
RetentionPoliciesManager.GetFileVersionRetentionsAsync(IEnumerable<string> fields = null, int limit = 100, string marker = null, bool autoPaginate = false, string fileId = null, string fileVersionId = null, string policyId = null, DateTime? dispositionBefore = null, DateTime? dispositionAfter = null, DispositionAction? dispositionAction = null)
.
BoxCollectionMarkerBased<BoxFileVersionRetention> retentions = await client.RetentionPoliciesManager
.GetFileVersionRetentionsAsync();
To retrieve a list of all files under retention for assignment, call
RetentionPoliciesManager.GetFilesUnderRetentionForAssignmentAsync(string retentionPolicyAssignmentId, IEnumerable<string> fields = null, int limit = 100, string marker = null, bool autoPaginate = false)
.
BoxCollectionMarkerBased<BoxFile> filesUnderRetentionForAssignment = await client.RetentionPoliciesManager
.GetFilesUnderRetentionForAssignmentAsync("55555");
To retrieve a list of all file versions under retention for assignment, call
RetentionPoliciesManager.GetFileVersionsUnderRetentionForAssignmentAsync(string retentionPolicyAssignmentId, IEnumerable<string> fields = null, int limit = 100, string marker = null, bool autoPaginate = false)
.
BoxCollectionMarkerBased<BoxFileVersion> fileVersionsUnderRetentionForAssignment = await client.RetentionPoliciesManager
.GetFileVersionsUnderRetentionForAssignmentAsync("55555");