User keys — K8 HQ Sign-in API
User keys operations for K8 HQ Sign-in API. Requests, permissions and responses.
Version 1OpenAPI description (JSON)
Before making requests, read the authentication and request requirements.
Create and unlock the person's own encryption key, and choose whether K8 HQ keeps a copy for recovery.
Base URL
| Base URL | For |
https://api.k8hq.com/auth | The K8 HQ web app, and programs acting with a person's session |
Endpoints
User keys
Get the person's key
GET/v1/keys
The person's key pair for zero-access inboxes (design note 0003): public keys and sealed private keys, which the client unseals with a passkey's PRF secret or the recovery kit. key is null until one is made. serverCopy says whether K8 HQ keeps a copy of the key for passkeys without PRF. This read uses only the signed-in person’s identity; request bodies cannot select another user. It returns wrapped records and status only, never the plaintext server-held copy, and does not require a recent passkey. Responses use Cache-Control: no-store. Delegated assistant tokens are refused.
For a person's own session (x-k8hq-token) only: assistants' delegated tokens and API tokens are refused.
Response body (JSON)
| Field | Type | Description |
key required | any | |
exposed | boolean | With key replacement on: whether this key was reported as possibly exposed (design note 0032 B.2). Replace it if so. |
fingerprint | string | The directory's fingerprint of the key (the first 8 bytes of the SHA-256 of x25519, in hex), when there's a key. Compare it with the one the web app computes from the key it unlocks and with the one K8 HQ's mail servers pinned (content API GET /key-fingerprints). Pattern: ^[0-9a-f]{16}$. |
keyGeneration | integer | With key replacement on: the key's generation, 1 for a first key and one more for each replacement. |
replacedAt | string | With key replacement on: when this key replaced the one before (RFC 3339); absent for a first key. |
serverCopy | any | Whether K8 HQ keeps a copy of the key (for passkeys without PRF): when it was turned on, or null. Absent where the service doesn't offer it. |
Responses
| Status | Body | Meaning |
| 200 | JSON | The key record, or null. |
| 401 | application/problem+json | No session, or it expired or was revoked (unauthenticated): refresh, or sign in again. |
| 403 | application/problem+json | Not allowed (forbidden): an assistant's delegated token, or a browser origin other than the web app's. |
| 404 | application/problem+json | Key records are disabled on this service (not_found). |
| 426 | application/problem+json | K8 HQ has been updated. Reload this page. |
| 500 | application/problem+json | A temporary problem (unavailable); retry. |
Create the person's key
PUT/v1/keys
Stores the person's first key pair, made on their device. It can't be replaced through this call. At least one wrap must be a recovery wrap.
For a person's own session (x-k8hq-token) only: assistants' delegated tokens and API tokens are refused. The session needs a recent passkey: if its last passkey confirmation is more than 5 minutes old, the answer is 401 step_up_required.
Parameters
| Name | Type | Description |
x-amz-content-sha256 (header) required | string | The body's SHA-256, lowercase hex. CloudFront signs requests to this service and refuses a POST without it (403, not a problem detail). For {}: 44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a. |
Request body (JSON)
| Field | Type | Description |
ed25519 required | string | The public Ed25519 key (signing), 32 bytes, standard base64. |
wraps required | KeyWrap[] | Sealed copies of the private keys: 1 to 20, at least one recovery. |
x25519 required | string | The public X25519 key (for sealing inbox keys to the person), 32 bytes, standard base64. |
suite | HPKESuite | |
{"ed25519":"base64...","wraps":[{"id":"recovery","kind":"recovery","salt":"base64...","wrapped":"base64..."}],"x25519":"base64..."}
Response body (JSON)
| Field | Type | Description |
ok required | true | |
Responses
| Status | Body | Meaning |
| 200 | Ok | Stored. |
| 400 | application/problem+json | The record's shape is wrong (invalid). |
| 401 | application/problem+json | No session or it expired (unauthenticated), or its passkey confirmation is more than 5 minutes old (step_up_required). |
| 403 | application/problem+json | Not allowed (forbidden): an assistant's delegated token, or a browser origin other than the web app's. |
| 405 | application/problem+json | Method not allowed. The Allow header lists supported methods. |
| 409 | application/problem+json | The person already has a key, or your account changed meanwhile (another passkey, session or name change, or a key change, won the race) and nothing was changed: reload and try again (conflict); or the key belongs to another account (key_in_use). |
| 426 | application/problem+json | K8 HQ has been updated. Reload this page. |
| 500 | application/problem+json | A temporary problem (unavailable); retry. |
Replace the person's key
POST/v1/keys/replace
Replaces the person's key with a new key pair made on their device (design note 0032 B.1), for someone who lost their key or whose key was reported. previous is the key the device read from GET /v1/keys; the old private key isn't needed. The new record has 1 to 20 wraps, at least one a recovery wrap, and every old wrap is replaced. K8 HQ's copy of the old key, if any, is deleted. Zero-access inboxes need a holder to give the new key access; mail sealed only to the old key stays unreadable. A key that was this person's before, or that was reported as possibly exposed, is refused. Send Idempotency-Key: <operationId>:key-replace; a retry with the same input answers replayed: true. Only the person's own session, with a passkey sign-in in the last 5 minutes. Off unless key replacement is turned on (404). Responses use Cache-Control: no-store.
For a person's own session (x-k8hq-token) only: assistants' delegated tokens and API tokens are refused. The session needs a recent passkey: if its last passkey confirmation is more than 5 minutes old, the answer is 401 step_up_required.
Parameters
| Name | Type | Description |
x-amz-content-sha256 (header) required | string | The body's SHA-256, lowercase hex. CloudFront signs requests to this service and refuses a POST without it (403, not a problem detail). For {}: 44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a. |
Idempotency-Key (header) required | string | <operationId>:key-replace. |
Request body (JSON)
| Field | Type | Description |
operationId required | string | Pattern: ^akr_[0-9A-HJKMNP-TV-Z]{26}$. |
previous required | object | |
record required | object | |
schemaVersion required | 1 | |
{"operationId":"akr_01M4KN0000000000000000000A","previous":{"ed25519":"base64url...","x25519":"base64url..."},"record":{"ed25519":"base64url...","wraps":[{"id":"recovery","kind":"recovery","salt":"base64url...","wrapped":"base64url..."}],"x25519":"base64url..."},"schemaVersion":1}
Response body (JSON)
| Field | Type | Description |
fingerprint required | string | Pattern: ^[0-9a-f]{16}$. |
previousFingerprint required | string | Pattern: ^[0-9a-f]{16}$. |
replayed required | boolean | |
schemaVersion required | 1 | |
Responses
| Status | Body | Meaning |
| 200 | JSON | Replaced (or the same replacement replayed). |
| 400 | application/problem+json | The body, the Idempotency-Key or the new record isn't valid, or the new key equals the old one (invalid). |
| 401 | application/problem+json | No session or it expired (unauthenticated), or its passkey confirmation is more than 5 minutes old (step_up_required). |
| 403 | application/problem+json | An assistant or token asked (needs_person), the request isn't allowed (forbidden), or the person recovered their account by email in the last 7 days (recently_recovered, with until). |
| 404 | application/problem+json | Key replacement is off (not_found). |
| 409 | application/problem+json | No key yet (no_key); the key changed on another device, the operation was used for other input, your account changed or an account recovery started meanwhile (conflict); the new key was replaced before (key_retired) or reported as possibly exposed (key_exposed); the new key belongs to another account (key_in_use). |
| 426 | application/problem+json | K8 HQ has been updated. Reload this page. |
| 500 | application/problem+json | A temporary problem (unavailable); retry. |
| 503 | application/problem+json | Key replacement isn't available yet: K8 HQ hasn't finished recording who owns each key (unavailable). |
Unlock with K8 HQ's copy of the key
POST/v1/keys/server-copy
For passkeys that can't unlock the person's key themselves (no PRF): returns the private key bundle K8 HQ keeps for them, if they turned that on (Turn on K8 HQ's copy). Needs a passkey sign-in or confirmation in the last 5 minutes (user verification is always required). The client keeps the bundle as this device's copy and never sends it anywhere else. Each release is recorded in the person's own events (access.userkey_server_copy.released), and one to a device or network that hadn't had one in 90 days gets an account notice. At most 10 releases and turn-ons an hour per person. If the person now uses a zero-access inbox, the copy is deleted and the call answers 409 zero_access. Answers are never cached (cache-control: no-store). Needs a release ticket: the releaseTicket from this session's passkey sign-in, or from a passkey confirmation asked with unlock; single use, 5 minutes, only for the session it was given to (design note 0013's review, H1). Until confirmations are enforced, a passkey sign-in in the last 5 minutes still does when no ticket is sent.
For a person's own session (x-k8hq-token) only: assistants' delegated tokens and API tokens are refused. The session needs a recent passkey: if its last passkey confirmation is more than 5 minutes old, the answer is 401 step_up_required.
Parameters
| Name | Type | Description |
x-amz-content-sha256 (header) required | string | The body's SHA-256, lowercase hex. CloudFront signs requests to this service and refuses a POST without it (403, not a problem detail). For {}: 44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a. |
Request body (JSON)
| Field | Type | Description |
ticket | string | The release ticket (k8hq_rel_...). Pattern: ^k8hq_rel_. |
{"ticket":"k8hq_rel_..."}
Response body (JSON)
| Field | Type | Description |
bundle required | string | The private keys, 64 bytes in standard base64: the X25519 private key, then the Ed25519 seed. They match the account's public keys. |
Responses
| Status | Body | Meaning |
| 200 | JSON | The key. |
| 401 | application/problem+json | No session or it expired (unauthenticated), or its passkey confirmation is more than 5 minutes old (step_up_required). |
| 403 | application/problem+json | Not allowed (forbidden): an assistant's delegated token, or a browser origin other than the web app's. |
| 404 | application/problem+json | K8 HQ keeps no copy of this person's key (no_server_copy). |
| 409 | application/problem+json | The person uses a zero-access inbox, so the copy was deleted (zero_access), or the copy no longer matches the account's key (conflict). |
| 426 | application/problem+json | K8 HQ has been updated. Reload this page. |
| 429 | application/problem+json | Too many releases this hour (rate_limited). |
| 500 | application/problem+json | A temporary problem (unavailable); retry. |
Turn on K8 HQ's copy of the key
PUT/v1/keys/server-copy
Lets K8 HQ keep a copy of the person's key, so a passkey without PRF can unlock their mail after signing in (Unlock with K8 HQ's copy). The client sends the key it has unlocked on this device (with a PRF passkey, the recovery kit or this device's copy); it must match the account's public keys. K8 HQ stores it encrypted with a key only the sign-in service can use, bound to the person. Less private than a PRF passkey: the person trusts K8 HQ with their key. Refused (409 zero_access) while they use a zero-access inbox. Turning it on again replaces the copy. Recorded as access.userkey_server_copy.enabled in the person's own events. Answers are never cached (cache-control: no-store).
For a person's own session (x-k8hq-token) only: assistants' delegated tokens and API tokens are refused. The session needs a recent passkey: if its last passkey confirmation is more than 5 minutes old, the answer is 401 step_up_required.
Parameters
| Name | Type | Description |
x-amz-content-sha256 (header) required | string | The body's SHA-256, lowercase hex. CloudFront signs requests to this service and refuses a POST without it (403, not a problem detail). For {}: 44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a. |
Request body (JSON)
| Field | Type | Description |
bundle required | string | The unlocked private keys, 64 bytes in standard base64: the X25519 private key, then the Ed25519 seed. |
{"bundle":"base64..."}
Response body (JSON)
| Field | Type | Description |
serverCopy required | ServerCopy | |
Responses
| Status | Body | Meaning |
| 200 | JSON | Turned on. |
| 400 | application/problem+json | The bundle is missing, the wrong size or doesn't belong to this account (invalid). |
| 401 | application/problem+json | No session or it expired (unauthenticated), or its passkey confirmation is more than 5 minutes old (step_up_required). |
| 403 | application/problem+json | Not allowed (forbidden): an assistant's delegated token, or a browser origin other than the web app's. |
| 405 | application/problem+json | Method not allowed. The Allow header lists supported methods. |
| 409 | application/problem+json | The person uses a zero-access inbox (zero_access), or has no key yet (conflict), or your account changed meanwhile (another passkey, session or name change, or a key change, won the race) and nothing was changed: reload and try again (conflict). |
| 426 | application/problem+json | K8 HQ has been updated. Reload this page. |
| 429 | application/problem+json | Too many turn-ons and releases this hour (rate_limited). |
| 500 | application/problem+json | A temporary problem (unavailable); retry. |
Turn off K8 HQ's copy of the key
DELETE/v1/keys/server-copy
Needs a passkey use in the last 5 minutes (step_up_required otherwise), so a stolen session alone can't take away the person's way of unlocking. Deletes K8 HQ's copy of the person's key at once (backups age out within 35 days). Recorded as access.userkey_server_copy.disabled (reason turned_off) when there was one. Passkeys without PRF then need the recovery kit, or this device's copy, to unlock mail. Answers are never cached (cache-control: no-store).
Needs a passkey confirmation of this change (x-k8hq-confirm: server_copy.disable). Until confirmations are enforced, a passkey sign-in in the last five minutes also works.
For a person's own session (x-k8hq-token) only: assistants' delegated tokens and API tokens are refused. The session needs a recent passkey: if its last passkey confirmation is more than 5 minutes old, the answer is 401 step_up_required.
Parameters
| Name | Type | Description |
x-amz-content-sha256 (header) required | string | The body's SHA-256, lowercase hex. CloudFront signs requests to this service and refuses a POST without it (403, not a problem detail). For {}: 44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a. |
Response body (JSON)
| Field | Type | Description |
ok required | true | |
Responses
| Status | Body | Meaning |
| 200 | Ok | Off (or already off). |
| 401 | application/problem+json | No session or it expired (unauthenticated), or confirm this change with your passkey (confirmation_required; until confirmations are enforced, step_up_required with action, which a passkey use in the last 5 minutes also satisfies): the answer carries the action to confirm and a short summary. |
| 403 | application/problem+json | Not allowed (forbidden): an assistant's delegated token, or a browser origin other than the web app's. |
| 405 | application/problem+json | Method not allowed. The Allow header lists supported methods. |
| 409 | application/problem+json | The confirmation is for a different change, or what it changes is different now (confirmation_mismatch), was already used (confirmation_used) or timed out (confirmation_expired). |
| 426 | application/problem+json | K8 HQ has been updated. Reload this page. |
| 500 | application/problem+json | A temporary problem (unavailable); retry. |
Add a sealed copy of the key
POST/v1/keys/wraps
Adds a wrap of the person's private key (sealed with another passkey's PRF secret, or a new recovery kit). A wrap is never replaced: an ID the account already has is refused (409 wrap_exists), since K8 HQ can't open wraps to tell a re-wrap from one that would lock the person out. Every wrap added sends the person a security notice (userkey_unlock_added, never muted) and is recorded as access.userkey.wrap_added in their own events.
For a person's own session (x-k8hq-token) only: assistants' delegated tokens and API tokens are refused. The session needs a recent passkey: if its last passkey confirmation is more than 5 minutes old, the answer is 401 step_up_required.
Parameters
| Name | Type | Description |
x-amz-content-sha256 (header) required | string | The body's SHA-256, lowercase hex. CloudFront signs requests to this service and refuses a POST without it (403, not a problem detail). For {}: 44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a. |
Request body (JSON)
| Field | Type | Description |
id required | string | Chosen by the client: 1 to 100 of A-Z a-z 0-9 _ -. Adding a wrap with an existing ID replaces it. Pattern: ^[A-Za-z0-9_-]{1,100}$. |
kind required | prf | recovery | prf: sealed with a passkey's PRF secret; recovery: sealed with the recovery kit's secret. |
salt required | string | The HKDF salt, 32 bytes, standard base64. |
wrapped required | string | AES-256-GCM (nonce, then ciphertext) of the private key bundle, 28 to 1024 bytes, standard base64. K8 HQ can't open it. |
createdAt | string | Set by K8 HQ. |
credentialId | string | For prf: the passkey's credential ID (base64url). |
{"credentialId":"q1w2e3...","id":"pk-iphone","kind":"prf","salt":"base64...","wrapped":"base64..."}
Response body (JSON)
| Field | Type | Description |
ok required | true | |
Responses
| Status | Body | Meaning |
| 200 | Ok | Stored. |
| 400 | application/problem+json | The wrap's shape is wrong (invalid). |
| 401 | application/problem+json | No session or it expired (unauthenticated), or its passkey confirmation is more than 5 minutes old (step_up_required). |
| 403 | application/problem+json | Not allowed (forbidden): an assistant's delegated token, or a browser origin other than the web app's. |
| 405 | application/problem+json | Method not allowed. The Allow header lists supported methods. |
| 409 | application/problem+json | The person has no key yet (conflict), or already has a wrap with this ID (wrap_exists), or your account changed meanwhile (another passkey, session or name change, or a key change, won the race) and nothing was changed: reload and try again (conflict). |
| 426 | application/problem+json | K8 HQ has been updated. Reload this page. |
| 500 | application/problem+json | A temporary problem (unavailable); retry. |