## Add a member to a key group (tenant:dms:admin)

`POST /api/dms/v1/key-groups/{id}/members`

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

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `id` | path | string (uuid) | yes |  |

### Request body

`application/json` (required)

- `ephemeralPublicKey` (string, required): Base64 SPKI P-256 ephemeral public key of the wrap
- `userId` (string, required): User id (e-mail address); must have registered a key
- `wrappedGroupPrivateKey` (string, required): The group private key wrapped for the member (base64)

Example:

```json
{
  "ephemeralPublicKey": "MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEexampleEphemeralKeyChristina",
  "userId": "christina.adler@muster-it.example",
  "wrappedGroupPrivateKey": "ZXhhbXBsZS13cmFwcGVkLWdyb3VwLWtleS1mb3ItY2hyaXN0aW5h"
}
```

### Responses

- **200** The key group (`application/json`)
- **400** Error (`application/json`)
- **404** Error (`application/json`)

Fields of the 200 answer:

- `algorithm` (string): Key agreement algorithm
- `createdAt` (string (date-time)): Creation time
- `createdBy` (string): Who created the group
- `description` (string): Description
- `id` (string (uuid)): Key group id
- `members` (array of object): Members of the group
  - `addedBy` (string): Who added the member
  - `createdAt` (string (date-time)): Time the member was added
  - `userId` (string): User id (e-mail address)
- `name` (string): Name, unique per tenant
- `publicKey` (string): Base64 SPKI public key of the group

Example 200 answer:

```json
{
  "algorithm": "ECDH-P256",
  "createdAt": "2026-03-10T14:20:00Z",
  "createdBy": "thomas.pfeiffer@muster-it.example",
  "description": "Personalakten und Gehaltsunterlagen",
  "id": "5d7f9b1d-3e5a-4c7b-9d1f-7b9d1f3a5c7e",
  "members": [
    {
      "addedBy": "thomas.pfeiffer@muster-it.example",
      "createdAt": "2026-03-10T14:20:00Z",
      "userId": "thomas.pfeiffer@muster-it.example"
    },
    {
      "addedBy": "thomas.pfeiffer@muster-it.example",
      "createdAt": "2026-03-10T14:22:31Z",
      "userId": "christina.adler@muster-it.example"
    }
  ],
  "name": "Personalabteilung",
  "publicKey": "MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEexamplePublicKeyOfTheGroupP256xyz"
}
```

### Example request

```bash
curl -X POST 'https://api.mbcom.cloud/api/dms/v1/key-groups/3f2b8c1e-7d4a-4e9b-9c2a-5b1d6e8f0a12/members' \
  -H "Authorization: Bearer $ACCESS_TOKEN" \
  -H 'Content-Type: application/json' \
  --data '{"ephemeralPublicKey":"MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEexampleEphemeralKeyChristina","userId":"christina.adler@muster-it.example","wrappedGroupPrivateKey":"ZXhhbXBsZS13cmFwcGVkLWdyb3VwLWtleS1mb3ItY2hyaXN0aW5h"}'
```
