Key Management
This guide covers the complete PQC key lifecycle in Qpher: generating key pairs, listing keys, finding the active key, rotating to a new version, and retiring old keys.
Prerequisites
- A Qpher account with an active API key
- Understanding of which algorithm you need:
- Kyber768 for encryption/decryption (KEM)
- Dilithium3 for signing/verification
Key Lifecycle Overview
Private keys are generated and used only inside Qpher's isolated key service. No API can export them. At rest they are encrypted with a Google Cloud KMS key.
Generate a Key Pair
Generate your first PQC key pair. Each tenant can have one active key per algorithm at a time.
curl -X POST https://api.qpher.ai/api/v1/kms/keys/generate \
-H "Content-Type: application/json" \
-H "x-api-key: qph_your_key_here" \
-d '{
"algorithm": "Kyber768"
}'/api/v1/kms/keys/generateContent-Type: application/json
x-api-key: qph_your_key_here{
"algorithm": "Kyber768"
}{
"data": {
"key_version": 1,
"algorithm": "Kyber768",
"status": "active",
"public_key": "base64-encoded-public-key...",
"created_at": "2026-02-15T10:00:00Z"
},
"request_id": "aaa-bbb-ccc",
"timestamp": "2026-02-15T10:00:00Z"
}To generate a Dilithium3 key pair for signing, replace "Kyber768" with "Dilithium3".
List All Keys
Retrieve all key versions for your tenant, across all algorithms and statuses.
curl -X GET https://api.qpher.ai/api/v1/kms/keys \
-H "x-api-key: qph_your_key_here"Get the Active Key
Retrieve the currently active key for a specific algorithm.
curl -X GET "https://api.qpher.ai/api/v1/kms/keys/active?algorithm=Kyber768" \
-H "x-api-key: qph_your_key_here"Rotate a Key
Key rotation creates a new active key version. The previous active key is moved to retired status. Retired keys can still be used for decryption and signature verification.
Each algorithm can hold up to 100 key versions that still hold a private key (active or retired). To make room, an organization owner or admin archives retired versions in Qpher Portal, confirming with a fresh second factor (a TOTP code, or the account password when MFA is off). A version can be archived 24 hours after it is retired, and not while Qpher Vault data still depends on it. Archive is irreversible and is not available through the API, SDKs, CLI or MCP server.
curl -X POST https://api.qpher.ai/api/v1/kms/keys/rotate \
-H "Content-Type: application/json" \
-H "x-api-key: qph_your_key_here" \
-d '{
"algorithm": "Kyber768"
}'Retire a Key
Manually retire a specific key version. Retired keys can no longer encrypt or sign, but can still decrypt and verify.
curl -X POST https://api.qpher.ai/api/v1/kms/keys/retire \
-H "Content-Type: application/json" \
-H "x-api-key: qph_your_key_here" \
-d '{
"algorithm": "Kyber768",
"key_version": 1
}'Error Handling
| HTTP Status | Error Code | Cause | Resolution |
|---|---|---|---|
| 400 | ERR_INVALID_001 | Generate while the algorithm already has an active key, or retire a key that is not active | Use rotate to create a new version |
| 401 | ERR_AUTH_001 | Invalid or missing API key | Check your x-api-key header |
| 403 | ERR_POLICY_001 | Your plan does not include this operation or algorithm | Check your plan in Qpher Portal |
| 403 | ERR_KMS_020 | Archive requested with an API key | An organization owner or admin archives keys in Qpher Portal |
| 403 | ERR_KMS_025 | Archive, or its pre-check, requested in Qpher Portal by an organization member who is not an owner or admin | Ask an organization owner or admin |
| 404 | ERR_NOT_FOUND_001 | Key version not found, or no active key to rotate | List your keys with GET /api/v1/kms/keys; generate a key first |
| 409 | ERR_KMS_021 | The algorithm already has 100 key versions that still hold a private key (active or retired) | An organization owner or admin archives retired versions in Qpher Portal, then generate or rotate |
| 422 | ERR_INVALID_001 | Invalid request body, for example an unknown algorithm name | Check the algorithm name and required fields |
| 429 | ERR_RATE_LIMIT_001 | Rate limit exceeded | Retry after the Retry-After interval |
Related Guides
- Key Versioning — How key versions and the active key work
- Encrypt Data — Use your KEM keys for encryption
- Sign Documents — Use your signing keys for digital signatures
- Migration Guide — Plan your PQC migration strategy