# Aegis Core API

The API of `aegisd`, the Aegis Core daemon you run yourself. Every operation is one RPC of a protobuf contract, served on the same TLS listener as gRPC (`/aegis.v1.<Service>/<Rpc>`) and as the REST route shown on each page, through one implementation: the same roles, limits, audit records and refusals apply to both.

This reference is generated from the OpenAPI document of **Aegis Core 0.13.0**. A running daemon serves its own release's document at `GET /v1/openapi.json`.

## Services

| Service | Page | Operations |
| --- | --- | --- |
| `KeyService` | [Keys](https://docs.qblackbit.com/api/core/keys.md) | Create, import, rotate, states, dates, delete, destroy; sign, verify, encrypt, decrypt, decapsulate, agree, receive, export |
| `ToolsService` | [Tools](https://docs.qblackbit.com/api/core/tools.md) | Hash, MAC, derive, wrap and unwrap, AEAD, encapsulate, HPKE, combine, transport, verify, random |
| `EnvelopeService` | [Envelopes and re-wrap](https://docs.qblackbit.com/api/core/envelopes.md) | Describe an envelope; re-wrap jobs |
| `EncodingService` | [Encodings](https://docs.qblackbit.com/api/core/encodings.md) | PKCS #8, SPKI, JWK and COSE keys; certificates and requests; CMS, JWS, JWE and COSE |
| `AlgorithmService` | [Algorithms](https://docs.qblackbit.com/api/core/algorithms.md) | The catalogue |
| `PolicyService` | [Policy packs](https://docs.qblackbit.com/api/core/policy.md) | Packs, activation, advisories, protocol values |
| `AuditService` | [Audit](https://docs.qblackbit.com/api/core/audit.md) | Records, verification, checkpoints, export |
| `AccessService` | [Access and approvals](https://docs.qblackbit.com/api/core/access.md) | Tokens, access policy, approvals, break-glass, OpenID Connect |
| `SealService` | [Seal and unseal](https://docs.qblackbit.com/api/core/seal.md) | Unseal, seal, rekey |
| `HierarchyService` | [Tenants and key hierarchy](https://docs.qblackbit.com/api/core/tenants.md) | Tenants, the root key, re-wrap progress |
| `SystemService` | [System](https://docs.qblackbit.com/api/core/system.md) | Health, readiness, information, metrics, providers, self-tests, switches, backups |
| `LicenceService` | [Licence](https://docs.qblackbit.com/api/core/licence.md) | The licence and its installation |
| `UpdatesService` | [Updates](https://docs.qblackbit.com/api/core/updates.md) | Upload, import, apply, roll back, commit |

## Transport and authentication

- TLS 1.3 with hybrid key exchange only (X25519MLKEM768, SecP256r1MLKEM768, SecP384r1MLKEM1024). See [Quantum-safe transport](https://docs.qblackbit.com/concepts/transport.md).
- Every route except `/v1/health`, `/v1/ready`, `/v1/openapi.json` and the OpenID Connect sign-in routes needs `Authorization: Bearer <token>`. Tokens are issued once with `POST /v1/sys/tokens` (or `aegisd token` for the first one), and the daemon keeps only their hashes.
- Each operation states the lowest **role** that may call it. Tokens can be narrowed further by scope, expiry and a client certificate. See [Dual control](https://docs.qblackbit.com/concepts/dual-control.md).
- Binary values are standard base64 with padding; bodies are limited to 1 MiB.

## Tenancy

Every holder belongs to a tenant. A key of tenant `acme` is named `<name>` by its holders and `acme/<name>` by the cross-tenant role (percent-encoded in a path: `acme%2F<name>`). Lists, records and policies are the caller's tenant's only.

## Dual control

An operation under dual control answers `202` with an approval and does nothing. Once others have approved it, send the same request again, unchanged, with `x-aegis-approval: <id>`. See [Access and approvals](https://docs.qblackbit.com/api/core/access.md) and [Dual control](https://docs.qblackbit.com/concepts/dual-control.md).

## Seal state

The daemon starts sealed. While sealed, every route that needs the vault answers `503`; `GET /v1/sys/unseal` and `POST /v1/sys/unseal` open it.

## Errors

Every error is `{"error": "<message>"}`, and the message never holds key material, passphrases or plaintext.

| Status | Meaning |
| --- | --- |
| 400 | The request is malformed, or an input is invalid |
| 401 | No token, or an unknown token; an expired token says so |
| 403 | The role is too low, or a gate refused (licence, policy, tier, health) |
| 404 | No such key, algorithm or route |
| 409 | A conflict with the current state |
| 413 | The body is larger than the limit |
| 500 | An internal failure; the daemon's log has the detail |
| 503 | The vault is sealed, or the daemon is busy (it refuses work beyond its limit instead of queueing) |

Over gRPC these map to `invalid argument`, `unauthenticated`, `permission denied`, `not found`, `failed precondition`, `resource exhausted`, `internal` and `unavailable`, with the REST status in the `aegis-http-status` metadata.
