> Index of every page on this site: [llms.txt](https://docs.a-line.cloud/llms.txt)

# Keys

> Encryption keys managed by the key service. Preview.

Keys is in **Preview**. It is only available where the platform runs the key
service.

A key lives in a **key ring**. You use a key to encrypt and decrypt data
through the API; the key material itself stays in the key service and can
never be exported, read or downloaded.

## Envelope encryption

To encrypt large data, ask the key service for a data key. You get the data
key in plain form and wrapped by your key. Encrypt the data locally with the
plain data key, throw it away, and store the wrapped data key next to the
data. To decrypt, send the wrapped data key back to have it unwrapped. Only
small payloads travel to the key service; your data never does.

## Rotation

A key has versions. Rotating a key adds a version and makes it the primary:
new data is encrypted with it, while data encrypted with older versions
still decrypts. A rotation period, such as `90d`, rotates the key
automatically. Re-encrypt (rewrap) old ciphertexts to move them to the
newest version.

## Destroying keys

Data encrypted with a destroyed key can never be decrypted again, so
destruction is delayed. Scheduling it marks every version of the key for
destruction after a delay of 24 hours to 30 days (7 days by default). Until then you
can cancel it in the console. Keys need **Allow destroy** switched on before
an API key or [IaC](/iac/keys) can schedule their destruction.

## No key export

There is no way to get a key's material out of the platform, not through
the API, the console nor IaC [export](/iac/keys#export). Back up the data
you encrypted, not the key.
