Deletion Semantics and Data Retention
- Deciders: Julian Bäume
- Date: 2026-09-04
Status
Accepted
Context
Teams had no way to delete anything. Threads could only be marked Done or Spam. Production feedback made two problems visible:
- When a mail was deleted outside of Teams (e.g. from the shared folder in App Suite), the thread kept showing up in the list with an empty message. The sync ignored the middleware's
deletedlist and never removed threads whose mails had vanished. - Non-actionable mail (advertisement, out-of-office replies) had no fitting resolution. Done claims somebody acted on it, Spam trains the filter and is wrong for legitimate but useless mail. Teams inboxes such as
info@also do not want aggressive spam filtering.
At the same time, Teams deliberately never implemented hard deletion. Shared inboxes carry business correspondence that users expect to keep, and retention obligations in several jurisdictions run for years. Losing comments, assignments or the timeline because a mail was cleaned up would be worse than an occasional stale entry.
Decision
Teams data is never hard-deleted
A thread row and its non-email actions (comments, assignments, categories, status history) are never removed by a user action. Removing content from Teams only ever changes a thread's state.
Mails leave the mailbox only via Trash
Deleting from Teams moves the thread's mails to the acting user's Trash folder of the account the folder belongs to. For public and shared folders this is the user's own Trash, which is where App Suite puts such a mail as well. Teams never calls the middleware with a hard delete and never honours the user's "permanently remove deleted mails" preference; the Trash folder's own retention applies from there.
The move uses mail?action=move rather than mail?action=delete. The move response carries the new mail ids, which a later restore needs. The delete action only hands them to the middleware's short-lived undo token.
The deleted thread state
A thread whose mails are gone from the inbox folder has status deleted. It leaves the Active, Assigned and Unassigned views and is listed under the Trash filter (status:deleted). Two paths lead there:
- Deleted from Teams. Mails are moved to Trash. Each email action follows its mail: it is flagged
movedByTeams, recordsdeletedBy(whose Trash it sits in) andrestoreTo(where it came from). The timeline shows who deleted the thread. - Deleted outside of Teams. The sync learns from the middleware's
deletedlist, re-imports, and soft-deletes every thread that owned a live mail before but is no longer listed. The timeline gets a system entry "removed from the mailbox". Threads that never had a mail (discussions, drafts) are never touched.
Restore
A thread deleted from Teams can be restored for as long as its mails are in Trash. Restore moves the mails back to their original folder and returns the thread to the workflow status it held before the deletion. Because IMAP ids are per folder and per mailbox, only the person who deleted owns the Trash copies and only they can restore. A thread without mails (e.g. created via comment) has nothing in Trash; restoring it only returns its workflow status. A thread soft-deleted by the sync cannot be restored from Teams; if the mail reappears in the folder (e.g. moved back in App Suite), the sync restores the thread automatically with a system timeline entry.
The UI offers an undo toast right after deleting. It calls the same restore endpoint, so undo and a later restore from the Trash view behave identically.
Failure handling
Unlike Spam, a delete does not hide the thread when the middleware refused to move any mail: the mails are still in the folder, and a hidden thread would be exactly the ghost the sync reconciliation removes. Partial failures still flip the thread and report the failed ids; the next sync sees the remaining live mails and reopens the thread.
Consequences
Positive
- Threads never disappear silently; comments and history survive every deletion path.
- Users can clear non-actionable mail without misusing Done or Spam, and the mailbox itself gets smaller, which was the operational ask.
- Delete and restore reuse the relocation bookkeeping introduced for Spam, so the sync needs no new special cases.
- Undo is cheap and does not depend on the middleware's undo TTL.
Negative
- Deleted threads accumulate in the database. They are hidden, not gone. A retention job that eventually purges
deletedthreads older than a configurable age is possible later, but is a separate decision. - Restore is limited to the deleting user. Colleagues see the thread in Trash but cannot bring it back; the error message tells them who can.
- A public folder the user may only read yields a middleware error on delete. Persisting folder rights so the UI can hide the action up front is a follow-up.
Alternatives Considered
Hard delete of the thread row. Simplest, but loses comments, assignments and history, and contradicts the retention expectations that kept Teams from deleting anything so far.
Status-only "dismiss" without touching the mailbox. Solves the semantic complaint about Done, but leaves the mailbox growing, which was the second half of the feedback. It remains an option as a fallback for read-only folders.
Middleware action=delete plus its undo token. Honours the user's hard-delete preference by default, does not return the Trash ids, and the undo expires after seconds. Teams needs the ids to offer restore days later from the Trash view.
Reusing core-ui's undo toast. It is bound to middleware undo tokens and would not update the Teams database. Teams ships a small toast of its own that calls the Teams restore endpoint.

