{
  "openapi": "3.1.0",
  "info": {
    "title": "Aegis Cloud API",
    "version": "0.13.0",
    "description": "The API of Aegis Cloud, the hosted Free and Pro editions of Aegis by qblackbit. Programs and AI agents call it with an API key (`Authorization: Bearer agk_…`) that an organisation admin makes in the app under API keys; the key acts with its role, `developer` or `auditor`. JSON in and out; binary values are standard base64 with padding; a body carries at most 1 MiB of data. Each organisation's keys live in its own tenant of Aegis Core, under its own key-encryption key. Call the API from servers, scripts and agents, never from a web page: the key would be exposed, and cross-site requests are refused."
  },
  "servers": [
    {
      "url": "https://aegis.qblackbit.com",
      "description": "Aegis Cloud"
    }
  ],
  "security": [
    {
      "apiKey": []
    }
  ],
  "paths": {
    "/api/config": {
      "get": {
        "operationId": "Cloud.Config",
        "x-docs-title": "Public settings",
        "security": [],
        "x-docs-metered": false,
        "summary": "The service's public settings: Google sign-in, the minimum password length, where data is held, and every plan's limits.",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Config"
                },
                "example": {
                  "data_location": "Contabo GmbH data centre in the European Union",
                  "google": true,
                  "password_min_length": 12,
                  "plans": {
                    "free": {
                      "algorithms": [
                        "ml-dsa-65",
                        "x25519-ml-kem-768"
                      ],
                      "export": "wrapped",
                      "hashes": [
                        "sha2-256",
                        "sha2-384",
                        "sha2-512",
                        "sha3-256",
                        "sha3-512"
                      ],
                      "max_keys": 10,
                      "monthly_operations": 10000,
                      "rate_per_minute": 60
                    },
                    "pro": {
                      "algorithms": [
                        "ml-kem-512",
                        "ml-kem-768",
                        "ml-kem-1024",
                        "ml-dsa-44",
                        "ml-dsa-65",
                        "ml-dsa-87",
                        "slh-dsa-sha2-128s",
                        "slh-dsa-sha2-128f",
                        "slh-dsa-sha2-192s",
                        "slh-dsa-sha2-256s",
                        "slh-dsa-shake-128s",
                        "slh-dsa-shake-256s",
                        "x25519-ml-kem-768",
                        "p256-ml-kem-768",
                        "p384-ml-kem-1024"
                      ],
                      "export": "wrapped",
                      "hashes": [
                        "sha2-256",
                        "sha2-384",
                        "sha2-512",
                        "sha3-256",
                        "sha3-512"
                      ],
                      "max_keys": 1000,
                      "monthly_operations": 1000000,
                      "rate_per_minute": 1200
                    }
                  },
                  "turnstile_site_key": null
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/algorithms": {
      "get": {
        "operationId": "Cloud.Algorithms",
        "x-docs-title": "Algorithms your plan allows",
        "x-docs-auth": "API key, role `auditor` or higher",
        "x-docs-metered": false,
        "summary": "The key algorithms, hash functions and export KEMs the organisation's plan allows.",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Algorithms"
                },
                "example": {
                  "plan": "free",
                  "algorithms": [
                    "ml-dsa-65",
                    "x25519-ml-kem-768"
                  ],
                  "hashes": [
                    "sha2-256",
                    "sha2-384",
                    "sha2-512",
                    "sha3-256",
                    "sha3-512"
                  ],
                  "export_kems": [
                    "hpke-mlkem768-x25519",
                    "hpke-mlkem1024-p384"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "`unauthenticated`: no API key, or an unknown or revoked one",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "`forbidden` (the key's role is too low, or the plan does not include the algorithm), `quota` (this month's operations and any prepaid balance are used up, or the plan's key limit is reached; reading still works) or `csrf` (a cross-site request)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "`rate_limited`: the organisation's requests per minute are used up; wait and retry",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/usage": {
      "get": {
        "operationId": "Cloud.Usage",
        "x-docs-title": "Usage this month",
        "x-docs-auth": "API key, role `auditor` or higher",
        "x-docs-metered": false,
        "summary": "Operations used this calendar month (UTC), what remains of the plan's allowance, and the prepaid balance (Pro). Never blocked.",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Usage"
                },
                "example": {
                  "month": "2026-12",
                  "plan": "free",
                  "included": 10000,
                  "used": {
                    "included": 42,
                    "from_balance": 0
                  },
                  "remaining": 9958,
                  "balance": 0
                }
              }
            }
          },
          "401": {
            "description": "`unauthenticated`: no API key, or an unknown or revoked one",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "`forbidden` (the key's role is too low, or the plan does not include the algorithm), `quota` (this month's operations and any prepaid balance are used up, or the plan's key limit is reached; reading still works) or `csrf` (a cross-site request)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "`rate_limited`: the organisation's requests per minute are used up; wait and retry",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/hash": {
      "post": {
        "operationId": "Cloud.Hash",
        "x-docs-title": "Hash",
        "x-docs-auth": "API key, role `developer` or higher",
        "x-docs-metered": true,
        "summary": "A digest of the data with one of the plan's hash functions.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "algorithm",
                  "data"
                ],
                "properties": {
                  "algorithm": {
                    "type": "string",
                    "description": "A hash function the plan allows: `sha2-256`, `sha2-384`, `sha2-512`, `sha3-256` or `sha3-512`.",
                    "example": "sha3-256"
                  },
                  "data": {
                    "type": "string",
                    "contentEncoding": "base64",
                    "description": "The data, at most 1 MiB.",
                    "example": "aGVsbG8gYWVnaXM="
                  }
                }
              },
              "example": {
                "algorithm": "sha3-256",
                "data": "aGVsbG8gYWVnaXM="
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HashResult"
                }
              }
            }
          },
          "400": {
            "description": "`invalid`: a malformed request or an input the service refuses (the message says which)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "`unauthenticated`: no API key, or an unknown or revoked one",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "`forbidden` (the key's role is too low, or the plan does not include the algorithm), `quota` (this month's operations and any prepaid balance are used up, or the plan's key limit is reached; reading still works) or `csrf` (a cross-site request)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "`rate_limited`: the organisation's requests per minute are used up; wait and retry",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "`unavailable`: Aegis Core is briefly unavailable; the operation was not counted; retry",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/encapsulate": {
      "post": {
        "operationId": "Cloud.Encapsulate",
        "x-docs-title": "Encapsulate",
        "x-docs-auth": "API key, role `developer` or higher",
        "x-docs-metered": true,
        "summary": "Encapsulates to a public key: a fresh shared secret, and the ciphertext that carries it to the holder of the matching private key.",
        "description": "The private key's holder recovers the same shared secret by decapsulating the ciphertext. The cloud API does not decapsulate: decapsulation happens where the private key is held. `x25519-ml-kem-768`, `p256-ml-kem-768` and `p384-ml-kem-1024` are the TLS 1.3 hybrid groups, which rely on the TLS handshake transcript; outside TLS, prefer `ml-kem-768` or `ml-kem-1024` (Pro), or bind the ciphertext and the recipient's public key into your key derivation (see Post-quantum and hybrids).",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "algorithm",
                  "public_key"
                ],
                "properties": {
                  "algorithm": {
                    "type": "string",
                    "description": "A KEM the plan allows, such as `x25519-ml-kem-768` (Free and Pro) or `ml-kem-768` (Pro).",
                    "example": "x25519-ml-kem-768"
                  },
                  "public_key": {
                    "type": "string",
                    "contentEncoding": "base64",
                    "description": "The recipient's public key, for example from `GET /api/v1/keys/{name}/public`.",
                    "example": "<base64 public key>"
                  }
                }
              },
              "example": {
                "algorithm": "x25519-ml-kem-768",
                "public_key": "<base64 public key>"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Encapsulation"
                }
              }
            }
          },
          "400": {
            "description": "`invalid`: a malformed request or an input the service refuses (the message says which)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "`unauthenticated`: no API key, or an unknown or revoked one",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "`forbidden` (the key's role is too low, or the plan does not include the algorithm), `quota` (this month's operations and any prepaid balance are used up, or the plan's key limit is reached; reading still works) or `csrf` (a cross-site request)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "`rate_limited`: the organisation's requests per minute are used up; wait and retry",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "`unavailable`: Aegis Core is briefly unavailable; the operation was not counted; retry",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/keys": {
      "get": {
        "operationId": "Cloud.ListKeys",
        "x-docs-title": "List keys",
        "x-docs-auth": "API key, role `auditor` or higher",
        "x-docs-metered": false,
        "summary": "The organisation's keys, without secrets.",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/KeyList"
                },
                "example": {
                  "keys": [
                    {
                      "name": "release-signing",
                      "algorithm": "ml-dsa-65",
                      "created": 1764806400,
                      "by": "<account id>"
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "`unauthenticated`: no API key, or an unknown or revoked one",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "`forbidden` (the key's role is too low, or the plan does not include the algorithm), `quota` (this month's operations and any prepaid balance are used up, or the plan's key limit is reached; reading still works) or `csrf` (a cross-site request)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "`rate_limited`: the organisation's requests per minute are used up; wait and retry",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "Cloud.CreateKey",
        "x-docs-title": "Create a key",
        "x-docs-auth": "API key, role `developer` or higher",
        "x-docs-metered": true,
        "summary": "Makes a key pair in the organisation's tenant of Aegis Core. The private key stays in the vault.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "name",
                  "algorithm"
                ],
                "properties": {
                  "name": {
                    "type": "string",
                    "description": "1 to 64 letters, digits, `-` or `_`, starting with a letter or digit; unique in the organisation.",
                    "example": "release-signing"
                  },
                  "algorithm": {
                    "type": "string",
                    "description": "An algorithm the plan allows: `ml-dsa-65` or `x25519-ml-kem-768` on Free; on Pro, every set `GET /api/v1/algorithms` lists.",
                    "example": "ml-dsa-65"
                  }
                }
              },
              "example": {
                "name": "release-signing",
                "algorithm": "ml-dsa-65"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreatedKey"
                },
                "example": {
                  "name": "release-signing",
                  "algorithm": "ml-dsa-65",
                  "version": 1
                }
              }
            }
          },
          "400": {
            "description": "`invalid`: a malformed request or an input the service refuses (the message says which)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "`unauthenticated`: no API key, or an unknown or revoked one",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "`forbidden` (the key's role is too low, or the plan does not include the algorithm), `quota` (this month's operations and any prepaid balance are used up, or the plan's key limit is reached; reading still works) or `csrf` (a cross-site request)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "`conflict`: a key of that name exists",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "`rate_limited`: the organisation's requests per minute are used up; wait and retry",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "`unavailable`: Aegis Core is briefly unavailable; the operation was not counted; retry",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/keys/{name}": {
      "get": {
        "operationId": "Cloud.GetKey",
        "x-docs-title": "Get a key",
        "x-docs-auth": "API key, role `auditor` or higher",
        "x-docs-metered": false,
        "parameters": [
          {
            "in": "path",
            "name": "name",
            "required": true,
            "example": "release-signing",
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$"
            },
            "description": "The key's name: 1 to 64 letters, digits, `-` or `_`, starting with a letter or digit."
          }
        ],
        "summary": "One key: its algorithm, when it was made, its state and its current version.",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/KeyDetail"
                },
                "example": {
                  "name": "release-signing",
                  "algorithm": "ml-dsa-65",
                  "created": 1764806400,
                  "state": "active",
                  "version": 1
                }
              }
            }
          },
          "401": {
            "description": "`unauthenticated`: no API key, or an unknown or revoked one",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "`forbidden` (the key's role is too low, or the plan does not include the algorithm), `quota` (this month's operations and any prepaid balance are used up, or the plan's key limit is reached; reading still works) or `csrf` (a cross-site request)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "`not_found`: no such key in this organisation (a key of another organisation answers the same)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "`rate_limited`: the organisation's requests per minute are used up; wait and retry",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "`unavailable`: Aegis Core is briefly unavailable; the operation was not counted; retry",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/keys/{name}/public": {
      "get": {
        "operationId": "Cloud.PublicKey",
        "x-docs-title": "Get a public key",
        "x-docs-auth": "API key, role `auditor` or higher",
        "x-docs-metered": false,
        "parameters": [
          {
            "in": "path",
            "name": "name",
            "required": true,
            "example": "release-signing",
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$"
            },
            "description": "The key's name: 1 to 64 letters, digits, `-` or `_`, starting with a letter or digit."
          }
        ],
        "summary": "The current version's public key.",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublicKey"
                }
              }
            }
          },
          "401": {
            "description": "`unauthenticated`: no API key, or an unknown or revoked one",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "`forbidden` (the key's role is too low, or the plan does not include the algorithm), `quota` (this month's operations and any prepaid balance are used up, or the plan's key limit is reached; reading still works) or `csrf` (a cross-site request)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "`not_found`: no such key in this organisation (a key of another organisation answers the same)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "`rate_limited`: the organisation's requests per minute are used up; wait and retry",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "`unavailable`: Aegis Core is briefly unavailable; the operation was not counted; retry",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/keys/{name}/sign": {
      "post": {
        "operationId": "Cloud.Sign",
        "x-docs-title": "Sign",
        "x-docs-auth": "API key, role `developer` or higher",
        "x-docs-metered": true,
        "parameters": [
          {
            "in": "path",
            "name": "name",
            "required": true,
            "example": "release-signing",
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$"
            },
            "description": "The key's name: 1 to 64 letters, digits, `-` or `_`, starting with a letter or digit."
          }
        ],
        "summary": "Signs the message with the key's current version (pure, hedged, no context string). The signature is verified before it is returned.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "message"
                ],
                "properties": {
                  "message": {
                    "type": "string",
                    "contentEncoding": "base64",
                    "description": "The message, at most 1 MiB.",
                    "example": "aGVsbG8gYWVnaXM="
                  }
                }
              },
              "example": {
                "message": "aGVsbG8gYWVnaXM="
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Signature"
                }
              }
            }
          },
          "400": {
            "description": "`invalid`: a malformed request or an input the service refuses (the message says which)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "`unauthenticated`: no API key, or an unknown or revoked one",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "`forbidden` (the key's role is too low, or the plan does not include the algorithm), `quota` (this month's operations and any prepaid balance are used up, or the plan's key limit is reached; reading still works) or `csrf` (a cross-site request)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "`not_found`: no such key in this organisation (a key of another organisation answers the same)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "`rate_limited`: the organisation's requests per minute are used up; wait and retry",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "`unavailable`: Aegis Core is briefly unavailable; the operation was not counted; retry",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/keys/{name}/verify": {
      "post": {
        "operationId": "Cloud.Verify",
        "x-docs-title": "Verify",
        "x-docs-auth": "API key, role `developer` or higher",
        "x-docs-metered": true,
        "parameters": [
          {
            "in": "path",
            "name": "name",
            "required": true,
            "example": "release-signing",
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$"
            },
            "description": "The key's name: 1 to 64 letters, digits, `-` or `_`, starting with a letter or digit."
          }
        ],
        "summary": "Checks a signature over the message with one of the key's versions.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "message",
                  "signature"
                ],
                "properties": {
                  "message": {
                    "type": "string",
                    "contentEncoding": "base64",
                    "description": "The message that was signed, at most 1 MiB.",
                    "example": "aGVsbG8gYWVnaXM="
                  },
                  "signature": {
                    "type": "string",
                    "contentEncoding": "base64",
                    "description": "The signature, as `sign` returned it.",
                    "example": "<base64 signature>"
                  },
                  "version": {
                    "type": "integer",
                    "minimum": 1,
                    "default": 1,
                    "example": 1,
                    "description": "The key version that signed (`sign` returns it). Defaults to 1."
                  }
                }
              },
              "example": {
                "message": "aGVsbG8gYWVnaXM=",
                "signature": "<base64 signature>",
                "version": 1
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Verification"
                }
              }
            }
          },
          "400": {
            "description": "`invalid`: a malformed request or an input the service refuses (the message says which)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "`unauthenticated`: no API key, or an unknown or revoked one",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "`forbidden` (the key's role is too low, or the plan does not include the algorithm), `quota` (this month's operations and any prepaid balance are used up, or the plan's key limit is reached; reading still works) or `csrf` (a cross-site request)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "`not_found`: no such key in this organisation (a key of another organisation answers the same)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "`rate_limited`: the organisation's requests per minute are used up; wait and retry",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "`unavailable`: Aegis Core is briefly unavailable; the operation was not counted; retry",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/keys/{name}/export": {
      "post": {
        "operationId": "Cloud.Export",
        "x-docs-title": "Export a key, wrapped",
        "x-docs-metered": false,
        "parameters": [
          {
            "in": "path",
            "name": "name",
            "required": true,
            "example": "release-signing",
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$"
            },
            "description": "The key's name: 1 to 64 letters, digits, `-` or `_`, starting with a letter or digit."
          }
        ],
        "x-docs-auth": "a signed-in session of an organisation `admin` or `owner`, from the app; API keys are refused",
        "x-docs-status": "The route exists, but exporting a key made by the cloud does not complete in the current release (Aegis Core 0.13.0).",
        "summary": "Exports the key wrapped with HPKE to your own hybrid post-quantum public key, so only you can open it. Never metered and never blocked by the quota.",
        "description": "Only hybrid KEMs are accepted for the wrapping key, so an export is never weaker than the key it carries.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "kem",
                  "public_key"
                ],
                "properties": {
                  "kem": {
                    "type": "string",
                    "description": "The HPKE KEM of your public key.",
                    "enum": [
                      "hpke-mlkem768-x25519",
                      "hpke-mlkem1024-p384"
                    ],
                    "example": "hpke-mlkem768-x25519"
                  },
                  "public_key": {
                    "type": "string",
                    "contentEncoding": "base64",
                    "description": "Your public key for that KEM.",
                    "example": "<base64 public key>"
                  }
                }
              },
              "example": {
                "kem": "hpke-mlkem768-x25519",
                "public_key": "<base64 public key>"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WrappedExport"
                }
              }
            }
          },
          "400": {
            "description": "`invalid`: a malformed request or an input the service refuses (the message says which)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "`unauthenticated`: no API key, or an unknown or revoked one",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "`forbidden` (the key's role is too low, or the plan does not include the algorithm), `quota` (this month's operations and any prepaid balance are used up, or the plan's key limit is reached; reading still works) or `csrf` (a cross-site request)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "`not_found`: no such key in this organisation (a key of another organisation answers the same)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "`unavailable`: Aegis Core is briefly unavailable; the operation was not counted; retry",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "apiKey": {
        "type": "http",
        "scheme": "bearer",
        "description": "An API key (`agk_…`), shown once when an organisation admin makes it in the app (API keys). Its role is `developer` (use keys and run metered operations) or `auditor` (read only), never above the role of the member who made it. Revoke it in the app at any time."
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "required": [
          "error",
          "code"
        ],
        "description": "Every error. `error` is for a person; `code` is stable and meant for programs.",
        "properties": {
          "error": {
            "type": "string",
            "description": "What went wrong, in words. It never holds key material."
          },
          "code": {
            "type": "string",
            "description": "One of `invalid`, `unauthenticated`, `forbidden`, `quota`, `csrf`, `not_found`, `conflict`, `rate_limited`, `unavailable`, `internal`."
          }
        }
      },
      "Config": {
        "type": "object",
        "description": "The service's public settings.",
        "properties": {
          "data_location": {
            "type": "string",
            "description": "Where customer data is held."
          },
          "google": {
            "type": "boolean",
            "description": "Whether Google sign-in is on."
          },
          "password_min_length": {
            "type": "integer",
            "format": "int64",
            "minimum": 0,
            "description": "The shortest password accepted."
          },
          "plans": {
            "type": "object",
            "description": "Every plan's limits.",
            "properties": {
              "free": {
                "$ref": "#/components/schemas/PlanLimits"
              },
              "pro": {
                "$ref": "#/components/schemas/PlanLimits"
              }
            }
          },
          "turnstile_site_key": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "description": "The bot-check site key, when the public forms ask for one."
          }
        }
      },
      "PlanLimits": {
        "type": "object",
        "additionalProperties": false,
        "description": "What a plan allows.",
        "properties": {
          "monthly_operations": {
            "type": "integer",
            "format": "int64",
            "minimum": 0,
            "description": "Metered operations included each calendar month (UTC)."
          },
          "algorithms": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Algorithms keys may be made with."
          },
          "hashes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Hash functions `hash` accepts."
          },
          "rate_per_minute": {
            "type": "integer",
            "format": "int64",
            "minimum": 0,
            "description": "Requests per minute for the organisation."
          },
          "max_keys": {
            "type": "integer",
            "format": "int64",
            "minimum": 0,
            "description": "Keys the organisation may hold."
          },
          "export": {
            "type": "string",
            "description": "How keys may leave the cloud: `wrapped` (to your own hybrid public key) or `none`.",
            "enum": [
              "wrapped",
              "none"
            ]
          }
        }
      },
      "Algorithms": {
        "type": "object",
        "description": "What the plan allows.",
        "properties": {
          "plan": {
            "type": "string",
            "description": "`free`, `pro` or `enterprise`."
          },
          "algorithms": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Key algorithms."
          },
          "hashes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Hash functions."
          },
          "export_kems": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The hybrid KEMs a key may be exported to."
          }
        }
      },
      "Usage": {
        "type": "object",
        "description": "This month's usage.",
        "properties": {
          "month": {
            "type": "string",
            "description": "The calendar month (UTC), `YYYY-MM`."
          },
          "plan": {
            "type": "string",
            "description": "The plan."
          },
          "included": {
            "type": "integer",
            "format": "int64",
            "minimum": 0,
            "description": "Operations the plan includes this month."
          },
          "used": {
            "type": "object",
            "description": "Operations used.",
            "properties": {
              "included": {
                "type": "integer",
                "format": "int64",
                "minimum": 0,
                "description": "Within the monthly allowance."
              },
              "from_balance": {
                "type": "integer",
                "format": "int64",
                "minimum": 0,
                "description": "Drawn from the prepaid balance (Pro)."
              }
            }
          },
          "remaining": {
            "type": "integer",
            "format": "int64",
            "minimum": 0,
            "description": "What remains of the allowance."
          },
          "balance": {
            "type": "integer",
            "format": "int64",
            "minimum": 0,
            "description": "The prepaid balance, in operations (Pro)."
          }
        }
      },
      "HashResult": {
        "type": "object",
        "description": "A digest (passed through from Aegis Core).",
        "properties": {
          "algorithm": {
            "type": "string",
            "description": "The hash function."
          },
          "digest": {
            "type": "string",
            "contentEncoding": "base64",
            "description": "The digest."
          },
          "caution": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "description": "A caution Aegis adds for a retired or broken algorithm; absent for the algorithms the cloud offers."
          }
        }
      },
      "Encapsulation": {
        "type": "object",
        "description": "An encapsulation (passed through from Aegis Core).",
        "properties": {
          "algorithm": {
            "type": "string",
            "description": "The KEM."
          },
          "ciphertext": {
            "type": "string",
            "contentEncoding": "base64",
            "description": "The ciphertext to send to the private key's holder."
          },
          "shared_secret": {
            "type": "string",
            "contentEncoding": "base64",
            "description": "The shared secret. Treat it as a key: never log it."
          },
          "caution": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "description": "A caution Aegis adds for a retired or broken algorithm; absent for the algorithms the cloud offers."
          }
        }
      },
      "KeyEntry": {
        "type": "object",
        "description": "A key as the organisation's index lists it.",
        "properties": {
          "name": {
            "type": "string",
            "description": "The name."
          },
          "algorithm": {
            "type": "string",
            "description": "The algorithm."
          },
          "created": {
            "type": "integer",
            "format": "int64",
            "minimum": 0,
            "description": "When it was made, in seconds since the Unix epoch."
          },
          "by": {
            "type": "string",
            "description": "The account that made it."
          }
        }
      },
      "KeyList": {
        "type": "object",
        "description": "The organisation's keys.",
        "properties": {
          "keys": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/KeyEntry"
            },
            "description": "Every key."
          }
        }
      },
      "CreatedKey": {
        "type": "object",
        "description": "A new key.",
        "properties": {
          "name": {
            "type": "string",
            "description": "The name."
          },
          "algorithm": {
            "type": "string",
            "description": "The algorithm."
          },
          "version": {
            "type": "integer",
            "format": "int64",
            "minimum": 0,
            "description": "The current version: 1 for a new key."
          }
        }
      },
      "KeyDetail": {
        "type": "object",
        "description": "One key.",
        "properties": {
          "name": {
            "type": "string",
            "description": "The name."
          },
          "algorithm": {
            "type": "string",
            "description": "The algorithm."
          },
          "created": {
            "type": "integer",
            "format": "int64",
            "minimum": 0,
            "description": "When it was made, in seconds since the Unix epoch."
          },
          "state": {
            "type": "string",
            "description": "The key's state in Aegis Core, such as `active`."
          },
          "version": {
            "type": "integer",
            "format": "int64",
            "minimum": 0,
            "description": "The current version."
          }
        }
      },
      "PublicKey": {
        "type": "object",
        "description": "A public key (passed through from Aegis Core).",
        "properties": {
          "version": {
            "type": "integer",
            "format": "int64",
            "minimum": 0,
            "description": "The current version."
          },
          "public_key": {
            "type": "string",
            "contentEncoding": "base64",
            "description": "The public key: its raw bytes, in base64."
          }
        }
      },
      "Signature": {
        "type": "object",
        "description": "A signature (passed through from Aegis Core).",
        "properties": {
          "algorithm": {
            "type": "string",
            "description": "The algorithm."
          },
          "version": {
            "type": "integer",
            "format": "int64",
            "minimum": 0,
            "description": "The version that signed; send it to `verify`."
          },
          "signature": {
            "anyOf": [
              {
                "type": "string",
                "contentEncoding": "base64"
              },
              {
                "type": "null"
              }
            ],
            "description": "The signature."
          },
          "envelope": {
            "anyOf": [
              {
                "type": "string",
                "contentEncoding": "base64"
              },
              {
                "type": "null"
              }
            ],
            "description": "Not used by the cloud API (always absent)."
          },
          "caution": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "description": "A caution Aegis adds for a retired or broken algorithm; absent for the algorithms the cloud offers."
          }
        }
      },
      "Verification": {
        "type": "object",
        "description": "Whether the signature verifies (passed through from Aegis Core).",
        "properties": {
          "valid": {
            "type": "boolean",
            "description": "`true` when the signature is valid for this message and key version."
          },
          "caution": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "description": "A caution Aegis adds for a retired or broken algorithm; absent for the algorithms the cloud offers."
          }
        }
      },
      "WrappedExport": {
        "type": "object",
        "description": "The key wrapped to your public key with HPKE (RFC 9180), passed through from Aegis Core. Open it with your private key and the `info` given.",
        "properties": {
          "kem": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "description": "The HPKE KEM."
          },
          "kdf": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "description": "The HPKE KDF."
          },
          "aead": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "description": "The HPKE AEAD."
          },
          "enc": {
            "anyOf": [
              {
                "type": "string",
                "contentEncoding": "base64"
              },
              {
                "type": "null"
              }
            ],
            "description": "The encapsulated key."
          },
          "ciphertext": {
            "anyOf": [
              {
                "type": "string",
                "contentEncoding": "base64"
              },
              {
                "type": "null"
              }
            ],
            "description": "The wrapped key material."
          },
          "info": {
            "anyOf": [
              {
                "type": "string",
                "contentEncoding": "base64"
              },
              {
                "type": "null"
              }
            ],
            "description": "The HPKE info, which binds the key's terms."
          },
          "algorithm": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "description": "The key's algorithm."
          },
          "version": {
            "anyOf": [
              {
                "type": "integer",
                "format": "int64",
                "minimum": 0
              },
              {
                "type": "null"
              }
            ],
            "description": "The version wrapped."
          },
          "export": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "description": "The key's export policy."
          },
          "state": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "description": "The key's state."
          },
          "usages": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The key's usages."
          },
          "caution": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "description": "A caution Aegis adds for a retired or broken algorithm; absent for the algorithms the cloud offers."
          }
        }
      }
    }
  }
}
