# Take back a change

> Undo a mistaken write softly, bring it back if you were wrong, remove a version's values for good, or delete a whole secret.

You wrote the wrong value, or an old credential must be gone for certain. You choose how final each step is: a delete
can be undone, a destroy can't, and deleting the whole secret frees the path to start again.

**Before you start:** you can write the secret: here, `web/github` in your own vault. You are signed in with your
session in `$CVYUH_SESSION` ([Call the API](/develop/api/) shows how).

## Take it back

<Steps>

1. Delete the latest version, softly:

   ```sh
   curl -X DELETE https://foobar.cvyuh.com/api/v0/vault/managed/v1/me/data/web/github \
     -H "Cookie: x-cvyuh-token=$CVYUH_SESSION"
   ```

   Reading that version now answers `404`, with its metadata showing when it was deleted. To delete chosen versions,
   send `{ "versions": [2, 3] }` to `…/me/delete/web/github`.

2. If you were wrong, bring versions back:

   ```sh
   curl https://foobar.cvyuh.com/api/v0/vault/managed/v1/me/undelete/web/github \
     -H "Cookie: x-cvyuh-token=$CVYUH_SESSION" \
     -H "Content-Type: application/json" \
     -d '{ "versions": [3] }'
   ```

3. To remove values for good, destroy the versions:

   ```sh
   curl https://foobar.cvyuh.com/api/v0/vault/managed/v1/me/destroy/web/github \
     -H "Cookie: x-cvyuh-token=$CVYUH_SESSION" \
     -H "Content-Type: application/json" \
     -d '{ "versions": [1] }'
   ```

   A destroyed version answers `404` with its metadata marked `destroyed`, and nothing brings it back.

4. To delete the whole secret, every version and its settings:

   ```sh
   curl -X DELETE https://foobar.cvyuh.com/api/v0/vault/managed/v1/me/metadata/web/github \
     -H "Cookie: x-cvyuh-token=$CVYUH_SESSION"
   ```

</Steps>

Each call answers `204`.

## Check it worked

A `GET` on `https://foobar.cvyuh.com/api/v0/vault/managed/v1/me/metadata/web/github` shows each version's
`deletion_time` and `destroyed`. After the whole secret is deleted, the path and its metadata answer `404`, and the
next write is version 1.

## Related

- [Delete, undelete and destroy](/secrets-store/secrets/delete-and-destroy/): what each step leaves.
- [Limit a secret's history](/secrets-store/guides/limit-a-secrets-history/): have versions lapse by themselves.
