# System

Health, readiness, information, metrics, providers, self-tests, switches, backups and the OpenAPI document. Aegis Core API, `SystemService`: 15 operations, generated from the OpenAPI document of Aegis Core 0.13.0.

## Health

`GET /v1/health`

Liveness: the process answers. Open to anyone.

- Role: none (open to anyone)
- gRPC: `/aegis.v1.SystemService/Health`

Response `200` (`application/json`): [HealthResponse](#schema-healthresponse)

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

## Open API

`GET /v1/openapi.json`

This contract as an OpenAPI 3.1 document. Open to anyone.

- Role: none (open to anyone)
- gRPC: `/aegis.v1.SystemService/OpenApi`

Response `200` (`application/json`): string

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

## Ready

`GET /v1/ready`

Readiness: whether the daemon is ready for work (vault unsealed, generator healthy, runtime state not degraded). Open to anyone, and says only whether; unavailable (503) when not ready.

- Role: none (open to anyone)
- gRPC: `/aegis.v1.SystemService/Ready`

Response `200` (`application/json`): [ReadyResponse](#schema-readyresponse)

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

## Backup

`POST /v1/sys/backup`

The vault as a backup file; restore it with `aegisd restore`.

- Role: `admin` or higher
- gRPC: `/aegis.v1.SystemService/Backup`

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

No fields.

Response `200` (`application/octet-stream`): string

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

## Snapshot

`POST /v1/sys/backup/snapshot`

A verified backup kept by the daemon in its backup directory.

- Role: `admin` or higher
- gRPC: `/aegis.v1.SystemService/Snapshot`

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

No fields.

Response `200` (`application/json`): [SnapshotResponse](#schema-snapshotresponse)

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

## Info

`GET /v1/sys/info`

What this daemon is: version, build, deployment, policy, licence, randomness, seal state, locked memory, the witness and the runtime state.

- Role: `auditor` or higher
- gRPC: `/aegis.v1.SystemService/Info`

Response `200` (`application/json`): [InfoResponse](#schema-inforesponse)

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

## Metrics

`GET /v1/sys/metrics`

The daemon's metrics in the Prometheus text format: the `monitor` role, which may read this and readiness and nothing else, and above.

- Role: `monitor` or higher
- gRPC: `/aegis.v1.SystemService/Metrics`

Response `200` (`text/plain; version=0.0.4`): string

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

## Providers

`GET /v1/sys/providers`

Every provider's manifest, its offerings and their self-test health.

- Role: `auditor` or higher
- gRPC: `/aegis.v1.SystemService/Providers`

Response `200` (`application/json`): [ProvidersResponse](#schema-providersresponse)

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

## Ready detail

`GET /v1/sys/ready`

Readiness with every check and the reasons: the `monitor` role and above.

- Role: `monitor` or higher
- gRPC: `/aegis.v1.SystemService/ReadyDetail`

Response `200` (`application/json`): [ReadyResponse](#schema-readyresponse)

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

## Self test

`POST /v1/sys/selftest`

Runs the self-tests again, for every offered algorithm or one.

- Role: `admin` or higher
- gRPC: `/aegis.v1.SystemService/SelfTest`

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

| Field | Type | Description |
| --- | --- | --- |
| `algorithm` | string, nullable | One algorithm, or every offered one when absent. |

Response `200` (`application/json`): [SelfTestResponse](#schema-selftestresponse)

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

## Reaffirm state

`POST /v1/sys/state/reaffirm`

Accepts a state file the audit chain does not vouch for, as it stands.

- Role: `admin` or higher
- gRPC: `/aegis.v1.SystemService/ReaffirmState`

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

No fields.

Response `200` (`application/json`): [ReaffirmStateResponse](#schema-reaffirmstateresponse)

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

## Status

`GET /v1/sys/status`

Whether the vault is sealed, the deployment, the policy and the providers.

- Role: `auditor` or higher
- gRPC: `/aegis.v1.SystemService/Status`

Response `200` (`application/json`): [StatusResponse](#schema-statusresponse)

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

## List switches

`GET /v1/sys/switches`

The modules, the switches that are off and every algorithm's standing.

- Role: `auditor` or higher
- gRPC: `/aegis.v1.SystemService/ListSwitches`

Response `200` (`application/json`): [ListSwitchesResponse](#schema-listswitchesresponse)

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

## Set switch

`POST /v1/sys/switches`

Switches a module, family or algorithm off or on, with a reason.

- Role: `admin` or higher
- gRPC: `/aegis.v1.SystemService/SetSwitch`

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

| Field | Type | Description |
| --- | --- | --- |
| `enabled` | boolean | On or off. |
| `name` | string | A module, family or algorithm. |
| `reason` | string | One line, at most 300 characters. |

Response `200` (`application/json`): [SetSwitchResponse](#schema-setswitchresponse)

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

## Who am i

`GET /v1/sys/whoami`

The caller: name, role, tenant, how it signed in, its scope and expiry. Any principal, the `emergency` role included.

- Role: `emergency` or higher
- gRPC: `/aegis.v1.SystemService/WhoAmI`

Response `200` (`application/json`): [WhoAmIResponse](#schema-whoamiresponse)

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

## Schemas

### HealthResponse

The daemon is alive.

| Field | Type | Description |
| --- | --- | --- |
| `status` | string | Always `ok`. |

### InfoResponse

What this daemon is.

| Field | Type | Description |
| --- | --- | --- |
| `break_glass` | [BreakGlassReport](#schema-breakglassreport), nullable | Break-glass sessions running now, and whether that raises the alarm. |
| `build` | [Build](#schema-build), nullable | How it was built. |
| `deployment` | string | The deployment profile. |
| `licence` | [Licence](#schema-licence), nullable | What the licence covers. |
| `memory` | [Memory](#schema-memory), nullable | The locked memory the vault's keys live in (VLT-008). |
| `policy` | [Policy](#schema-policy), nullable | The policy in force. |
| `randomness` | [Randomness](#schema-randomness), nullable | The engine's generator, when it has one. |
| `sealed` | boolean | Whether the vault is sealed. |
| `started` | integer (int64) | When it started, in seconds since the Unix epoch. |
| `state` | [RuntimeState](#schema-runtimestate), nullable | The runtime state and how far the audit chain vouches for it. |
| `state_file` | boolean | Whether a state file keeps runtime changes. |
| `updates` | [InfoUpdates](#schema-infoupdates), nullable | Updates: whether the directives' restrictions are held because they could not be checked. |
| `uptime` | integer (int64) | Seconds since it started. |
| `variable_time_allowed` | boolean | Whether this daemon allows the sets that run in variable time. |
| `version` | string | The release. |
| `witness` | [Witness](#schema-witness), nullable | The signed-checkpoint export (VLT-006). |

### ListSwitchesResponse

The switches.

| Field | Type | Description |
| --- | --- | --- |
| `algorithms` | array of [SwitchedAlgorithm](#schema-switchedalgorithm) | Every algorithm's standing. |
| `modules` | array of [Module](#schema-module) | The modules. |
| `switches` | array of [Switch](#schema-switch) | The switches that are off. |

### ProvidersResponse

Every provider.

| Field | Type | Description |
| --- | --- | --- |
| `providers` | array of [Provider](#schema-provider) | The providers, in the engine's order. |

### ReadyResponse

Whether the daemon is ready.

| Field | Type | Description |
| --- | --- | --- |
| `checks` | array of [ReadyCheck](#schema-readycheck) | Each check (`/v1/sys/ready` only). |
| `error` | string, nullable | Why not, when not ready. |
| `ready` | boolean | Ready for work. |

### ReaffirmStateResponse

The state accepted.

| Field | Type | Description |
| --- | --- | --- |
| `condition` | string | `vouched`. |
| `generation` | integer (int64) | Its generation. |

### SelfTestResponse

The self-test run.

| Field | Type | Description |
| --- | --- | --- |
| `failed` | integer (int64) | Tests failed. |
| `not_in_deployment` | integer (int64) | Algorithms outside this deployment. |
| `not_run` | integer (int64) | Tests that could not run. |
| `passed` | integer (int64) | Tests passed. |
| `results` | array of [SelfTestResult](#schema-selftestresult) | Each test. |

### SetSwitchResponse

The switch set.

| Field | Type | Description |
| --- | --- | --- |
| `enabled` | boolean | On or off now. |
| `name` | string | Its name. |
| `scope` | string | `module`, `family` or `algorithm`. |

### SnapshotResponse

A backup kept by the daemon.

| Field | Type | Description |
| --- | --- | --- |
| `file` | string | The file. |
| `keys` | integer (int64) | Keys verified. |
| `records` | integer (int64) | Audit records verified. |
| `sealed` | string, nullable | The copy sealed to the recovery key, if one is set. |
| `versions` | integer (int64) | Key versions verified. |

### StatusResponse

The daemon's standing.

| Field | Type | Description |
| --- | --- | --- |
| `deployment` | string | `laboratory`, `production` or a regional profile. |
| `policy` | string | The policy's name. |
| `providers` | array of string | The providers' identifiers. |
| `sealed` | boolean | Whether the vault is sealed. |

### WhoAmIResponse

The caller.

| Field | Type | Description |
| --- | --- | --- |
| `actor` | string | The actor in the audit chain: the name with its tenant, and `+break-glass` during a session. |
| `break_glass` | integer (int64), nullable | When the caller's break-glass session ends, while one runs. |
| `expires` | integer (int64), nullable | When the credential stops working, in seconds since the Unix epoch. |
| `granted` | string | The role as granted: a custom role's name, or the built-in one. |
| `name` | string | The holder's name. |
| `role` | string | The built-in role the request runs with: `emergency`, `monitor`, `auditor`, `operator` or `admin` (`admin` during a break-glass session). |
| `scope` | [TokenScope](#schema-tokenscope), nullable | What a scoped token may reach. |
| `tenant` | string | The tenant, `default`, or `*` for the cross-tenant role. |
| `via` | string | How the caller proved who it is: `token`, `oidc` or `certificate`. |

### BreakGlassReport

The break-glass sessions running now (SVC-003).

| Field | Type | Description |
| --- | --- | --- |
| `alarm` | boolean | Whether any session runs. |
| `sessions` | array of [BreakGlassSession](#schema-breakglasssession) | The sessions. |

### Build

How the daemon was built.

| Field | Type | Description |
| --- | --- | --- |
| `profile` | string | `debug` or `release`. |
| `target` | string | The operating system and architecture. |

### InfoUpdates

The updates part of the daemon's information.

| Field | Type | Description |
| --- | --- | --- |
| `degraded` | boolean | The audit chain could not be read, so the directives' restrictions in force are held. |
| `modules` | array of [ModuleReport](#schema-modulereport) | The algorithm modules not running freely: limited or refused, each with the reason. |

### Licence

What the licence covers.

| Field | Type | Description |
| --- | --- | --- |
| `modules` | array of string | The licensed modules; absent when every module is licensed. |

### Memory

Locked memory.

| Field | Type | Description |
| --- | --- | --- |
| `failed` | integer (int64) | Secrets that could not be locked since start. |
| `live` | integer (int64) | Allocations held now. |
| `locked_pages` | integer (int64) | Pages locked now. |
| `policy` | string | `required` or `best-effort`. |

### Policy

The policy in force.

| Field | Type | Description |
| --- | --- | --- |
| `contextless_refusals` | integer (int64) | Operations refused because no context was installed while the policy reads the caller or the key: each is a daemon path that forgot its context. |
| `name` | string | Its name. |
| `rules` | array of string | Its rules, one line each. |

### Randomness

The engine's random generator (ADR 0004, addendum).

| Field | Type | Description |
| --- | --- | --- |
| `external` | [ExternalSource](#schema-externalsource), nullable | The external source. |
| `failed` | boolean | Whether the generator is in its error state. |
| `generator` | string | The SP 800-90A generator. |
| `mechanism` | string | Its mechanism, in words. |
| `requests` | integer (int64) | Requests served. |

### RuntimeState

The runtime state (ADR 0010).

| Field | Type | Description |
| --- | --- | --- |
| `condition` | string | `unchecked`, `vouched`, `unaudited` or `degraded`. |
| `detail` | string, nullable | Why, when not vouched. |
| `generation` | integer (int64) | Its generation. |
| `pending` | integer (int64) | Records waiting for the next unseal. |

### Witness

The signed-checkpoint export.

| Field | Type | Description |
| --- | --- | --- |
| `configured` | boolean | Whether exports are configured. |
| `degraded` | boolean | Whether exports are failing now. |
| `error` | string, nullable | The last error while they fail. |
| `exported` | integer (int64) | The newest record exported. |
| `failures` | integer (int64) | Failed exports since start. |
| `last` | integer (int64) | When, in seconds since the Unix epoch. |

### Module

A licensed module.

| Field | Type | Description |
| --- | --- | --- |
| `algorithms` | integer (int64) | Algorithms in it. |
| `algorithms_off` | integer (int64) | Algorithms switched off in it. |
| `licensed` | boolean | Whether the licence includes it. |
| `name` | string | Its name. |
| `off` | boolean | Whether it is switched off. |

### Switch

A switch that is off.

| Field | Type | Description |
| --- | --- | --- |
| `by` | string, nullable | Who switched it off. |
| `name` | string | A module, family or algorithm. |
| `reason` | string, nullable | Why it is off. |
| `scope` | string | `module`, `family`, `algorithm` or `unknown`. |
| `time` | integer (int64), nullable | When, in seconds since the Unix epoch. |

### SwitchedAlgorithm

An algorithm and the switch that holds it off, if any.

| Field | Type | Description |
| --- | --- | --- |
| `family` | string | The family. |
| `id` | string | The identifier. |
| `kind` | string | The kind. |
| `module` | string | The module. |
| `name` | string | The name. |
| `off_by` | string, nullable | The switch that holds it off. |

### Provider

One provider.

| Field | Type | Description |
| --- | --- | --- |
| `id` | string | Its identifier. |
| `implementation` | string | How it is implemented. |
| `isolation` | string | How it is isolated. |
| `licence` | string | Its licence (SPDX). |
| `name` | string | Its name. |
| `offerings` | array of [Offering](#schema-offering) | What it offers and the self-test health of each. |
| `origin` | string | Where its code comes from. |
| `summary` | [HealthSummary](#schema-healthsummary), nullable | Counts of the self-test results. |
| `validation` | string, nullable | A validation certificate quoted exactly, if any. |
| `version` | string | Its version. |

### ReadyCheck

One readiness check.

| Field | Type | Description |
| --- | --- | --- |
| `detail` | string | What it found. |
| `name` | string | `vault`, `randomness`, `state`, `selftests` or `witness`. |
| `ok` | boolean | Whether it passes. |

### SelfTestResult

One self-test.

| Field | Type | Description |
| --- | --- | --- |
| `algorithm` | string | The algorithm. |
| `deployed` | boolean | Whether the algorithm is in this deployment. |
| `passed` | boolean | Whether it passed. |
| `provider` | string | The provider. |
| `ran` | boolean | Whether the test ran. |

### TokenScope

What a scoped token may reach: each list, when given, narrows it.

| Field | Type | Description |
| --- | --- | --- |
| `keys` | array of string | Key names as the holder writes them, for example `payments-*`. |
| `operations` | array of string | Operations, for example `key.sign` or `key.*`. |
| `paths` | array of string | Route patterns, for example `/v1/keys/payments-*/sign` (`*` within a segment, `**` below). |

### BreakGlassSession

A break-glass session.

| Field | Type | Description |
| --- | --- | --- |
| `holder` | string | The holder of the `emergency` role. |
| `reason` | string | Why, one line. |
| `started` | integer (int64) | When it started, in seconds since the Unix epoch. |
| `tenant` | string | Its tenant. |
| `until` | integer (int64) | When it ends. |

### ModuleReport

An algorithm module installed on its own (DLV-007, ADR 0024, section 4).

| Field | Type | Description |
| --- | --- | --- |
| `limited` | string, nullable | Why it is limited. |
| `name` | string | The module. |
| `protocol` | integer (int64), nullable | The provider protocol it speaks. |
| `provider` | string, nullable | The provider it runs. |
| `reason` | string, nullable | Why it was refused. |
| `requires_core` | string, nullable | The core releases it supports, as a version range. |
| `root` | string | Its installation's directory. |
| `sha256` | string, nullable | The SHA2-256 of the binary started. |
| `state` | string | `running`, `limited` (revoked, not as malicious: new protection refused) or `refused`. |
| `version` | string, nullable | Its release. |

### ExternalSource

An external entropy source mixed into every request.

| Field | Type | Description |
| --- | --- | --- |
| `configured` | boolean | Whether one is configured. |
| `failed` | boolean | Whether it failed. |
| `mixed` | integer (int64) | Requests it was mixed into. |

### HealthSummary

Counts of self-test results.

| Field | Type | Description |
| --- | --- | --- |
| `failed` | integer (int64) | Failed. |
| `passed` | integer (int64) | Passed. |
| `untested` | integer (int64) | Not tested yet. |

### Offering

One algorithm a provider offers.

| Field | Type | Description |
| --- | --- | --- |
| `algorithm` | string | The algorithm. |
| `health` | string | `untested`, `passed` or `failed`. |
| `kind` | string | Its kind. |
