# Tenants and key hierarchy

Tenants with their key-encryption keys, the root key, rotation and crypto-shredding. Aegis Core API, `HierarchyService`: 8 operations, generated from the OpenAPI document of Aegis Core 0.13.0.

## Rewrap progress

`GET /v1/sys/rewrap`

How far the background job has moved each level.

- Role: `auditor` or higher
- gRPC: `/aegis.v1.HierarchyService/RewrapProgress`

Response `200` (`application/json`): [RewrapProgressResponse](#schema-rewrapprogressresponse)

Errors: `400` · `401` · `403` · `404` · `409` · `413` · `500` · `503` ([what each means](https://docs.qblackbit.com/api/core/index.md#errors)).

## Retire root

`POST /v1/sys/root/retire`

Forgets every root version but the current one.

- Role: `admin` or higher
- gRPC: `/aegis.v1.HierarchyService/RetireRoot`

Request body, required (`application/json`):

| Field | Type | Description |
| --- | --- | --- |
| `override_backup` | boolean | Retire although no backup was taken since the last rotation (recorded). |

Response `200` (`application/json`): [RetireRootResponse](#schema-retirerootresponse)

Errors: `400` · `401` · `403` · `404` · `409` · `413` · `500` · `503` ([what each means](https://docs.qblackbit.com/api/core/index.md#errors)).

## Rotate root

`POST /v1/sys/root/rotate`

A new root key version.

- Role: `admin` or higher
- gRPC: `/aegis.v1.HierarchyService/RotateRoot`

Request body, required (`application/json`):

No fields.

Response `200` (`application/json`): [RotateRootResponse](#schema-rotaterootresponse)

Errors: `400` · `401` · `403` · `404` · `409` · `413` · `500` · `503` ([what each means](https://docs.qblackbit.com/api/core/index.md#errors)).

## List tenants

`GET /v1/tenants`

The key-encryption domains.

- Role: `admin` or higher
- gRPC: `/aegis.v1.HierarchyService/ListTenants`

Response `200` (`application/json`): [ListTenantsResponse](#schema-listtenantsresponse)

Errors: `400` · `401` · `403` · `404` · `409` · `413` · `500` · `503` ([what each means](https://docs.qblackbit.com/api/core/index.md#errors)).

## Create tenant

`POST /v1/tenants`

Creates a tenant with its first key-encryption key.

- Role: `admin` or higher
- gRPC: `/aegis.v1.HierarchyService/CreateTenant`

Request body, required (`application/json`):

| Field | Type | Description |
| --- | --- | --- |
| `name` | string | The name. |

Response `201` (`application/json`): [Tenant](#schema-tenant)

Errors: `400` · `401` · `403` · `404` · `409` · `413` · `500` · `503` ([what each means](https://docs.qblackbit.com/api/core/index.md#errors)).

## Retire tenant

`POST /v1/tenants/{name}/retire`

Erases the tenant's older key-encryption keys.

- Role: `admin` or higher
- gRPC: `/aegis.v1.HierarchyService/RetireTenant`

| Parameter | In | Type | Description |
| --- | --- | --- | --- |
| `name` | path | string, required |  |

Request body, required (`application/json`):

| Field | Type | Description |
| --- | --- | --- |
| `override_backup` | boolean | Retire although no backup was taken since the last rotation (recorded). |

Response `200` (`application/json`): [Tenant](#schema-tenant)

Errors: `400` · `401` · `403` · `404` · `409` · `413` · `500` · `503` ([what each means](https://docs.qblackbit.com/api/core/index.md#errors)).

## Rotate tenant

`POST /v1/tenants/{name}/rotate`

A new current key-encryption key version.

- Role: `admin` or higher
- gRPC: `/aegis.v1.HierarchyService/RotateTenant`

| Parameter | In | Type | Description |
| --- | --- | --- | --- |
| `name` | path | string, required |  |

Response `200` (`application/json`): [Tenant](#schema-tenant)

Errors: `400` · `401` · `403` · `404` · `409` · `413` · `500` · `503` ([what each means](https://docs.qblackbit.com/api/core/index.md#errors)).

## Shred tenant

`POST /v1/tenants/{name}/shred`

Erases the tenant's key-encryption keys and destroys every key under it.

- Role: `admin` or higher
- gRPC: `/aegis.v1.HierarchyService/ShredTenant`

| Parameter | In | Type | Description |
| --- | --- | --- | --- |
| `name` | path | string, required |  |

Request body, required (`application/json`):

| Field | Type | Description |
| --- | --- | --- |
| `confirm` | string | The tenant's name again. |

Response `200` (`application/json`): [ShredTenantResponse](#schema-shredtenantresponse)

Errors: `400` · `401` · `403` · `404` · `409` · `413` · `500` · `503` ([what each means](https://docs.qblackbit.com/api/core/index.md#errors)).

## Schemas

### ListTenantsResponse

The tenants.

| Field | Type | Description |
| --- | --- | --- |
| `tenants` | array of [Tenant](#schema-tenant) | Every tenant. |

### RetireRootResponse

The root versions forgotten.

| Field | Type | Description |
| --- | --- | --- |
| `retired` | array of integer (int64) | Their numbers. |

### RewrapProgressResponse

The job's progress per level.

| Field | Type | Description |
| --- | --- | --- |
| `done` | boolean | Whether every level is on its current version. |
| `levels` | array of [RewrapLevel](#schema-rewraplevel) | `root`, then `tenant:<name>`. |

### RotateRootResponse

The new root version.

| Field | Type | Description |
| --- | --- | --- |
| `version` | integer (int64) | Its number. |

### ShredTenantResponse

What was shredded.

| Field | Type | Description |
| --- | --- | --- |
| `keys` | integer (int64) | Keys destroyed. |
| `versions` | integer (int64) | Key versions erased. |

### Tenant

A key-encryption domain.

| Field | Type | Description |
| --- | --- | --- |
| `created` | integer (int64) | When it was created. |
| `current_version` | integer (int64) | The current key-encryption key version. |
| `name` | string | The name. |
| `state` | string | `active` or `destroyed`. |
| `versions` | array of [TenantVersion](#schema-tenantversion) | Every version. |

### RewrapLevel

One level of the hierarchy.

| Field | Type | Description |
| --- | --- | --- |
| `behind` | integer (int64) | Items still under an older version. |
| `level` | string | The level. |
| `total` | integer (int64) | Items in all. |
| `version` | integer (int64) | Its current version. |

### TenantVersion

A tenant key-encryption key version.

| Field | Type | Description |
| --- | --- | --- |
| `created` | integer (int64) | When it was made. |
| `number` | integer (int64) | Its number. |
| `retired` | boolean | Whether it is erased. |
