# API overview

Aegis has two APIs. Pick the one for where your keys live.

| | Aegis Cloud API | Aegis Core API |
| --- | --- | --- |
| Base URL | `https://aegis.qblackbit.com` | Your own daemon, for example `https://aegis.internal.example:8200` |
| Routes | `/api/v1/…` for keys and operations | `/v1/…`, REST and gRPC on one listener |
| Authentication | An API key: `Authorization: Bearer agk_…` | A token: `Authorization: Bearer agt_…`; or mutual TLS; or OpenID Connect sessions |
| Roles | `developer`, `auditor` | `auditor`, `operator`, `admin`, custom roles, `emergency`, `monitor` |
| Reference | [Cloud API](https://docs.qblackbit.com/api/cloud.md) | [Core API](https://docs.qblackbit.com/api/core/index.md), service by service |
| OpenAPI document | [`/openapi/aegis-cloud-v1.json`](https://docs.qblackbit.com/openapi/aegis-cloud-v1.json) | [`/openapi/aegis-core-v1.json`](https://docs.qblackbit.com/openapi/aegis-core-v1.json), and `GET /v1/openapi.json` on every daemon |

Both references are generated from those OpenAPI documents when this site is built. The Core document comes from the Aegis Core 0.13.0 release; the cloud does not publish one yet, so qblackbit keeps the cloud's document from the service's source and checks it against the live service.

## Conventions

- **JSON in and out.** Binary values (messages, keys, signatures, ciphertexts, shared secrets) are standard base64 with padding.
- **Size.** A request body holds at most 1 MiB of data.
- **Never cached.** Every answer carries `Cache-Control: no-store`, because answers can hold key material.
- **From servers, not browsers.** Call the cloud API from servers, scripts and agents. A web page would expose the key, and the service refuses cross-site requests that change anything.
- **Names, not material.** You refer to keys by name. Private keys stay in the vault.

## Errors

Every error is JSON. The cloud adds a stable `code` meant for programs:

```json
{ "error": "this month's operations are used up; reading and exporting keys still work", "code": "quota" }
```

| HTTP | Cloud `code` | Meaning | What to do |
| --- | --- | --- | --- |
| 400 | `invalid` | A malformed request or an input the service refuses | Fix the request; the message says what |
| 401 | `unauthenticated` | No key or token, or an unknown or revoked one | Check the credential |
| 403 | `forbidden` | The role is too low, the plan does not include the algorithm, or a gate refused | Use a credential with the right role, or a plan or policy that allows it |
| 403 | `quota` | This month's operations (and any prepaid balance) are used up, or the key limit is reached | Stop; reading still works; the allowance renews at the start of the month (UTC) |
| 403 | `csrf` | A cross-site request with a session cookie | Call from a server with an API key |
| 404 | `not_found` | No such key or route (a key of another organisation answers the same) | Check the name |
| 409 | `conflict` | A key of that name exists; or, in Core, the request conflicts with the current state | Use another name, or read the state first |
| 413 | | Core: the body is larger than the limit | Send less, or sign a digest |
| 429 | `rate_limited` | Too many requests | Wait, then retry with back-off |
| 503 | `unavailable` | Briefly unavailable (in Core, also: the vault is sealed, or the daemon is busy) | Retry later; a cloud operation that failed was not counted |
| 500 | `internal` | An internal failure | Retry later; the service's log has the detail |

Aegis Core answers with `{"error": "…"}` and the same status codes, and gRPC callers get the matching gRPC status with the REST status in the `aegis-http-status` metadata.

## Limits

| | Free | Pro |
| --- | --- | --- |
| Operations a month (create, sign, verify, encapsulate, hash) | 10,000 | 1,000,000, then a prepaid balance |
| Requests a minute, per organisation | 60 | 1,200 |
| Keys | 10 | 1,000 |

The service publishes the current limits at `GET /api/config`. The edge in front of the cloud also limits each client address. Aegis Core has no plan limits; its licence can set limits on keys and tenants, and the daemon refuses work beyond a fixed number of requests in flight rather than queueing it.

## Versions

The cloud's routes carry `/api/v1`, Core's `/v1`. Aegis Core's build refuses a breaking change to its contract, so `v1` clients keep working across releases. Every daemon serves its own release's OpenAPI document at `GET /v1/openapi.json`, and reports its release at `GET /v1/sys/info`.
