# Quickstart: Aegis Cloud

From sign-up to a verified post-quantum signature in a few minutes, with nothing to install beyond `curl`. Everything on this page works on the Free plan.

## 1. Sign up

Open [aegis.qblackbit.com](https://aegis.qblackbit.com/sign-up) and sign up with Google, or with an email address and a password of at least 12 characters. An email sign-up is confirmed by a link sent to that address; Google is the quickest path. Your first organisation is made for you, on the Free plan.

Then turn on the authenticator app in **Settings**. The account that makes API keys deserves a second factor.

> **The Free plan:**
>
> 10,000 metered operations a month, 60 requests a minute and up to 10 keys, with `ml-dsa-65` for signatures, `x25519-ml-kem-768` for key encapsulation, and the hashes `sha2-256`, `sha2-384`, `sha2-512`, `sha3-256` and `sha3-512`. Creating a key, signing, verifying, encapsulating and hashing are metered; reading keys and usage are never counted or blocked. The service publishes every plan's limits at [`GET /api/config`](https://docs.qblackbit.com/api/cloud.md#cloud-config).

## 2. Make an API key

In the app, open **API keys**, give the key a label (for example `quickstart`), choose the role **developer** and create it. The key starts with `agk_` and is shown once.

Put it in your shell's environment, never in a file you commit:

```bash
export AEGIS_URL=https://aegis.qblackbit.com
read -rs AEGIS_API_KEY && export AEGIS_API_KEY   # paste the key, press Enter
```

A key acts for the member who made it, never above that member's role, and stops working if the member leaves the organisation. `developer` keys create keys and run operations; `auditor` keys only read. Keys do not expire on their own: revoke this one under **API keys** when you are done. Expiring keys are (Planned).

Check that it works:

```bash
curl -sS "$AEGIS_URL/api/v1/algorithms" -H "Authorization: Bearer $AEGIS_API_KEY"
```

```json
{"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"]}
```

## 3. Make a signing key

```bash
curl -sS -X POST "$AEGIS_URL/api/v1/keys" \
  -H "Authorization: Bearer $AEGIS_API_KEY" -H "Content-Type: application/json" \
  -d '{"name": "quickstart-signing", "algorithm": "ml-dsa-65"}'
```

The answer is `201` with `{"name":"quickstart-signing","algorithm":"ml-dsa-65","version":1}`. The key pair lives in your organisation's tenant of Aegis Core, under your organisation's own key-encryption key. The private key stays there: you send messages to sign and receive signatures.

## 4. Sign and verify

Messages and signatures travel as standard base64. This script signs a message, verifies it, then verifies a changed message, which must fail:

curl and jq:

```bash
#!/usr/bin/env bash
# Sign and verify with an ML-DSA-65 key in Aegis Cloud, with curl and jq.
# Set AEGIS_URL (https://aegis.qblackbit.com) and AEGIS_API_KEY (a developer key) in the environment first.
set -euo pipefail
: "${AEGIS_URL:=https://aegis.qblackbit.com}"
: "${AEGIS_API_KEY:?set AEGIS_API_KEY to a developer key; never paste it into a file you commit}"
NAME=${AEGIS_KEY_NAME:-quickstart-signing}

aegis() { # aegis METHOD PATH [JSON]: one call; prints the body, fails on an HTTP error
  curl -sS --fail-with-body -X "$1" "$AEGIS_URL$2" \
    -H "Authorization: Bearer $AEGIS_API_KEY" -H "Content-Type: application/json" ${3:+-d "$3"}
}

aegis GET /api/v1/algorithms | jq -c '{plan, algorithms}'

# Make the key once; a second run answers 409 "a key of that name exists", which is fine.
aegis POST /api/v1/keys "{\"name\": \"$NAME\", \"algorithm\": \"ml-dsa-65\"}" || true
echo

MESSAGE=$(printf '%s' 'hello from my first post-quantum signature' | base64 | tr -d '\n')
SIGNED=$(aegis POST "/api/v1/keys/$NAME/sign" "{\"message\": \"$MESSAGE\"}")
SIGNATURE=$(jq -r .signature <<<"$SIGNED")
VERSION=$(jq -r .version <<<"$SIGNED")
echo "signature: $(printf '%s' "$SIGNATURE" | base64 -d | wc -c | tr -d ' ') bytes, key version $VERSION"

TAMPERED=$(printf '%s' 'hello from my first post-quantum signature!' | base64 | tr -d '\n')
for CHECK in "original $MESSAGE" "tampered $TAMPERED"; do
  set -- $CHECK
  VALID=$(aegis POST "/api/v1/keys/$NAME/verify" \
    "{\"message\": \"$2\", \"signature\": \"$SIGNATURE\", \"version\": $VERSION}" | jq -r .valid)
  echo "$1: valid = $VALID"
done

aegis GET /api/v1/usage | jq -r '"operations this month: \(.used.included) of \(.included)"'
```

Python:

```python
#!/usr/bin/env python3
"""Sign and verify with an ML-DSA-65 key in Aegis Cloud, with Python's standard library only.

Set AEGIS_URL (https://aegis.qblackbit.com) and AEGIS_API_KEY (a developer key) in the environment first.
"""
import base64
import json
import os
import sys
import urllib.error
import urllib.request

BASE = os.environ.get("AEGIS_URL", "https://aegis.qblackbit.com").rstrip("/")
API_KEY = os.environ.get("AEGIS_API_KEY") or sys.exit("set AEGIS_API_KEY to a developer key")
NAME = os.environ.get("AEGIS_KEY_NAME", "quickstart-signing")

def call(method, path, body=None):
    """One call to the cloud API: returns (HTTP status, decoded JSON)."""
    data = json.dumps(body).encode() if body is not None else None
    request = urllib.request.Request(BASE + path, data=data, method=method)
    request.add_header("Authorization", "Bearer " + API_KEY)
    if data is not None:
        request.add_header("Content-Type", "application/json")
    try:
        with urllib.request.urlopen(request, timeout=30) as response:
            return response.status, json.load(response)
    except urllib.error.HTTPError as error:
        return error.code, json.load(error)

def must(status, answer, *expected):
    if status not in expected:
        sys.exit(f"{status} {answer.get('code')}: {answer.get('error')}")
    return answer

def b64(raw):
    return base64.b64encode(raw).decode()

plan = must(*call("GET", "/api/v1/algorithms"), 200)
print("plan:", plan["plan"], "| algorithms:", ", ".join(plan["algorithms"]))

status, made = call("POST", "/api/v1/keys", {"name": NAME, "algorithm": "ml-dsa-65"})
print("key:", NAME, "made" if status == 201 else "already exists" if status == 409 else must(status, made))

message = b"hello from my first post-quantum signature"
signed = must(*call("POST", f"/api/v1/keys/{NAME}/sign", {"message": b64(message)}), 200)
print("signature:", len(base64.b64decode(signed["signature"])), "bytes, key version", signed["version"])

for label, candidate in (("original", message), ("tampered", message + b"!")):
    body = {"message": b64(candidate), "signature": signed["signature"], "version": signed["version"]}
    checked = must(*call("POST", f"/api/v1/keys/{NAME}/verify", body), 200)
    print(f"{label}: valid = {checked['valid']}")

usage = must(*call("GET", "/api/v1/usage"), 200)
print("operations this month:", usage["used"]["included"], "of", usage["included"])
```

Node.js:

```js
// Sign and verify with an ML-DSA-65 key in Aegis Cloud, with Node's built-in fetch (Node 18 or later).
// Set AEGIS_URL (https://aegis.qblackbit.com) and AEGIS_API_KEY (a developer key) in the environment first.
const base = (process.env.AEGIS_URL ?? 'https://aegis.qblackbit.com').replace(/\/$/, '')
const apiKey = process.env.AEGIS_API_KEY
const name = process.env.AEGIS_KEY_NAME ?? 'quickstart-signing'
if (!apiKey) throw new Error('set AEGIS_API_KEY to a developer key')

/** One call to the cloud API; throws on an unexpected status with the API's error code. */
async function call(method, path, body, ...expected) {
  const response = await fetch(base + path, {
    method,
    headers: { authorization: `Bearer ${apiKey}`, ...(body ? { 'content-type': 'application/json' } : {}) },
    body: body ? JSON.stringify(body) : undefined
  })
  const answer = await response.json()
  if (!(expected.length ? expected : [200]).includes(response.status)) {
    throw new Error(`${response.status} ${answer.code}: ${answer.error}`)
  }
  return { status: response.status, answer }
}
const b64 = (text) => Buffer.from(text).toString('base64')

const plan = (await call('GET', '/api/v1/algorithms')).answer
console.log(`plan: ${plan.plan} | algorithms: ${plan.algorithms.join(', ')}`)

const made = await call('POST', '/api/v1/keys', { name, algorithm: 'ml-dsa-65' }, 201, 409)
console.log(`key: ${name} ${made.status === 201 ? 'made' : 'already exists'}`)

const message = 'hello from my first post-quantum signature'
const signed = (await call('POST', `/api/v1/keys/${name}/sign`, { message: b64(message) })).answer
console.log(`signature: ${Buffer.from(signed.signature, 'base64').length} bytes, key version ${signed.version}`)

for (const [label, candidate] of [['original', message], ['tampered', message + '!']]) {
  const body = { message: b64(candidate), signature: signed.signature, version: signed.version }
  const checked = (await call('POST', `/api/v1/keys/${name}/verify`, body)).answer
  console.log(`${label}: valid = ${checked.valid}`)
}

const usage = (await call('GET', '/api/v1/usage')).answer
console.log(`operations this month: ${usage.used.included} of ${usage.included}`)
```

Go:

```go
// Sign and verify with an ML-DSA-65 key in Aegis Cloud, with Go's standard library only.
// Set AEGIS_URL (https://aegis.qblackbit.com) and AEGIS_API_KEY (a developer key) in the environment first.
//
//	go run quickstart.go
package main

import (
	"bytes"
	"encoding/base64"
	"encoding/json"
	"fmt"
	"log"
	"net/http"
	"os"
	"strings"
	"time"
)

var (
	base   = strings.TrimRight(envOr("AEGIS_URL", "https://aegis.qblackbit.com"), "/")
	apiKey = os.Getenv("AEGIS_API_KEY")
	name   = envOr("AEGIS_KEY_NAME", "quickstart-signing")
	client = &http.Client{Timeout: 30 * time.Second}
)

func envOr(key, fallback string) string {
	if value := os.Getenv(key); value != "" {
		return value
	}
	return fallback
}

// call makes one request and decodes the JSON answer into out; it returns the HTTP status.
func call(method, path string, body any, out any) int {
	var reader *bytes.Reader
	if body != nil {
		encoded, err := json.Marshal(body)
		if err != nil {
			log.Fatal(err)
		}
		reader = bytes.NewReader(encoded)
	} else {
		reader = bytes.NewReader(nil)
	}
	request, err := http.NewRequest(method, base+path, reader)
	if err != nil {
		log.Fatal(err)
	}
	request.Header.Set("Authorization", "Bearer "+apiKey)
	if body != nil {
		request.Header.Set("Content-Type", "application/json")
	}
	response, err := client.Do(request)
	if err != nil {
		log.Fatal(err)
	}
	defer response.Body.Close()
	if err := json.NewDecoder(response.Body).Decode(out); err != nil {
		log.Fatal(err)
	}
	return response.StatusCode
}

type apiError struct {
	Error string `json:"error"`
	Code  string `json:"code"`
}

func main() {
	if apiKey == "" {
		log.Fatal("set AEGIS_API_KEY to a developer key")
	}
	var plan struct {
		Plan       string   `json:"plan"`
		Algorithms []string `json:"algorithms"`
	}
	if status := call("GET", "/api/v1/algorithms", nil, &plan); status != 200 {
		log.Fatalf("algorithms: HTTP %d", status)
	}
	fmt.Printf("plan: %s | algorithms: %s\n", plan.Plan, strings.Join(plan.Algorithms, ", "))

	var made apiError
	switch status := call("POST", "/api/v1/keys", map[string]string{"name": name, "algorithm": "ml-dsa-65"}, &made); status {
	case 201:
		fmt.Println("key:", name, "made")
	case 409:
		fmt.Println("key:", name, "already exists")
	default:
		log.Fatalf("create: %d %s: %s", status, made.Code, made.Error)
	}

	message := []byte("hello from my first post-quantum signature")
	var signed struct {
		Signature string `json:"signature"`
		Version   int    `json:"version"`
	}
	if status := call("POST", "/api/v1/keys/"+name+"/sign", map[string]string{"message": base64.StdEncoding.EncodeToString(message)}, &signed); status != 200 {
		log.Fatalf("sign: HTTP %d", status)
	}
	raw, _ := base64.StdEncoding.DecodeString(signed.Signature)
	fmt.Printf("signature: %d bytes, key version %d\n", len(raw), signed.Version)

	for _, check := range []struct {
		label   string
		message []byte
	}{{"original", message}, {"tampered", append(append([]byte{}, message...), '!')}} {
		var checked struct {
			Valid bool `json:"valid"`
		}
		body := map[string]any{"message": base64.StdEncoding.EncodeToString(check.message), "signature": signed.Signature, "version": signed.Version}
		if status := call("POST", "/api/v1/keys/"+name+"/verify", body, &checked); status != 200 {
			log.Fatalf("verify: HTTP %d", status)
		}
		fmt.Printf("%s: valid = %t\n", check.label, checked.Valid)
	}

	var usage struct {
		Included int `json:"included"`
		Used     struct {
			Included int `json:"included"`
		} `json:"used"`
	}
	call("GET", "/api/v1/usage", nil, &usage)
	fmt.Printf("operations this month: %d of %d\n", usage.Used.Included, usage.Included)
}
```

The output ends like this:

```text
signature: 3309 bytes, key version 1
original: valid = true
tampered: valid = false
operations this month: 4 of 10000
```

An ML-DSA-65 signature is 3,309 bytes and its public key 1,952 bytes (FIPS 204). Fetch the public key with `GET /api/v1/keys/quickstart-signing/public` to give it to whoever verifies your signatures elsewhere. The service checks every signature it makes before it answers. The examples are tested against a stand-in for the API on every change to these docs.

## 5. Encapsulate to a public key

Key encapsulation gives you a fresh shared secret and a ciphertext that carries it to the holder of a private key. The holder recovers the same secret by decapsulating:

```bash
curl -sS -X POST "$AEGIS_URL/api/v1/encapsulate" \
  -H "Authorization: Bearer $AEGIS_API_KEY" -H "Content-Type: application/json" \
  -d "{\"algorithm\": \"x25519-ml-kem-768\", \"public_key\": \"$RECIPIENT_PUBLIC_KEY\"}"
```

The answer holds `ciphertext` (send it) and `shared_secret` (treat it as a key: never log it). `RECIPIENT_PUBLIC_KEY` is the recipient's public key in base64, for the same algorithm.

> **Decapsulation is not in the cloud API:**
>
> The cloud API encapsulates but does not decapsulate, and exporting a key made in the cloud is not available yet. So the recipient should make the KEM key pair where they will decapsulate, for example in [Aegis Core](https://docs.qblackbit.com/quickstart/core.md) (`POST /v1/keys/{name}/decapsulate`), and give you only the public key.

> **Which KEM to choose:**
>
> `x25519-ml-kem-768` (Free and Pro) is the hybrid group of TLS 1.3. In TLS the handshake transcript binds it; outside TLS, derive your key with HKDF over the shared secret with the ciphertext and the recipient's public key in the `info`, as HPKE does. On Pro, `ml-kem-768` and `ml-kem-1024` (FIPS 203) are complete KEMs on their own. More in [Post-quantum and hybrids](https://docs.qblackbit.com/concepts/post-quantum.md#kems-are-not-encryption).

## 6. Watch your usage

```bash
curl -sS "$AEGIS_URL/api/v1/usage" -H "Authorization: Bearer $AEGIS_API_KEY"
```

```json
{"month":"2026-12","plan":"free","included":10000,"used":{"included":4,"from_balance":0},"remaining":9996,"balance":0}
```

When the month's operations are used up, metered calls answer `403` with the code `quota`; reading keys and usage keep working, and the allowance renews at the start of the next calendar month (UTC). On Pro, operations beyond the allowance are drawn from a prepaid balance.

## Errors

Every error is JSON with a person's message and a stable code: `{"error": "…", "code": "…"}`. Handle `rate_limited` (wait and retry), `quota` (stop and tell someone), `unavailable` (retry later; the operation was not counted), `invalid`, `not_found` and `forbidden`. The full list is in the [API overview](https://docs.qblackbit.com/api/index.md#errors).

## Next

- Every route, field and answer: the [Cloud API reference](https://docs.qblackbit.com/api/cloud.md).
- Moving a real project: the [personal project guide](https://docs.qblackbit.com/guides/developer-project.md), or hand the work to your agent with the [matching prompt](https://docs.qblackbit.com/prompts/developer-project.md).
- More room and every standard parameter set: request **Pro** from the **Plan** page in the app; qblackbit then gets in touch.
