Box Retention and Cleanup Automation
On a schedule, the flow scans Box folders for files past a retention window, archives them to Azure Blob, removes the originals, and emails an owner a cleanup report. Enforces retention and reclaims Box storage.
Provided as-is, without warranty of any kind. Review and test each pattern in a non-production environment before deploying it to live automations. See our Terms.
Overview
This flow enforces a retention policy on Box and reclaims storage. On a daily schedule it scans a configured Box folder, identifies files older than a retention window, archives each file to Azure Blob Storage, removes the original from Box, and emails an Outlook summary report of everything cleaned up.
Why it matters: Box folders accumulate stale files that raise cost and compliance risk. Automating archive-then-delete enforces retention consistently and gives owners an auditable report every run.
Ships Off (demo).
Use Case
IT / Operations needs old Box files archived to cold storage and removed from Box on a recurring retention schedule, with a report of what was cleaned up. Routine cleanup is automated; legal-hold cases should still use Box's native retention policies.
Flow Architecture
Daily Retention Scan
RecurrenceRuns the cleanup scan once a day.
Initialize Config & Cutoff
Initialize variableSets the folder id, retention days, Blob account and path, report recipient, cutoff = addDays(utcNow(), -RetentionDays), and counters.
List Box Folder Files
Box - ListFolderLists items in the watched folder.
Per-file Retention Check
Apply to each + ConditionFor each file (not subfolder) older than the cutoff, proceeds to archive and delete (sequential, concurrency 1).
Archive then Delete
Box GetFileContent + Azure Blob CreateFile_V2 + Box DeleteFileDownloads the file, writes it to the blob archive, and deletes the Box original only after the archive Succeeded.
Send Cleanup Report
Office 365 Outlook - SendEmailV2Emails the HTML retention/cleanup summary.
Environment Variables
| Schema name | Type | Default | Description |
|---|---|---|---|
| flowlibs_BoxRetentionFolderId | String | 0 | Box folder ID to scan (0 = root). |
| flowlibs_BoxRetentionDays | String | 90 | Days a file may stay before cleanup. |
| flowlibs_BoxArchiveStorageAccount | String | flowlibsarchive | Azure Blob storage account (dataset). |
| flowlibs_BoxArchiveFolderPath | String | /box-archive | Target folder/container path for archives. |
| flowlibs_BoxRetentionReportRecipient | String | alerts@yourcompany.com | Report recipient address. |
Connectors & Connections
| Connector | API name | Actions used |
|---|---|---|
| Box | shared_box | ListFolder GetFileContent DeleteFile |
| Azure Blob Storage | shared_azureblob | CreateFile_V2 |
| Office 365 Outlook | shared_office365 | SendEmailV2 |
Note — All connections are referenced as solution connection references; the flow is portable between environments as long as a connection is mapped at import time.
Customization Guide
Almost every realistic variant of this flow can be implemented by changing environment variable values. A few cases require small edits inside the flow definition — those are called out explicitly below.
- Legal hold
- Add a condition to skip files tagged or in a held subfolder before archiving.
- Tiered retention
- Use different RetentionDays per folder by parameterizing or looping over multiple folder ids.
- Dry run
- Disable Delete Original From Box to report what would be cleaned without removing anything.
- Archive to SharePoint instead of Blob
- Swap the Azure Blob archive action for a SharePoint CreateFile action.
- Frequency
- Change the Recurrence interval/frequency for weekly or hourly cleanup windows.
Key Expressions
The flow is intentionally light on Power Fx / WDL gymnastics — the heaviest expressions are the branch-name concatenation and the approval outcome check. They are listed below in the order they appear in the flow.
EXPR.01Cutoff date
Retention window start.
EXPR.02Retention test (Condition)
Numeric date comparison via ticks().
EXPR.03Report row
Appended per cleaned file.
Comments
Sign in to join the conversation.
Sign inNo comments yet. Be the first to share your experience with this flow.