---
title: "Encrypt"
method: POST
path: "/kms-key/{id}/encrypt"
tags: ["crypto"]
---

# Encrypt

`POST /kms-key/{id}/encrypt`

## Request

- Base URL: `https://api-ch-gva-2.exoscale.com/v2`
- URL: `https://api-ch-gva-2.exoscale.com/v2/kms-key/{id}/encrypt`
- Auth: none declared
- TypeScript: <https://skmtc.dev/exoscale/apis/exoscale-api/docs/kms-key/:id/encrypt/post.ts> (a function with typed inputs; its response is checked against the schema)

Encrypts a plaintext.

## Path parameters

- `id` string, uuid, required

## Request body

- EncryptRequest
  - `encryption-context` string, byte, nullable: Base64-encoded bytes to be used as the Additional Authenticated Data (AAD) for encryption integrity.
  - `plaintext` string, byte, required: The Base64-encoded plaintext data you wish to encrypt.

## Response `200`

Base64 encoded ciphertext

- EncryptResponse
  - `ciphertext` string, byte, required: The resulting Base64-encoded ciphertext after encryption.

## Other responses

- `400`: ### Errors Key Not Found: The request was rejected because the specified KMS Key could not be found. Key is Disabled: The request was rejected because the specified KMS key is disabled. Invalid Usage: The request was rejected because the operation is only allowed on symmetric keys with usage "encrypt-decrypt".

## Changes

- **2026-11-06** `63da6f74c845`: 2 warning
  - removed the optional property `errors` from the response with the `400` status
  - removed the optional property `instance` from the response with the `400` status
- **2026-03-16** `e05707a7b346`: 1 info
  - endpoint added

[Operation history](https://skmtc.dev/exoscale/apis/exoscale-api/changes/kms-key/:id/encrypt/post.md)

---

[API](https://skmtc.dev/exoscale/apis/exoscale-api.md) - [All operations](https://skmtc.dev/exoscale/apis/exoscale-api/llms.txt) - [OpenAPI document](https://skmtc.dev/exoscale/apis/exoscale-api/revisions/63da6f74c845?raw)
