# Retention and Deletion

Each object has its own expiry, fixed when the vault stores it. Three things remove an object: its expiry, your `delete`, and your subject erasure. Each removal leaves a record in the index and an event in the log.

## Retention

Your vault's retention is a number of days, or no expiry. Octet sets it for you. When the vault stores an object, it stamps the object with `retention_until`: the time it was received plus the retention.

- **Raising the retention** applies to new objects only. Objects already stored keep their expiry.
- **Lowering the retention** also shortens the expiry of objects already stored, from the next sweep on. It never shortens a write-once object.
- **Each retention change** is a `policy_changed` event in your log. Octet sends you its hash for your monitor allow-list.

## Expiry

Once an hour, the vault sweeps objects past their expiry. For each one it removes the sealed object, keeps the index row as a tombstone with the deletion time and reason, and appends an `object_deleted` event. An object under a legal hold is never swept.

After deletion, Google Cloud Storage keeps the sealed object for 7 more days in soft delete, so a faulty sweep or a mistaken deletion can be undone. The object stays sealed during that time, so Octet still can't read it. An expired object is therefore gone for good at most about 7 days and 1 hour after its `retention_until`.

## Legal hold

A legal hold keeps an object, or every object in the vault, until you clear it. The sweep skips a held object, and `delete` refuses it. Setting and clearing a hold are log events. See [Hold, Delete and Erase](/docs/vaults/integration/delete/).

## Write-once mode

In write-once mode, the vault locks each new sealed object in Cloud Storage until its `retention_until`. Nobody can delete it earlier or shorten its expiry, Octet included, and `delete` refuses it. Write-once mode needs a finite retention. Octet turns it on for you if your terms cover it.

The only way to make a locked object unreadable before it expires, for example for an erasure request, is to destroy every copy of the recipient key it is sealed to (see [Keys](/docs/vaults/concepts/keys/#recipient-keys)). That makes every object sealed to the key unreadable, not only this one. The objects stay stored until they expire.

## Deleting and erasing

- **`delete`** removes one object, with a reason recorded on the tombstone and in the event.
- **`subject erase`** removes every object written with a given `subject_ref`, and clears that `subject_ref` from the index. No log event names the subject. When a legal hold or write-once retention keeps some of the objects, `subject erase` lists them and exits with code `1`. Proofs that the vault seals from your app's uploads carry no `subject_ref`, so `subject erase` doesn't reach them. Delete those one by one with `delete`.

## When the vault is turned off

If Octet turns your vault off, new proofs stop being sealed. Proofs already queued are still sealed if their 24-hour buffer window has not ended. You keep reading, holding and deleting objects, and each object stays until its expiry.
