## The caller's key wraps of an encrypted version (tenant:dms:read)

`GET /api/dms/v1/documents/{id}/encryption`

Module: DMS · operationId: `getDocumentEncryption` · Tag: Encryption · Auth: access token (`Authorization: Bearer <accessToken>`)

`400` for unencrypted documents, `403` when the caller holds no wrap (directly or through a key group). Callers with `tenant:dms:admin` also see the recovery wrap.

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `id` | path | string (uuid) | yes |  |
| `version` | query | integer |  | Version number; default the current version |

### Responses

- **200** Envelope (`application/json`)
- **400** Error (`application/json`)
- **403** Error (`application/json`)
- **404** Error (`application/json`)

Fields of the 200 answer:

- `alg` (string, required): Content encryption algorithm
- `documentId` (string (uuid), required): Document id
- `groupKeys` (array of GroupKeyShare, required): The caller's shares of the groups the document is wrapped for
  - `algorithm` (string): Key agreement algorithm
  - `ephemeralPublicKey` (string): Base64 SPKI P-256 ephemeral public key of the wrap
  - `groupId` (string (uuid)): Key group id
  - `groupName` (string): Key group name
  - `publicKey` (string): Base64 SPKI public key of the group
  - `wrappedGroupPrivateKey` (string): The group private key wrapped for the caller (base64)
- `iv` (string, required): Initialization vector of the content encryption (base64)
- `versionNumber` (integer, required): Version the wraps belong to
- `wraps` (array of KeyWrap, required): The document key wrapped for the caller and its groups
  - `ephemeralPublicKey` (string, required): Base64 SPKI P-256 public key
  - `recipientId` (string, required): User id (e-mail), key group id or recovery key id
  - `recipientType` (string, required): Who the wrap is for (one of `USER`, `GROUP`, `RECOVERY`)
  - `wrappedDek` (string, required): The document key wrapped with ECDH + AES-GCM (base64)
- `encryptedMetadata` (string): Client-encrypted metadata, if any

Example 200 answer:

```json
{
  "alg": "AES-256-GCM",
  "documentId": "9d1f3b5d-7e9a-4c1d-8f3b-1d3f5b7d9e1a",
  "groupKeys": [
    {
      "algorithm": "ECDH-P256",
      "ephemeralPublicKey": "MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEexampleEphemeralKeyChristina",
      "groupId": "5d7f9b1d-3e5a-4c7b-9d1f-7b9d1f3a5c7e",
      "groupName": "Personalabteilung",
      "publicKey": "MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEexamplePublicKeyOfTheGroupP256xyz",
      "wrappedGroupPrivateKey": "ZXhhbXBsZS13cmFwcGVkLWdyb3VwLWtleS1mb3ItY2hyaXN0aW5h"
    }
  ],
  "iv": "ZXhhbXBsZS1pdi0xMg==",
  "versionNumber": 1,
  "wraps": [
    {
      "ephemeralPublicKey": "MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEexampleEphemeralKeyDocument",
      "recipientId": "5d7f9b1d-3e5a-4c7b-9d1f-7b9d1f3a5c7e",
      "recipientType": "GROUP",
      "wrappedDek": "ZXhhbXBsZS13cmFwcGVkLWRlay1mb3ItZ3JvdXA"
    }
  ]
}
```

### Example request

```bash
curl -X GET 'https://api.mbcom.cloud/api/dms/v1/documents/3f2b8c1e-7d4a-4e9b-9c2a-5b1d6e8f0a12/encryption' \
  -H "Authorization: Bearer $ACCESS_TOKEN"
```
