# Hold, Delete and Erase

These commands change your vault, so each needs a `vaults:admin` token. Each change is a log event. See [Retention and Deletion](/docs/vaults/concepts/retention/) for how expiry, holds and write-once mode interact.

## Place a legal hold

```bash
# One object
octet-vault --token-file admin.token hold set <object-id> --reason "<case reference>"

# The whole vault
octet-vault --token-file admin.token hold set --vault --reason "<case reference>"
```

A held object is never removed by expiry, and `delete` refuses it. Clear the hold with `hold clear <object-id>` or `hold clear --vault`.

## Delete one object

```bash
octet-vault --token-file admin.token delete <object-id> --reason "<reason>" --yes
```

The vault removes the sealed object, keeps a tombstone in the index, and appends an `object_deleted` event with your reason. Without `--reason`, the reason is `customer_request`. A deleted object can't be restored by you. Google Cloud Storage keeps the sealed bytes for 7 more days in soft delete, still sealed.

The vault refuses with `409 object_held` for a held object, and with `409 object_worm_locked` for a write-once object before its expiry. To make a write-once object unreadable sooner, destroy every copy of the recipient key it is sealed to. That makes every object sealed to the key unreadable (see [Keys](/docs/vaults/concepts/keys/#recipient-keys)).

## Erase a subject

`subject erase` removes every object written with a given `subject_ref`:

```bash
octet-vault --token-file read.token list --subject-ref <subject-ref>
octet-vault --token-file admin.token subject erase <subject-ref> --yes
```

It deletes each object as `delete` would, with the reason `subject_erasure` unless you pass `--reason`, and clears the `subject_ref` from the index, earlier tombstones included. No log event names the subject.

Objects under a legal hold, and write-once objects before their expiry, stay. When any object stays, the erasure is incomplete and `subject erase` exits with code `1`. Its output says how many objects it kept and lists each one with its reason: `held` for a legal hold, `worm_locked` for write-once retention. With `--json`, `retained` holds those objects, each with `object_id` and `reason`, and `retained_total` counts them. `retained` lists at most 1,000 objects, and `retained_total` counts every one. To erase a held object, clear its hold and run `subject erase` again. To make a write-once object unreadable before its expiry, destroy the recipient key it is sealed to (see [Keys](/docs/vaults/concepts/keys/#recipient-keys)).

Proofs your vault seals from your app's uploads carry no `subject_ref`. To remove those, use `delete` on each object.
