> [!WARNING]
> **Warning:** Deleting keys is a total and complete wipeout. You cannot retrieve your keys after performing the actions on this page.

The Platform Administrator (PA) can delete Key Management System (KMS) keys in
the Management API server.

The PA can delete the AEAD and Signing keys in the project namespace.
See [Supported keys](https://docs.cloud.google.com/distributed-cloud/hosted/docs/latest/gdcag/application/ao-user/kms/kms.md.txt) for the full
list of KMS keys.

## Before you begin

Before deleting KMS keys, you must request the necessary permissions and prepare
your environment.

### Request IAM roles

Contact your IAM Org Admin to request the following roles:

- **KMS Admin** (`kms-admin`): create, update, delete, and use KMS keys in your project namespace.
- **Global MZAEADKey Deleter** (`global-mzaeadkey-deleter`): delete multi-zone `AEAD` keys in your project namespace.

### Prepare your environment

- [Download](https://docs.cloud.google.com/distributed-cloud/hosted/docs/latest/gdcag/resources/gdcloud-download.md.txt) and
  [install](https://docs.cloud.google.com/distributed-cloud/hosted/docs/latest/gdcag/resources/gdcloud-install.md.txt) the gdcloud CLI,
  if you haven't already done so.

- [Install the kubectl CLI](https://docs.cloud.google.com/distributed-cloud/hosted/docs/latest/gdcag/get-started/kubectl.md.txt).

- Generate the necessary kubeconfig files. You need the path to the relevant
  kubeconfig file to use with the `kubectl` commands.

  - To delete zonal keys, [generate the kubeconfig file for the management API server](https://docs.cloud.google.com/distributed-cloud/hosted/docs/latest/gdcag/platform/pa-user/iam/sign-in.md.txt#zonal-resources-kubeconfig).
  - To delete multi-zone keys, [generate the kubeconfig file for the global API server](https://docs.cloud.google.com/distributed-cloud/hosted/docs/latest/gdcag/platform/pa-user/iam/sign-in.md.txt#global-resources-kubeconfig).

## Delete all keys

You can delete zonal keys from the management API server or multi-zone keys from
the global API server.

### Delete all zonal keys

To delete all zonal keys in a project namespace, use the following
command:

```bash
kubectl --kubeconfig MANAGEMENT_API_SERVER_KUBECONFIG \
  delete KEY_PRIMITIVE --namespace=PROJECT --all
```

Replace the following:

- <var translate="no">MANAGEMENT_API_SERVER_KUBECONFIG</var>: the kubeconfig file of the management API server.
- <var translate="no">KEY_PRIMITIVE</var>: the key you want to delete. For example: `aeadkey` for the `AEAD` key.
- <var translate="no">PROJECT</var>: the name of the project. For example: `kms-test1`.

> [!NOTE]
> **Note:** To delete keys of all primitive types, ensure to run the command for all possible key primitive types: aeadkey and signingkey.

### Delete all multi-zone keys

To delete all multi-zone keys in a project namespace, use the following command:

```bash
kubectl --kubeconfig GLOBAL_API_SERVER_KUBECONFIG \
  delete mzaeadkey --namespace=PROJECT --all
```

Replace the following:

- <var translate="no">GLOBAL_API_SERVER_KUBECONFIG</var>: the kubeconfig file of the global API server.
- <var translate="no">PROJECT</var>: the name of the project. For example: `kms-test1`.