{
  "openapi": "3.1.0",
  "info": {
    "title": "K8 HQ Sign-in API",
    "version": "1",
    "summary": "Sign up and sign in with passkeys, and manage a person's sessions, passkeys, tokens, invitations and organization members.",
    "description": "Passkey sign-in for K8 HQ, and everything about a person's account: sessions, passkeys, access tokens, invitations, the members of their organizations, K8 settings and account notices. The [Content API](https://api.k8hq.com/docs) reads and sends messages; the [Setup API](https://api.k8hq.com/setup/docs) creates organizations, domains and inboxes.\n\n**Requests.** Resource reads use GET without a body. JSON writes use POST, PUT, PATCH or DELETE as documented. Requests use these headers where applicable:\n\n- `content-type: application/json`.\n- `x-amz-content-sha256`: the body's SHA-256 in lowercase hex. api.k8hq.com reaches this service through CloudFront, which signs each request to it; a JSON mutation without the right hash is refused with 403 before it gets here (not a problem detail). For mutations with no fields, send `{}` and hash exactly the bytes you send. Bodyless GET requests do not need this header.\n- `x-k8hq-token`: the session's access token, on every call but the sign-up, sign-in, recovery and refresh ceremonies. Not `Authorization`, which CloudFront uses for its own signature.\n\n**Sessions.** Signing up or in with a passkey starts a session: an access token (a JWT, valid 15 minutes) and a refresh token (30 days). Exchange the refresh token at [Refresh a session](#refresh) before the access token expires; each one works once, and presenting a spent one ends the session. The same access token works on the content API and the Setup API.\n\n**Recent passkey (step-up).** Changes to credentials, people and settings need a passkey used in the last 5 minutes; each such call says so. Otherwise it answers 401 `step_up_required`: run [Start a passkey confirmation](#stepUpBegin) and [Finish it](#stepUpFinish) (the passkey prompt, on the same page), then retry with the new access token. Refreshing doesn't renew the confirmation.\n\n**A person's own session.** Every call acts for the person signed in and none takes a user ID. API tokens (`k8hq_...`) aren't accepted here. Assistants' delegated tokens ([Get a delegated token for K8](#k8Token)) get 403 `forbidden`, except K8 Admin's on the three listings that say so, and only in the organization the token was made for.\n\n**Browsers.** Only `https://app.k8hq.com` may call this API from a browser: CORS preflights from other origins are refused, and a request whose `Origin` names another site gets 403 `forbidden` (against cross-site request forgery). Programs that send no `Origin` aren't affected. No cookies are used.\n\n**Limits.** Each network address may make 100 sign-in, sign-up and recovery POSTs in 5 minutes under `/auth/v1/login/`, `/auth/v1/signup/` and `/auth/v1/recovery/`. A sign-in uses two requests; recovery uses a handful. Other `/auth/` requests, excluding OPTIONS, have a separate limit of 300 per address in 5 minutes, including `GET /auth/v1/recovery/status`. Browser preflights count toward neither auth budget. Neither budget uses the other. For these limits, paths are URL-decoded, normalized and matched in lowercase. Both return 429 `rate_limited` with a problem body and `Retry-After: 300`. All requests still count toward the broader API limit of 3000 per address in 5 minutes, which can return 403. Edge enforcement is approximate. Separately, 20 failed passkey ceremonies in 15 minutes get 429 `rate_limited` until the window passes.\n\n**Errors** are [RFC 9457](https://www.rfc-editor.org/rfc/rfc9457) problem details with a stable `code`; see [Error codes](#errors).\n\nResource operations use GET for reads, POST for creation and workflows, PUT for whole resources, PATCH for partial updates, and DELETE for removal. Credential requirements are unchanged; this release does not add external-agent administrative authorization. JSON mutation bodies sent through CloudFront need their x-amz-content-sha256 hash; GET requests have no body."
  },
  "servers": [
    {
      "url": "https://api.k8hq.com/auth",
      "description": "The K8 HQ web app, and programs acting with a person's session"
    }
  ],
  "security": [
    {
      "session": []
    }
  ],
  "tags": [
    {
      "name": "Sign-up and sign-in",
      "description": "Create an account or sign in with a passkey. Each ceremony is two calls: start, then finish with the browser's passkey response."
    },
    {
      "name": "Sessions",
      "description": "Refresh, confirm and end sessions. Use these to keep an access token fresh and to confirm a recent passkey before sensitive changes."
    },
    {
      "name": "Account",
      "description": "Read the signed-in person's account and change their display name."
    },
    {
      "name": "Policies",
      "description": "See which terms and policy versions the person still has to accept, and accept them."
    },
    {
      "name": "Passkeys",
      "description": "List, add and remove the passkeys that sign a person in."
    },
    {
      "name": "User keys",
      "description": "Create and unlock the person's own encryption key, and choose whether K8 HQ keeps a copy for recovery."
    },
    {
      "name": "Access tokens",
      "description": "Create and revoke your own access tokens for scripts, AI agents and integrations. Owners and admins can also list and revoke any token in the organization."
    },
    {
      "name": "Sign-up invitations",
      "description": "Make and revoke invitations that let someone new create a K8 HQ account."
    },
    {
      "name": "Members",
      "description": "List an organization's members and change their roles, suspend, remove or leave."
    },
    {
      "name": "Invites",
      "description": "Invite people to an organization, and preview or accept an invite you were sent."
    },
    {
      "name": "Pending changes",
      "description": "Changes to people that wait for an owner: list them, approve, decline or cancel."
    },
    {
      "name": "K8",
      "description": "K8, the built-in assistant: its settings and the delegated token it acts with."
    },
    {
      "name": "Notices",
      "description": "The person's account notices: list them, mark them read, follow their links and delete them."
    },
    {
      "name": "Notifications",
      "description": "Where notices are sent besides the web app (email addresses), and which kinds each destination gets."
    },
    {
      "name": "Service",
      "description": "The public keys session access tokens are signed with, for services that verify tokens offline."
    },
    {
      "name": "Sign-in recovery",
      "description": "Recover a K8 HQ account after losing every passkey, using an outside address and a copy of the key kept by K8 HQ."
    },
    {
      "name": "Agent key bindings",
      "description": "Apps connected by a person prove they hold the keys K8 HQ may later share with them, and the person confirms them.\n\nDesign note 0031. Off until zero-access inboxes ship: every operation answers 404 `not_found`."
    }
  ],
  "paths": {
    "/.well-known/jwks.json": {
      "get": {
        "tags": [
          "Service"
        ],
        "operationId": "jwks",
        "summary": "Get the signing keys",
        "description": "The public keys session access tokens are signed with (ES256), for services that verify them offline. Cached for 5 minutes. Tokens' `iss` is `https://auth.k8hq.com` and `aud` `k8hq` (a person's session) or an assistant's audience.",
        "security": [],
        "responses": {
          "200": {
            "description": "The key set.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/JWKS"
                }
              }
            }
          }
        },
        "parameters": []
      }
    },
    "/v1/account": {
      "get": {
        "tags": [
          "Account"
        ],
        "operationId": "getAccountResource",
        "summary": "Get the account",
        "description": "The person's user ID and display name: the name every organization they're in shows for them (in [List members](#listMembersResource)). Not available to an assistant's delegated token. Includes any waiting recovery and when the limits after account recovery end.",
        "security": [
          {
            "session": []
          }
        ],
        "parameters": [],
        "responses": {
          "200": {
            "description": "The account.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "userId": {
                      "type": "string",
                      "description": "The person (usr_)."
                    },
                    "name": {
                      "type": "string",
                      "description": "Their display name; empty if they chose none."
                    },
                    "recovery": {
                      "description": "The waiting recovery from the account recovery lock, or null. Use this for the banner on every page and the notice shown after passkey sign-in. The address is masked; no cancel token or pending credential is returned.",
                      "oneOf": [
                        {
                          "type": "object",
                          "properties": {
                            "recoveryId": {
                              "type": "string"
                            },
                            "startedAt": {
                              "type": "string"
                            },
                            "readyAt": {
                              "type": "string"
                            },
                            "expiresAt": {
                              "type": "string"
                            },
                            "network": {
                              "type": "string"
                            },
                            "country": {
                              "type": "string"
                            },
                            "address": {
                              "type": "string"
                            }
                          },
                          "required": [
                            "recoveryId",
                            "startedAt",
                            "readyAt",
                            "expiresAt",
                            "network",
                            "country"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "recoveredUntil": {
                      "type": "integer",
                      "description": "Unix time when the seven-day limits end, or zero when they do not apply. Expired records do not extend the limits."
                    }
                  },
                  "required": [
                    "userId",
                    "name"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "userId": "usr_01J9ZQ3W5K7M8N2P4R6T8V0X2Y",
                  "name": "Dee Porter"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "500": {
            "$ref": "#/components/responses/Error"
          },
          "405": {
            "description": "Method not allowed. The Allow header lists supported methods.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      },
      "patch": {
        "tags": [
          "Account"
        ],
        "operationId": "setAccountNameResource",
        "summary": "Change the display name",
        "description": "Changes the person's display name, the same in every organization they're in, or clears it with `\"\"`. Spaces are collapsed; up to 100 characters, without control characters. Only the person can change it, never an assistant's delegated token. A change records `user.name.changed` in their own scope.",
        "security": [
          {
            "session": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/contentSha256"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "description": "The new name, or `\"\"` to clear it.",
                    "maxLength": 100
                  }
                },
                "required": [
                  "name"
                ]
              },
              "example": {
                "name": "Dee Porter"
              }
            }
          }
        },
        "responses": {
          "409": {
            "description": "Your account changed meanwhile (another passkey, session or name change won the race), so nothing was changed (`conflict`); reload and try again.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "200": {
            "description": "Changed (or unchanged): the name as stored.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "name": {
                      "type": "string",
                      "description": "The name as stored; empty if cleared."
                    }
                  },
                  "required": [
                    "name"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "500": {
            "$ref": "#/components/responses/Error"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "405": {
            "description": "Method not allowed. The Allow header lists supported methods.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/v1/changes/approve": {
      "post": {
        "tags": [
          "Pending changes"
        ],
        "operationId": "approveChange",
        "summary": "Approve a change",
        "description": "An owner approves a pending change, which is applied now (or fails, and is marked so, if the organization changed meanwhile). Approving a removal that would leave boards without a full member gives the approving owner full access to them: the 401 `confirmation_required` answer lists `boards` and `ownerMemberId` (the approver) as removing a member does, and the confirmation is always needed then. Zero-access boards are listed but not handed over. A changed list needs a fresh confirmation (409 `confirmation_mismatch`); the change stays pending.\n\nNeeds a passkey confirmation of this change (`x-k8hq-confirm`: `change.approve`). Until confirmations are enforced, a passkey sign-in in the last five minutes also works.",
        "security": [
          {
            "session": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/contentSha256"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string",
                    "description": "The organization (`org_...`).",
                    "pattern": "^org_"
                  },
                  "id": {
                    "type": "string"
                  }
                },
                "required": [
                  "orgId",
                  "id"
                ]
              },
              "example": {
                "orgId": "org_01J...",
                "id": "chg_01J..."
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Applied.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Ok"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedConfirm"
          },
          "403": {
            "description": "Their role or permissions don't allow it (`forbidden`); or a delegated token or foreign origin; or the confirmation isn't this session's (`confirmation_invalid`), or an API token or assistant asked (`needs_person`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/Error"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "404": {
            "description": "They aren't a member of the organization (`not_found`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "409": {
            "description": "It isn't pending any more, or can't be applied now, or who can do what in the organization changed while this ran: reload and try again (`conflict`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        },
        "x-k8hq-step-up": true,
        "x-k8hq-confirm": "change.approve"
      }
    },
    "/v1/changes/decline": {
      "post": {
        "tags": [
          "Pending changes"
        ],
        "operationId": "declineChange",
        "summary": "Decline or cancel a change",
        "description": "Owners decline a pending change; whoever asked for it may cancel it.",
        "security": [
          {
            "session": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/contentSha256"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string",
                    "description": "The organization (`org_...`).",
                    "pattern": "^org_"
                  },
                  "id": {
                    "type": "string"
                  }
                },
                "required": [
                  "orgId",
                  "id"
                ]
              },
              "example": {
                "orgId": "org_01J...",
                "id": "chg_01J..."
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Declined.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Ok"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Their role or permissions don't allow it (`forbidden`); or a delegated token or foreign origin.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/Error"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "404": {
            "description": "They aren't a member of the organization (`not_found`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "409": {
            "description": "It isn't pending any more, or who can do what in the organization changed while this ran: reload and try again (`conflict`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/v1/destinations/ask/dismiss": {
      "post": {
        "tags": [
          "Notifications"
        ],
        "operationId": "dismissDestinationAsk",
        "summary": "Keep notices in Notices only",
        "description": "The person chose not to send security notices to a shared inbox: `ask` turns false.",
        "security": [
          {
            "session": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/contentSha256"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {},
                "description": "Send `{}`: the call takes nothing."
              },
              "example": {}
            }
          }
        },
        "responses": {
          "200": {
            "description": "Done.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Ok"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "500": {
            "$ref": "#/components/responses/Error"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          }
        }
      }
    },
    "/v1/destinations/confirm": {
      "post": {
        "tags": [
          "Notifications"
        ],
        "operationId": "confirmDestination",
        "summary": "Confirm a destination",
        "description": "Checks the 6-digit code K8 HQ emailed an outside address (7 days, the newest one only, 5 tries) and starts sending copies there. Codes are typed here, signed in: confirmation emails carry no link that confirms.",
        "security": [
          {
            "session": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/contentSha256"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "id": {
                    "type": "string"
                  },
                  "code": {
                    "type": "string"
                  }
                },
                "required": [
                  "id",
                  "code"
                ]
              },
              "example": {
                "id": "dst_01J...",
                "code": "123456"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The confirmed destination.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "destination": {
                      "$ref": "#/components/schemas/Destination"
                    }
                  },
                  "required": [
                    "destination"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedStepUp"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "500": {
            "$ref": "#/components/responses/Error"
          },
          "400": {
            "description": "Bad request, or the code isn't right (`wrong_code`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "description": "It isn't waiting for a code (`not_pending`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "410": {
            "description": "The code has expired (`code_expired`): send a new one.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "Too many wrong codes (`too_many_tries`): send a new one; or no more destination changes today (`changes_limit`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        },
        "x-k8hq-step-up": true
      }
    },
    "/v1/destinations/resend": {
      "post": {
        "tags": [
          "Notifications"
        ],
        "operationId": "resendDestinationCode",
        "summary": "Send a new code",
        "description": "Emails a pending address a new code; earlier codes stop working. Counts against the 5 confirmation emails a day.",
        "security": [
          {
            "session": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/contentSha256"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "id": {
                    "type": "string"
                  }
                },
                "required": [
                  "id"
                ]
              },
              "example": {
                "id": "dst_01J..."
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Sent (within a minute).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "const": true
                    },
                    "confirmationsLeft": {
                      "type": "integer"
                    }
                  },
                  "required": [
                    "ok",
                    "confirmationsLeft"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "500": {
            "$ref": "#/components/responses/Error"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "description": "It isn't waiting for a code (`not_pending`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "No more confirmation emails today (`confirmations_limit`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/v1/destinations/stop": {
      "post": {
        "tags": [
          "Notifications"
        ],
        "operationId": "stopDestination",
        "summary": "Stop emails to an address",
        "description": "The \"this wasn't me\" link in a confirmation email (`https://app.k8hq.com/n/stop/<token>`), needing no sign-in: K8 HQ won't email the address again, for any account, and its person is told.",
        "security": [],
        "parameters": [
          {
            "$ref": "#/components/parameters/contentSha256"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "token": {
                    "type": "string"
                  }
                },
                "required": [
                  "token"
                ]
              },
              "example": {
                "token": "dst_01J...-1-..."
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Stopped.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Ok"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/Error"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "404": {
            "description": "Not a link K8 HQ sent, or it was changed (`not_found`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/v1/invites/accept": {
      "post": {
        "tags": [
          "Invites"
        ],
        "operationId": "acceptInvite",
        "summary": "Accept an invite",
        "description": "Joins the organization with the invite's role and access (or adds the access, for a member).",
        "security": [
          {
            "session": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/contentSha256"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "secret": {
                    "type": "string",
                    "pattern": "^k8hq_inv_"
                  }
                },
                "required": [
                  "secret"
                ]
              },
              "example": {
                "secret": "k8hq_inv_EXAMPLE"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Joined.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "orgId": {
                      "type": "string",
                      "description": "The organization (`org_...`).",
                      "pattern": "^org_"
                    },
                    "memberId": {
                      "type": "string",
                      "description": "The person's member ID there."
                    },
                    "role": {
                      "type": "string",
                      "enum": [
                        "guest",
                        "member",
                        "developer",
                        "admin",
                        "owner"
                      ],
                      "description": "The member's organization role: `guest`, `member`, `developer`, `admin` or `owner`. Guest has no organization permissions and cannot list members, domains or roles."
                    }
                  },
                  "required": [
                    "orgId",
                    "memberId",
                    "role"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "description": "The organization is read-only (`read_only`, design note 0024): it has been out of credit for 60 days, so nobody can be invited to it or join it until an owner adds credit.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "500": {
            "$ref": "#/components/responses/Error"
          },
          "410": {
            "description": "The invitation link is invalid (`invalid`). Whoever made a contact book invitation may no longer be able to give the access it offers.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "409": {
            "description": "Who can do what in the organization changed while this ran, so nothing was changed: reload and try again (`conflict`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/v1/invites/preview": {
      "post": {
        "tags": [
          "Invites"
        ],
        "operationId": "previewInvite",
        "summary": "Preview an invite",
        "description": "What accepting an invite link would give the signed-in person, before they accept. Only a valid invitation secret reveals the organization and inviter names. No other organization or inviter details are returned.",
        "security": [
          {
            "session": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/contentSha256"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "secret": {
                    "type": "string",
                    "pattern": "^k8hq_inv_"
                  }
                },
                "required": [
                  "secret"
                ]
              },
              "example": {
                "secret": "k8hq_inv_EXAMPLE"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "What it offers.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "orgId": {
                      "type": "string",
                      "description": "The organization (`org_...`).",
                      "pattern": "^org_"
                    },
                    "orgName": {
                      "type": "string",
                      "description": "The organization's display name, or an empty string if unavailable."
                    },
                    "inviterName": {
                      "type": "string",
                      "description": "The inviter's chosen display name, or an empty string if none."
                    },
                    "role": {
                      "type": "string",
                      "enum": [
                        "guest",
                        "member",
                        "developer",
                        "admin",
                        "owner"
                      ],
                      "description": "The member's organization role: `guest`, `member`, `developer`, `admin` or `owner`. Guest has no organization permissions and cannot list members, domains or roles."
                    },
                    "containers": {
                      "type": "integer",
                      "description": "How many containers it gives access to."
                    },
                    "expiresAt": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "alreadyMember": {
                      "type": "boolean",
                      "description": "They're in the organization already; accepting adds the access."
                    }
                  },
                  "required": [
                    "orgId",
                    "orgName",
                    "inviterName",
                    "role",
                    "containers",
                    "expiresAt",
                    "alreadyMember"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "500": {
            "$ref": "#/components/responses/Error"
          },
          "410": {
            "description": "This invitation link didn't work. Check you copied all of it, or ask whoever sent it for a new one. (`invalid`; used, revoked, expired or its maker can no longer give what it offers.)",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/v1/k8/token": {
      "post": {
        "tags": [
          "K8"
        ],
        "operationId": "k8Token",
        "summary": "Get a delegated token for K8",
        "description": "Mints a short-lived token (15 minutes) for one of K8 HQ's assistants to act for the person in one organization: `k8hq-k8-admin` (K8 Admin, which helps set things up and may only read) or `k8hq-k8-messages` (K8 Messages, which reads messages; only where the organization allows it). The token is accepted only on its assistant's allowlist of calls, in that organization, while the person may still use K8 there. Only a person's own session can mint one.\n\nAfter the web client cutover, browser requests need `K8hq-Client: web/<build>; storage=4` with a build at least the configured minimum and storage version 4 or later. Older clients receive 426 `client_outdated` and must reload K8 HQ. Browser delegations also keep the client version declared when they were issued; delegations issued without a compatible version must be replaced.",
        "security": [
          {
            "session": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/contentSha256"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string",
                    "description": "The organization (`org_...`).",
                    "pattern": "^org_"
                  },
                  "audience": {
                    "type": "string",
                    "enum": [
                      "k8hq-k8-admin",
                      "k8hq-k8-messages"
                    ]
                  }
                },
                "required": [
                  "orgId",
                  "audience"
                ]
              },
              "example": {
                "orgId": "org_01J...",
                "audience": "k8hq-k8-admin"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The token.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "token": {
                      "type": "string",
                      "description": "Send it as `x-k8hq-token` on the assistant's calls."
                    },
                    "expiresAt": {
                      "type": "string",
                      "format": "date-time"
                    }
                  },
                  "required": [
                    "token",
                    "expiresAt"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "K8 isn't available to them there, or K8 Messages is off (`forbidden`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/Error"
          },
          "400": {
            "description": "No organization, or an unknown audience (`invalid`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "404": {
            "description": "They aren't a member (`not_found`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "426": {
            "description": "K8 HQ has been updated. Reload this page.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/v1/keys": {
      "get": {
        "tags": [
          "User keys"
        ],
        "operationId": "getKeyResource",
        "summary": "Get the person's key",
        "description": "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.",
        "security": [
          {
            "session": []
          }
        ],
        "parameters": [],
        "responses": {
          "200": {
            "description": "The key record, or null.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "key": {
                      "oneOf": [
                        {
                          "$ref": "#/components/schemas/UserKey"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "serverCopy": {
                      "oneOf": [
                        {
                          "$ref": "#/components/schemas/ServerCopy"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "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."
                    },
                    "fingerprint": {
                      "type": "string",
                      "pattern": "^[0-9a-f]{16}$",
                      "description": "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`)."
                    },
                    "keyGeneration": {
                      "type": "integer",
                      "minimum": 1,
                      "description": "With key replacement on: the key's generation, 1 for a first key and one more for each replacement."
                    },
                    "replacedAt": {
                      "type": "string",
                      "format": "date-time",
                      "description": "With key replacement on: when this key replaced the one before (RFC 3339); absent for a first key."
                    },
                    "exposed": {
                      "type": "boolean",
                      "description": "With key replacement on: whether this key was reported as possibly exposed (design note 0032 B.2). Replace it if so."
                    }
                  },
                  "required": [
                    "key"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "500": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "description": "Key records are disabled on this service (`not_found`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "426": {
            "description": "K8 HQ has been updated. Reload this page.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      },
      "put": {
        "tags": [
          "User keys"
        ],
        "operationId": "createKeyResource",
        "summary": "Create the person's key",
        "description": "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.",
        "security": [
          {
            "session": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/contentSha256"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UserKey"
              },
              "example": {
                "x25519": "base64...",
                "ed25519": "base64...",
                "wraps": [
                  {
                    "id": "recovery",
                    "kind": "recovery",
                    "salt": "base64...",
                    "wrapped": "base64..."
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Stored.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Ok"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedStepUp"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "500": {
            "$ref": "#/components/responses/Error"
          },
          "400": {
            "description": "The record's shape is wrong (`invalid`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "409": {
            "description": "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`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "405": {
            "description": "Method not allowed. The Allow header lists supported methods.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "426": {
            "description": "K8 HQ has been updated. Reload this page.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        },
        "x-k8hq-step-up": true
      }
    },
    "/v1/keys/server-copy": {
      "post": {
        "tags": [
          "User keys"
        ],
        "operationId": "releaseServerCopy",
        "summary": "Unlock with K8 HQ's copy of the key",
        "description": "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](#enableServerCopyResource)). 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](#loginFinish), or from a [passkey confirmation](#stepUpFinish) 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.",
        "security": [
          {
            "session": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/contentSha256"
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "ticket": {
                    "type": "string",
                    "description": "The release ticket (`k8hq_rel_...`).",
                    "pattern": "^k8hq_rel_"
                  }
                }
              },
              "example": {
                "ticket": "k8hq_rel_..."
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The key.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "bundle": {
                      "type": "string",
                      "contentEncoding": "base64",
                      "description": "The private keys, 64 bytes in standard base64: the X25519 private key, then the Ed25519 seed. They match the account's public keys."
                    }
                  },
                  "required": [
                    "bundle"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedStepUp"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "K8 HQ keeps no copy of this person's key (`no_server_copy`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "409": {
            "description": "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`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "Too many releases this hour (`rate_limited`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/Error"
          },
          "426": {
            "description": "K8 HQ has been updated. Reload this page.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        },
        "x-k8hq-step-up": true
      },
      "put": {
        "tags": [
          "User keys"
        ],
        "operationId": "enableServerCopyResource",
        "summary": "Turn on K8 HQ's copy of the key",
        "description": "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](#releaseServerCopy)). 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`).",
        "security": [
          {
            "session": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/contentSha256"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "bundle": {
                    "type": "string",
                    "contentEncoding": "base64",
                    "description": "The unlocked private keys, 64 bytes in standard base64: the X25519 private key, then the Ed25519 seed."
                  }
                },
                "required": [
                  "bundle"
                ]
              },
              "example": {
                "bundle": "base64..."
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Turned on.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "serverCopy": {
                      "$ref": "#/components/schemas/ServerCopy"
                    }
                  },
                  "required": [
                    "serverCopy"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "The bundle is missing, the wrong size or doesn't belong to this account (`invalid`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedStepUp"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "description": "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`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "Too many turn-ons and releases this hour (`rate_limited`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/Error"
          },
          "405": {
            "description": "Method not allowed. The Allow header lists supported methods.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "426": {
            "description": "K8 HQ has been updated. Reload this page.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        },
        "x-k8hq-step-up": true
      },
      "delete": {
        "tags": [
          "User keys"
        ],
        "operationId": "disableServerCopyResource",
        "summary": "Turn off K8 HQ's copy of the key",
        "description": "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`).\n\nNeeds 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.",
        "security": [
          {
            "session": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/contentSha256"
          }
        ],
        "responses": {
          "200": {
            "description": "Off (or already off).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Ok"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedConfirm"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "description": "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`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/Error"
          },
          "405": {
            "description": "Method not allowed. The Allow header lists supported methods.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "426": {
            "description": "K8 HQ has been updated. Reload this page.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        },
        "x-k8hq-step-up": true,
        "x-k8hq-confirm": "server_copy.disable"
      }
    },
    "/v1/keys/replace": {
      "post": {
        "tags": [
          "User keys"
        ],
        "operationId": "replaceKey",
        "summary": "Replace the person's key",
        "description": "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.",
        "security": [
          {
            "session": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/contentSha256"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "`<operationId>:key-replace`."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "schemaVersion",
                  "operationId",
                  "previous",
                  "record"
                ],
                "properties": {
                  "schemaVersion": {
                    "type": "integer",
                    "const": 1
                  },
                  "operationId": {
                    "type": "string",
                    "pattern": "^akr_[0-9A-HJKMNP-TV-Z]{26}$"
                  },
                  "previous": {
                    "type": "object",
                    "additionalProperties": false,
                    "required": [
                      "x25519",
                      "ed25519"
                    ],
                    "properties": {
                      "x25519": {
                        "type": "string",
                        "pattern": "^[A-Za-z0-9_-]+$",
                        "description": "Unpadded base64url."
                      },
                      "ed25519": {
                        "type": "string",
                        "pattern": "^[A-Za-z0-9_-]+$",
                        "description": "Unpadded base64url."
                      }
                    }
                  },
                  "record": {
                    "type": "object",
                    "additionalProperties": false,
                    "required": [
                      "x25519",
                      "ed25519",
                      "wraps"
                    ],
                    "properties": {
                      "suite": {
                        "type": "object"
                      },
                      "x25519": {
                        "type": "string",
                        "pattern": "^[A-Za-z0-9_-]+$",
                        "description": "Unpadded base64url."
                      },
                      "ed25519": {
                        "type": "string",
                        "pattern": "^[A-Za-z0-9_-]+$",
                        "description": "Unpadded base64url."
                      },
                      "wraps": {
                        "type": "array",
                        "minItems": 1,
                        "maxItems": 20,
                        "items": {
                          "type": "object",
                          "additionalProperties": false,
                          "required": [
                            "id",
                            "kind",
                            "salt",
                            "wrapped"
                          ],
                          "properties": {
                            "id": {
                              "type": "string"
                            },
                            "kind": {
                              "type": "string",
                              "enum": [
                                "prf",
                                "recovery"
                              ]
                            },
                            "credentialId": {
                              "type": "string"
                            },
                            "salt": {
                              "type": "string",
                              "pattern": "^[A-Za-z0-9_-]+$",
                              "description": "Unpadded base64url."
                            },
                            "wrapped": {
                              "type": "string",
                              "pattern": "^[A-Za-z0-9_-]+$",
                              "description": "Unpadded base64url."
                            }
                          }
                        }
                      }
                    }
                  }
                }
              },
              "example": {
                "schemaVersion": 1,
                "operationId": "akr_01M4KN0000000000000000000A",
                "previous": {
                  "x25519": "base64url...",
                  "ed25519": "base64url..."
                },
                "record": {
                  "x25519": "base64url...",
                  "ed25519": "base64url...",
                  "wraps": [
                    {
                      "id": "recovery",
                      "kind": "recovery",
                      "salt": "base64url...",
                      "wrapped": "base64url..."
                    }
                  ]
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Replaced (or the same replacement replayed).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "schemaVersion",
                    "fingerprint",
                    "previousFingerprint",
                    "replayed"
                  ],
                  "properties": {
                    "schemaVersion": {
                      "type": "integer",
                      "const": 1
                    },
                    "fingerprint": {
                      "type": "string",
                      "pattern": "^[0-9a-f]{16}$"
                    },
                    "previousFingerprint": {
                      "type": "string",
                      "pattern": "^[0-9a-f]{16}$"
                    },
                    "replayed": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "The body, the Idempotency-Key or the new record isn't valid, or the new key equals the old one (`invalid`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedStepUp"
          },
          "403": {
            "description": "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`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "404": {
            "description": "Key replacement is off (`not_found`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "409": {
            "description": "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`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/Error"
          },
          "503": {
            "description": "Key replacement isn't available yet: K8 HQ hasn't finished recording who owns each key (`unavailable`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "426": {
            "description": "K8 HQ has been updated. Reload this page.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        },
        "x-k8hq-step-up": true
      }
    },
    "/v1/login/begin": {
      "post": {
        "tags": [
          "Sign-up and sign-in"
        ],
        "operationId": "loginBegin",
        "summary": "Start signing in",
        "description": "Starts a passkey sign-in. No username: the person picks one of their K8 HQ passkeys in the browser's prompt. Pass `options` to `navigator.credentials.get()`; send the result to [Finish signing in](#loginFinish).",
        "security": [],
        "parameters": [
          {
            "$ref": "#/components/parameters/contentSha256"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {},
                "description": "Send `{}`: the call takes nothing."
              },
              "example": {}
            }
          }
        },
        "responses": {
          "200": {
            "description": "The ceremony's options. Pass `options` to the browser, then send its answer to the matching finish call within 5 minutes.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Challenge"
                }
              }
            }
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "500": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/v1/login/finish": {
      "post": {
        "tags": [
          "Sign-up and sign-in"
        ],
        "operationId": "loginFinish",
        "summary": "Finish signing in",
        "description": "Checks the passkey's answer and starts a session. A sign-in from a network the account hasn't used in 90 days writes an account notice (see [Notices](#notices)). Each failure counts against the caller's address: 20 in 15 minutes and it gets 429 until the window passes. `policiesNeeded` lists the Terms of Service or Privacy Policy versions that took effect since the person last accepted one: the web app asks them to accept before going on ([Accept policy versions](#acceptPolicies)). Access tokens, IMAP and SMTP never ask.",
        "security": [],
        "parameters": [
          {
            "$ref": "#/components/parameters/contentSha256"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "challengeId": {
                    "type": "string"
                  },
                  "credential": {
                    "type": "object",
                    "description": "The passkey's answer: the `PublicKeyCredential` from the browser as JSON (`id`, `rawId`, `type`, `response` with binary fields as base64url; `PublicKeyCredential.toJSON()` gives this shape)."
                  },
                  "device": {
                    "type": "string",
                    "description": "A short name for the device, shown in the person's sessions and notices (`Mac`, `iPhone`, ...).",
                    "maxLength": 100
                  },
                  "partitionSecret": {
                    "type": "string",
                    "pattern": "^[A-Za-z0-9_-]{43}$",
                    "description": "This browser's secret for signing out: 32 random bytes in base64url (no padding), made once per browser storage partition and kept there. K8 HQ keeps only a hash of it, so knowing a browser's ID never lets another sign-in join that browser. Sent with every sign-in from the web app, so Forget this browser can end them all (`DELETE /v1/account/browser-sessions`); the session keeps it through refreshes. Leave it out from anything but the web app. A value that isn't one is refused (`invalid`) before the passkey answer is used."
                  }
                },
                "required": [
                  "challengeId",
                  "credential"
                ]
              },
              "example": {
                "challengeId": "chl_01J...",
                "credential": {
                  "id": "...",
                  "rawId": "...",
                  "type": "public-key",
                  "response": {
                    "clientDataJSON": "...",
                    "authenticatorData": "...",
                    "signature": "...",
                    "userHandle": "..."
                  }
                },
                "device": "iPhone"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Signed in: the account and its new session.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "userId": {
                      "type": "string",
                      "description": "The account (`usr_...`).",
                      "pattern": "^usr_"
                    },
                    "tokens": {
                      "$ref": "#/components/schemas/Tokens"
                    },
                    "policiesNeeded": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/PolicyVersion"
                      },
                      "description": "Versions to accept before using the web app; empty when none."
                    },
                    "policiesFirst": {
                      "type": "boolean",
                      "description": "The person has accepted no version yet: ask them to review and accept, rather than saying the policies were updated."
                    },
                    "releaseTicket": {
                      "type": "string",
                      "description": "For people with K8 HQ's copy of their key: a release ticket for [Unlock with K8 HQ's copy](#releaseServerCopy), single use, valid 5 minutes, for this session only."
                    },
                    "recovery": {
                      "type": [
                        "object",
                        "null"
                      ],
                      "properties": {
                        "recoveryId": {
                          "type": "string",
                          "description": "The waiting recovery."
                        },
                        "destinationId": {
                          "type": "string",
                          "description": "The recovery address destination."
                        },
                        "startedAt": {
                          "type": "string",
                          "description": "When recovery started."
                        },
                        "readyAt": {
                          "type": "string",
                          "description": "When the wait ends."
                        },
                        "network": {
                          "type": "string",
                          "description": "The requesting network."
                        },
                        "country": {
                          "type": "string",
                          "description": "The requesting country."
                        }
                      },
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "userId",
                    "tokens"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "500": {
            "$ref": "#/components/responses/Error"
          },
          "400": {
            "description": "Malformed, or the challenge is unknown, expired or used, or the passkey's answer couldn't be read (`invalid`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "401": {
            "description": "The passkey isn't recognized, or looks cloned and is refused (`unauthenticated`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "Too many failed passkey ceremonies from this address (`rate_limited`); wait 15 minutes.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "409": {
            "description": "This browser was signed out while this sign-in completed (`browser_changed`), so no session started; sign in again.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/v1/members/check": {
      "get": {
        "tags": [
          "Members"
        ],
        "operationId": "checkMemberChangeQuery",
        "summary": "Check a people change",
        "description": "Whether an invite, a role change or a removal would be allowed for the person asking, with the same checks as [inviting](#createInviteResource), [changing a role](#setRoleResource) and [removing a member](#removeMemberResource), changing nothing and needing no passkey. K8 Admin asks it before proposing a change for the person to approve (design note 0010); the change is checked again when it's made. Today's invite limit is checked only then. Send the inputs as query parameters, with no request body. Unknown parameters and repeated single values are refused. The query string may be at most 8192 bytes. Repeat `containerIds` for each inbox.",
        "security": [
          {
            "session": []
          },
          {
            "delegated": []
          }
        ],
        "parameters": [
          {
            "name": "orgId",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "description": "The organization (`org_...`).",
              "pattern": "^org_"
            },
            "example": "org_01J..."
          },
          {
            "name": "action",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "invite",
                "role",
                "remove"
              ],
              "description": "`invite` (role, containerIds), `role` (memberId, role) or `remove` (memberId)."
            },
            "example": "role"
          },
          {
            "name": "memberId",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "example": "mem_01J..."
          },
          {
            "name": "role",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "guest",
                "member",
                "developer",
                "admin",
                "owner"
              ],
              "description": "The member's organization role: `guest`, `member`, `developer`, `admin` or `owner`. Guest has no organization permissions and cannot list members, domains or roles."
            },
            "example": "admin"
          },
          {
            "name": "containerIds",
            "in": "query",
            "required": false,
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "description": "Invites: inboxes the invited person would get access to."
            },
            "style": "form",
            "explode": true
          }
        ],
        "responses": {
          "200": {
            "description": "Allowed. `pending`: it would wait for an owner's approval (design note 0009, 3.2). `role`: the member's current role (role changes).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "pending": {
                      "type": "boolean"
                    },
                    "role": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "pending"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Unknown action or role, or the request is malformed (`invalid`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "description": "The organization is read-only (`read_only`, design note 0024): it has been out of credit for 60 days, so nobody can be invited to it or join it until an owner adds credit.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "403": {
            "description": "Their role or permissions don't allow it (`forbidden`); or a delegated token for another organization, or a foreign origin.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "404": {
            "description": "Not a member, or no such member (`not_found`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "409": {
            "description": "It would leave a container nobody can open (`conflict`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/Error"
          },
          "503": {
            "description": "Whether K8 is available couldn't be checked (`unavailable`); retry.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/v1/notices": {
      "post": {
        "tags": [
          "Notices"
        ],
        "operationId": "notices",
        "summary": "List account notices",
        "description": "The person's account notices (design note 0012), newest first: passkeys added or removed, sign-ins from new networks, tokens used from new networks, invitations used, removal from an organization. Only the person sees them; there are no parameters naming anyone. `unread` counts the unarchived ones on this page.",
        "security": [
          {
            "session": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/contentSha256"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "cursor": {
                    "type": "string",
                    "description": "`nextCursor` from the previous page.",
                    "pattern": "^[0-9]{20}$"
                  },
                  "limit": {
                    "type": "integer",
                    "description": "Up to 100; 50 by default.",
                    "maximum": 100
                  }
                }
              },
              "example": {
                "limit": 50
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "A page of notices.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "notices": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Notice"
                      }
                    },
                    "unread": {
                      "type": "integer"
                    },
                    "nextCursor": {
                      "type": "string",
                      "description": "Present while there are more."
                    }
                  },
                  "required": [
                    "notices",
                    "unread"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "500": {
            "$ref": "#/components/responses/Error"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          }
        }
      }
    },
    "/v1/notices/link": {
      "post": {
        "tags": [
          "Notices"
        ],
        "operationId": "openNoticeLink",
        "summary": "Open a notice link",
        "description": "Resolves a link from a copy of a notice (`https://app.k8hq.com/n/<link>`). It opens only for the signed-in person it was made for: anyone else, and any link that was changed or made up, gets `not_for_you`. Links never act and never sign in.",
        "security": [
          {
            "session": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/contentSha256"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "link": {
                    "type": "string",
                    "description": "The part after `/n/`."
                  }
                },
                "required": [
                  "link"
                ]
              },
              "example": {
                "link": "42-..."
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "What it names.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LinkTarget"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "500": {
            "$ref": "#/components/responses/Error"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "404": {
            "description": "Not a notice for this account (`not_for_you`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/v1/passkeys": {
      "get": {
        "tags": [
          "Passkeys"
        ],
        "operationId": "listPasskeysResource",
        "summary": "List passkeys",
        "description": "The person's passkeys, oldest first.",
        "security": [
          {
            "session": []
          }
        ],
        "parameters": [],
        "responses": {
          "200": {
            "description": "The passkeys.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "passkeys": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Passkey"
                      }
                    }
                  },
                  "required": [
                    "passkeys"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "500": {
            "$ref": "#/components/responses/Error"
          },
          "405": {
            "description": "Method not allowed. The Allow header lists supported methods.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/v1/passkeys/begin": {
      "post": {
        "tags": [
          "Passkeys"
        ],
        "operationId": "passkeyBegin",
        "summary": "Add a passkey",
        "description": "Starts registering another passkey for the signed-in person (ones they already have are excluded). Pass `options` to `navigator.credentials.create()` and send the result to [Finish adding a passkey](#passkeyFinish).\n\nNeeds a passkey confirmation of this change (`x-k8hq-confirm`: `passkey.add`). Until confirmations are enforced, a passkey sign-in in the last five minutes also works.",
        "security": [
          {
            "session": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/contentSha256"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {},
                "description": "Send `{}`: the call takes nothing."
              },
              "example": {}
            }
          }
        },
        "responses": {
          "200": {
            "description": "The ceremony's options. Pass `options` to the browser, then send its answer to the matching finish call within 5 minutes.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Challenge"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedConfirm"
          },
          "403": {
            "description": "Not allowed (`forbidden`); or the confirmation isn't this session's (`confirmation_invalid`), or an API token or assistant asked (`needs_person`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "409": {
            "description": "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`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/Error"
          }
        },
        "x-k8hq-step-up": true,
        "x-k8hq-confirm": "passkey.add"
      }
    },
    "/v1/passkeys/finish": {
      "post": {
        "tags": [
          "Passkeys"
        ],
        "operationId": "passkeyFinish",
        "summary": "Finish adding a passkey",
        "description": "Stores the new passkey; it can sign in at once. The person gets an account notice.\n\nThe registration challenge must come from a confirmed passkey addition. Until confirmations are enforced, a recent passkey sign-in also works.",
        "security": [
          {
            "session": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/contentSha256"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "challengeId": {
                    "type": "string"
                  },
                  "credential": {
                    "type": "object",
                    "description": "The passkey's answer: the `PublicKeyCredential` from the browser as JSON (`id`, `rawId`, `type`, `response` with binary fields as base64url; `PublicKeyCredential.toJSON()` gives this shape)."
                  }
                },
                "required": [
                  "challengeId",
                  "credential"
                ]
              },
              "example": {
                "challengeId": "chl_01J...",
                "credential": {
                  "id": "...",
                  "type": "public-key",
                  "response": {}
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Added.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Ok"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedConfirm"
          },
          "403": {
            "description": "Not allowed (`forbidden`); or the confirmation isn't this session's (`confirmation_invalid`), or an API token or assistant asked (`needs_person`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/Error"
          },
          "400": {
            "description": "Malformed, or the challenge is unknown, expired or used, or the passkey's answer couldn't be read (`invalid`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "409": {
            "description": "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`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        },
        "x-k8hq-step-up": true,
        "x-k8hq-confirm": "passkey.add"
      }
    },
    "/v1/policies": {
      "get": {
        "tags": [
          "Policies"
        ],
        "operationId": "listPoliciesResource",
        "summary": "List policy versions",
        "description": "The current versions of K8 HQ's Terms of Service and Privacy Policy, any published ones that haven't taken effect yet (everyone is told 30 days ahead), and every version ever published, each with its text's hash. No sign-in needed. Sign-up sends the current ones in `accepted`.",
        "security": [],
        "parameters": [],
        "responses": {
          "200": {
            "description": "The versions.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "current": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/PolicyVersion"
                      }
                    },
                    "upcoming": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/PolicyVersion"
                      }
                    },
                    "published": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/PolicyVersion"
                      }
                    }
                  },
                  "required": [
                    "current",
                    "upcoming",
                    "published"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "current": [
                    {
                      "doc": "terms",
                      "title": "Terms of Service",
                      "version": "2026-10-16",
                      "effective": "2026-10-16",
                      "url": "https://k8hq.com/terms/2026-10-16/",
                      "summary": "The first numbered version.",
                      "sha256": "0000000000000000000000000000000000000000000000000000000000000000"
                    },
                    {
                      "doc": "privacy",
                      "title": "Privacy Policy",
                      "version": "2026-10-16",
                      "effective": "2026-10-16",
                      "url": "https://k8hq.com/privacy/2026-10-16/",
                      "summary": "The first numbered version.",
                      "sha256": "0000000000000000000000000000000000000000000000000000000000000000"
                    }
                  ],
                  "upcoming": [],
                  "published": [
                    {
                      "doc": "terms",
                      "title": "Terms of Service",
                      "version": "2026-10-16",
                      "effective": "2026-10-16",
                      "url": "https://k8hq.com/terms/2026-10-16/",
                      "summary": "The first numbered version.",
                      "sha256": "0000000000000000000000000000000000000000000000000000000000000000"
                    },
                    {
                      "doc": "privacy",
                      "title": "Privacy Policy",
                      "version": "2026-10-16",
                      "effective": "2026-10-16",
                      "url": "https://k8hq.com/privacy/2026-10-16/",
                      "summary": "The first numbered version.",
                      "sha256": "0000000000000000000000000000000000000000000000000000000000000000"
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/Error"
          },
          "405": {
            "description": "Method not allowed; Allow lists supported methods.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/v1/policies/accept": {
      "post": {
        "tags": [
          "Policies"
        ],
        "operationId": "acceptPolicies",
        "summary": "Accept policy versions",
        "description": "Records that the person accepts these versions, with the time, IP address and browser. Each acceptance is recorded once and never changed; accepting a version again changes nothing. Not available to an assistant's delegated token.",
        "security": [
          {
            "session": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/contentSha256"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "accepted": {
                    "$ref": "#/components/schemas/Accepted"
                  }
                },
                "required": [
                  "accepted"
                ]
              },
              "example": {
                "accepted": {
                  "terms": "2026-11-20"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Recorded; `needed` is what's still left to accept.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "needed": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/PolicyVersion"
                      }
                    }
                  },
                  "required": [
                    "needed"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Nothing named (`policy_acceptance_required`), or malformed (`invalid`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "description": "A version that isn't current or published, or an unknown document (`policy_outdated`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/v1/refresh": {
      "post": {
        "tags": [
          "Sessions"
        ],
        "operationId": "refresh",
        "summary": "Refresh a session",
        "description": "Exchanges a refresh token for a new access token and a new refresh token. Each refresh token works once: presenting one again (or two requests racing with the same one) ends the whole session, since it was copied. A refreshed access token keeps the session's last passkey confirmation time, so it doesn't satisfy a recent-passkey check. A successful refresh from a network the account has not used in 90 days creates the same new-network security notice as a sign-in. Repeated use of a known network does not create another notice. Notice failures are logged without failing the refresh.",
        "security": [],
        "parameters": [
          {
            "$ref": "#/components/parameters/contentSha256"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "refreshToken": {
                    "type": "string"
                  }
                },
                "required": [
                  "refreshToken"
                ]
              },
              "example": {
                "refreshToken": "..."
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "New tokens; keep the new refresh token, the old one is spent.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "tokens": {
                      "$ref": "#/components/schemas/Tokens"
                    }
                  },
                  "required": [
                    "tokens"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "500": {
            "$ref": "#/components/responses/Error"
          },
          "400": {
            "description": "No refresh token (`invalid`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "401": {
            "description": "The refresh token is unknown, spent or its session ended (`unauthenticated`): sign in again.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/v1/signup/begin": {
      "post": {
        "tags": [
          "Sign-up and sign-in"
        ],
        "operationId": "signupBegin",
        "summary": "Start signing up",
        "description": "Starts creating an account from a passkey alone: no email address or password, just an optional display name. Signing up needs an invitation: a sign-up invitation's secret (`k8hq_sinv_...`, from a link `https://app.k8hq.com/#invite=...`) or an organization invite's (`k8hq_inv_...`, from `#join=...`), checked here, before any passkey is made. The invitation is used up only when the account is created.\n\nPass `options` to `navigator.credentials.create()`; send the result to [Finish signing up](#signupFinish).\n\nSigning up also needs the current [Terms of Service and Privacy Policy](https://api.k8hq.com/auth/docs/policies#listPoliciesResource): send the versions the person agreed to in `accepted`. They're recorded with the account when it's created, with the time, IP address and browser.",
        "security": [],
        "parameters": [
          {
            "$ref": "#/components/parameters/contentSha256"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "invite": {
                    "type": "string",
                    "description": "The invitation's secret."
                  },
                  "displayName": {
                    "type": "string",
                    "description": "The person's name as others in their organizations see it; optional, up to 100 characters.",
                    "maxLength": 100
                  },
                  "accepted": {
                    "$ref": "#/components/schemas/Accepted"
                  },
                  "attribution": {
                    "$ref": "#/components/schemas/Attribution"
                  }
                },
                "required": [
                  "invite",
                  "accepted"
                ]
              },
              "example": {
                "displayName": "Dee Porter",
                "invite": "k8hq_sinv_EXAMPLE",
                "accepted": {
                  "terms": "2026-10-16",
                  "privacy": "2026-10-16"
                },
                "attribution": {
                  "utm_source": "newsletter",
                  "utm_campaign": "launch",
                  "referrer": "news.example.com",
                  "landing": "/"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The ceremony's options. Pass `options` to the browser, then send its answer to the matching finish call within 5 minutes.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Challenge"
                }
              }
            }
          },
          "402": {
            "description": "The organization is read-only (`read_only`, design note 0024): it has been out of credit for 60 days, so nobody can be invited to it or join it until an owner adds credit.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "403": {
            "description": "No invitation (`invite_required`), or an organization invite from an organization without a proven domain (`org_invite_no_domain`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/Error"
          },
          "400": {
            "description": "The display name is over 100 characters (`invalid`), or `accepted` doesn't name every current version (`policy_acceptance_required`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "410": {
            "description": "The invitation was used, revoked or has expired (`invite_used`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "The organization has signed up as many new people as it may today (`org_signup_limit`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "409": {
            "description": "A version in `accepted` isn't the current one, or isn't published (`policy_outdated`): fetch [the current versions](#listPoliciesResource) and ask again.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/v1/signup/finish": {
      "post": {
        "tags": [
          "Sign-up and sign-in"
        ],
        "operationId": "signupFinish",
        "summary": "Finish signing up",
        "description": "Checks the new passkey, creates the account, uses up the invitation and starts a session. The account's only credential is this passkey: add another soon ([Add a passkey](#passkeyBegin)), and keep a recovery kit for zero-access inboxes. The policy versions accepted when it began are recorded now, with this request's IP address and user agent; a version that stopped being current since then is refused.",
        "security": [],
        "parameters": [
          {
            "$ref": "#/components/parameters/contentSha256"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "challengeId": {
                    "type": "string"
                  },
                  "credential": {
                    "type": "object",
                    "description": "The passkey's answer: the `PublicKeyCredential` from the browser as JSON (`id`, `rawId`, `type`, `response` with binary fields as base64url; `PublicKeyCredential.toJSON()` gives this shape)."
                  },
                  "device": {
                    "type": "string",
                    "description": "A short name for the device, shown in the person's sessions and notices (`Mac`, `iPhone`, ...).",
                    "maxLength": 100
                  },
                  "partitionSecret": {
                    "type": "string",
                    "pattern": "^[A-Za-z0-9_-]{43}$",
                    "description": "This browser's secret for signing out: 32 random bytes in base64url (no padding), made once per browser storage partition and kept there. K8 HQ keeps only a hash of it, so knowing a browser's ID never lets another sign-in join that browser. Sent with every sign-in from the web app, so Forget this browser can end them all (`DELETE /v1/account/browser-sessions`); the session keeps it through refreshes. Leave it out from anything but the web app. A value that isn't one is refused (`invalid`) before the passkey answer is used."
                  }
                },
                "required": [
                  "challengeId",
                  "credential"
                ]
              },
              "example": {
                "challengeId": "chl_01J...",
                "credential": {
                  "id": "...",
                  "rawId": "...",
                  "type": "public-key",
                  "response": {
                    "clientDataJSON": "...",
                    "attestationObject": "..."
                  }
                },
                "device": "Mac"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Signed in: the account and its new session.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "userId": {
                      "type": "string",
                      "description": "The account (`usr_...`).",
                      "pattern": "^usr_"
                    },
                    "tokens": {
                      "$ref": "#/components/schemas/Tokens"
                    }
                  },
                  "required": [
                    "userId",
                    "tokens"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "402": {
            "description": "The organization is read-only (`read_only`, design note 0024): it has been out of credit for 60 days, so nobody can be invited to it or join it until an owner adds credit.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "403": {
            "description": "The invitation is no longer enough (`invite_required`, `org_invite_no_domain`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/Error"
          },
          "400": {
            "description": "Malformed, or the challenge is unknown, expired or used, or the passkey's answer couldn't be read (`invalid`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "410": {
            "description": "The invitation was used meanwhile (`invite_used`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "Too many failed ceremonies from this address (`rate_limited`), or the organization's sign-ups for today are used (`org_signup_limit`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "409": {
            "description": "A policy version accepted at the start isn't current any more (`policy_outdated`): start again. Or: This browser was signed out while this sign-in completed (`browser_changed`), so no session started; sign in again.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/v1/stepup/begin": {
      "post": {
        "tags": [
          "Sessions"
        ],
        "operationId": "stepUpBegin",
        "summary": "Start a passkey confirmation",
        "description": "Asks the signed-in person to confirm with one of their own passkeys, for actions that need a recent one (marked on each call; they answer 401 `step_up_required` otherwise). Pass `options` to `navigator.credentials.get()` and send the answer to [Finish a passkey confirmation](#stepUpFinish).",
        "security": [
          {
            "session": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/contentSha256"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {},
                "description": "Send `{}`: the call takes nothing."
              },
              "example": {}
            }
          }
        },
        "responses": {
          "200": {
            "description": "The ceremony's options. Pass `options` to the browser, then send its answer to the matching finish call within 5 minutes.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Challenge"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "500": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/v1/stepup/finish": {
      "post": {
        "tags": [
          "Sessions"
        ],
        "operationId": "stepUpFinish",
        "summary": "Finish a passkey confirmation",
        "description": "Checks the passkey (it must be the same person's) and returns a new access token for the same session, confirmed now: for the next 5 minutes it passes recent-passkey checks here, in the Setup API and in the content API. The refresh token is unchanged.",
        "security": [
          {
            "session": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/contentSha256"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "challengeId": {
                    "type": "string"
                  },
                  "credential": {
                    "type": "object",
                    "description": "The passkey's answer: the `PublicKeyCredential` from the browser as JSON (`id`, `rawId`, `type`, `response` with binary fields as base64url; `PublicKeyCredential.toJSON()` gives this shape)."
                  },
                  "unlock": {
                    "type": "boolean",
                    "description": "Ask for a release ticket (the step-up is to unlock the key with K8 HQ's copy)."
                  }
                },
                "required": [
                  "challengeId",
                  "credential"
                ]
              },
              "example": {
                "challengeId": "chl_01J...",
                "credential": {
                  "id": "...",
                  "type": "public-key",
                  "response": {}
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "A new access token (no refresh token).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "tokens": {
                      "$ref": "#/components/schemas/Tokens"
                    },
                    "releaseTicket": {
                      "type": "string",
                      "description": "For people with K8 HQ's copy of their key: a release ticket for [Unlock with K8 HQ's copy](#releaseServerCopy), single use, valid 5 minutes, for this session only."
                    }
                  },
                  "required": [
                    "tokens"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "401": {
            "description": "No session or it expired (`unauthenticated`), or the passkey isn't recognized or isn't theirs.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "500": {
            "$ref": "#/components/responses/Error"
          },
          "400": {
            "description": "Malformed, or the challenge is unknown, expired or used, or the passkey's answer couldn't be read (`invalid`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "Too many failed passkey ceremonies from this address (`rate_limited`); wait 15 minutes.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/v1/passkeys/{id}": {
      "delete": {
        "tags": [
          "Passkeys"
        ],
        "operationId": "removePasskeyResource",
        "summary": "Remove a passkey",
        "description": "Removes a passkey, and any copy of the person's key sealed with it. The last passkey can't be removed (the account would be unreachable). The person gets an account notice.\n\nNeeds a passkey confirmation of this change (`x-k8hq-confirm`: `passkey.remove`). Until confirmations are enforced, a passkey sign-in in the last five minutes also works.",
        "security": [
          {
            "session": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/contentSha256"
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Passkey ID.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Removed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Ok"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedConfirm"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "500": {
            "$ref": "#/components/responses/Error"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "404": {
            "description": "No such passkey (`not_found`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "409": {
            "description": "It's the only passkey; add another first, or your account changed meanwhile (another passkey, session or name change won the race) and nothing was removed: reload and try again (`conflict`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "405": {
            "description": "Method not allowed. The Allow header lists supported methods.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        },
        "x-k8hq-step-up": true,
        "x-k8hq-confirm": "passkey.remove"
      }
    },
    "/v1/account/tokens": {
      "get": {
        "tags": [
          "Access tokens"
        ],
        "operationId": "listTokensResource",
        "summary": "List my tokens",
        "description": "The person's access tokens in every organization (never their secrets), and per organization what they may give a new one. Bounded HTTP descendants are returned in pages of at most 8 evaluated index rows. Follow nextCursor even when a page has no matching tokens. Send it as cursor on the same listing; each agent page rechecks current authority. Legacy token metadata appears on the first page.",
        "security": [
          {
            "session": []
          }
        ],
        "parameters": [
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 2048
            },
            "description": "Continuation for this exact user, organization, app and listing action; grants no authority."
          },
          {
            "name": "orgId",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^org_"
            },
            "description": "Agent requests select one organization. Required when the issuer covers multiple organizations; humans retain their account-wide listing."
          }
        ],
        "responses": {
          "200": {
            "description": "Their tokens and organizations.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "tokens": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Token"
                      }
                    },
                    "orgs": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "orgId": {
                            "type": "string",
                            "description": "The organization (`org_...`).",
                            "pattern": "^org_"
                          },
                          "memberId": {
                            "type": "string"
                          },
                          "role": {
                            "type": "string",
                            "enum": [
                              "guest",
                              "member",
                              "developer",
                              "admin",
                              "owner"
                            ],
                            "description": "The member's organization role: `guest`, `member`, `developer`, `admin` or `owner`. Guest has no organization permissions and cannot list members, domains or roles."
                          },
                          "issuable": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            },
                            "description": "The scopes this person may give a token here."
                          },
                          "permissions": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            },
                            "description": "Their permissions in the organization (design note 0009)."
                          }
                        },
                        "required": [
                          "orgId",
                          "memberId",
                          "role",
                          "issuable",
                          "permissions"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "nextCursor": {
                      "type": "string",
                      "maxLength": 2048,
                      "description": "Omitted only when descendant enumeration is complete."
                    }
                  },
                  "required": [
                    "tokens",
                    "orgs"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "500": {
            "$ref": "#/components/responses/Error"
          },
          "405": {
            "description": "Method not allowed. The Allow header lists supported methods.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          }
        }
      },
      "post": {
        "tags": [
          "Access tokens"
        ],
        "operationId": "createTokenResource",
        "summary": "Create a token",
        "description": "Makes an access token for the person in one organization, for the content API (`api`), mail apps (`imap`, `smtp`) or both. A token acts for its member with the member's current access, never more: every scope must be one they may give (see `issuable` in [List my tokens](#listTokensResource)), and every container one they're in. A person may have 20 tokens.\n\n- `preset: \"email\"`: a mail app on one inbox (`inboxId`): scopes `imap`, `smtp`, `messages:read`, `messages:write`, `messages:send`; no expiry unless `expiresInDays` says otherwise.\n- `preset: \"custom\"`: the `scopes` given, narrowed to `containerIds`, expiring in 90 days unless `expiresInDays` says otherwise.\n\nThe secret (`k8hq_<token ID>_<secret>`) is in this answer only; K8 HQ keeps just a hash.\n\nWhen personal app admission is enabled, an app bearer credential may create only a bounded personal HTTP descendant with `Idempotency-Key`, `preset: \"custom\"`, `orgId`, and either an explicit permission/capability `ceiling` or supported named-container HTTP scopes. Expiry defaults to 30 days, accepts 1–90 days, and cannot exceed the original human authorization deadline. The complete requested-resource capture supports at most 20 distinct named resources and may refuse a unit that cannot fit the single 100-item capture. Browser issuers need no manual_copy flow. The first confirmed acceptance returns a copy-once `k8m1_` secret; replay/status return only safe token metadata. Legacy mail protocols, unbounded expiry and legacy presets are unsupported for app issuers.\n\nNeeds a passkey confirmation of this change (`x-k8hq-confirm`: `token.create`). Until confirmations are enforced, a passkey sign-in in the last five minutes also works. The API-token scope `tags:create` is an explicit choice, never part of a preset. Only a current owner or admin who holds `tags.create` can grant it. It always needs a passkey confirmation naming the new token. Each create checks the member’s current role and permission again and the token can create up to 50 tags. To give this scope to an existing token, create a new token.",
        "security": [
          {
            "session": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/contentSha256"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "preset": {
                    "type": "string",
                    "enum": [
                      "email",
                      "custom"
                    ]
                  },
                  "orgId": {
                    "type": "string",
                    "description": "The organization; may be left out when `containerIds` or `inboxId` name it."
                  },
                  "inboxId": {
                    "type": "string",
                    "description": "For `email`: the inbox the mail app signs in to."
                  },
                  "containerIds": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "description": "For `custom`: containers to narrow it to, all in the organization."
                  },
                  "scopes": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "description": "For `custom`."
                  },
                  "label": {
                    "type": "string",
                    "description": "Up to 100 characters; defaults to `mail app` or `token`.",
                    "maxLength": 100
                  },
                  "expiresInDays": {
                    "type": "integer",
                    "description": "1 to 3650; -1 for never; 0 or absent for the preset's default.",
                    "minimum": -1,
                    "maximum": 3650
                  }
                },
                "required": [
                  "preset"
                ]
              },
              "example": {
                "preset": "custom",
                "orgId": "org_01J...",
                "containerIds": [
                  "ibx_01J..."
                ],
                "scopes": [
                  "api",
                  "messages:read"
                ],
                "label": "Backup script",
                "expiresInDays": 30
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The token and, this once, its secret.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "token": {
                      "$ref": "#/components/schemas/Token"
                    },
                    "secret": {
                      "type": "string",
                      "description": "The full token to send as `Authorization: Bearer`.",
                      "pattern": "^k8hq_tok_"
                    }
                  },
                  "required": [
                    "token",
                    "secret"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedConfirm"
          },
          "403": {
            "description": "They can't make tokens in the organization, or give one of the scopes (`forbidden`); or a delegated token or foreign origin.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/Error"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "404": {
            "description": "They have no access to a container, or aren't a member (`not_found`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "409": {
            "description": "They have 20 tokens already, their access to the inbox needs updating, or who can do what in the organization changed meanwhile (`conflict`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "405": {
            "description": "Method not allowed. The Allow header lists supported methods.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        },
        "x-k8hq-step-up": true,
        "x-k8hq-confirm": "token.create"
      }
    },
    "/v1/account/tokens/{id}": {
      "delete": {
        "tags": [
          "Access tokens"
        ],
        "operationId": "revokeTokenResource",
        "summary": "Revoke my token",
        "description": "Revokes one of the person's own tokens; it stops working at once.",
        "security": [
          {
            "session": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/contentSha256"
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Resource ID.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "409": {
            "description": "Who can do what in the organization changed meanwhile (`conflict`): nothing was revoked; try again.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "200": {
            "description": "Revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Ok"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "500": {
            "$ref": "#/components/responses/Error"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "404": {
            "description": "Not one of their tokens (`not_found`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "405": {
            "description": "Method not allowed. The Allow header lists supported methods.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/v1/organizations/{orgId}/tokens": {
      "get": {
        "tags": [
          "Access tokens"
        ],
        "operationId": "listOrgTokensResource",
        "summary": "List an organization's tokens",
        "description": "Every token in the organization, for its owners and admins (`tokens.manage_all`). Bounded HTTP descendants are returned in pages of at most 8 evaluated index rows. Follow nextCursor even when a page has no matching tokens. Send it as cursor on the same listing; each agent page rechecks current authority. Legacy token metadata appears on the first page.",
        "security": [
          {
            "session": []
          }
        ],
        "parameters": [
          {
            "name": "orgId",
            "in": "path",
            "required": true,
            "description": "Organization ID.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 2048
            },
            "description": "Continuation for this exact user, organization, app and listing action; grants no authority."
          }
        ],
        "responses": {
          "200": {
            "description": "The tokens.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "tokens": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/OrgToken"
                      }
                    },
                    "nextCursor": {
                      "type": "string",
                      "maxLength": 2048,
                      "description": "Omitted only when descendant enumeration is complete."
                    }
                  },
                  "required": [
                    "tokens"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "They can't see the organization's tokens (`forbidden`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/Error"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "405": {
            "description": "Method not allowed. The Allow header lists supported methods.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/v1/organizations/{orgId}/tokens/{id}": {
      "delete": {
        "tags": [
          "Access tokens"
        ],
        "operationId": "revokeOrgTokenResource",
        "summary": "Revoke an organization's token",
        "description": "Revokes any token in the organization, for its owners and admins. Only owners revoke an owner's tokens.",
        "security": [
          {
            "session": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/contentSha256"
          },
          {
            "name": "orgId",
            "in": "path",
            "required": true,
            "description": "Organization ID.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Resource ID.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "409": {
            "description": "Who can do what in the organization changed meanwhile (`conflict`): nothing was revoked; try again.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "200": {
            "description": "Revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Ok"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "They can't revoke it (`forbidden`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/Error"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "404": {
            "description": "No such token in the organization (`not_found`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "405": {
            "description": "Method not allowed. The Allow header lists supported methods.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/v1/account/signup-invites": {
      "get": {
        "tags": [
          "Sign-up invitations"
        ],
        "operationId": "listSignupInvitesResource",
        "summary": "List my sign-up invitations",
        "description": "The sign-up invitations the person made, newest first, with how many they may have and how many are left. Each is a single-use link that expires after 14 days; unused ones that are revoked or expire stop counting.",
        "security": [
          {
            "session": []
          }
        ],
        "parameters": [],
        "responses": {
          "200": {
            "description": "Their invitations.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "invites": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/SignupInvite"
                      }
                    },
                    "limit": {
                      "type": "integer",
                      "description": "How many pending or accepted invitations they may have (3 unless K8 HQ raised it)."
                    },
                    "left": {
                      "type": "integer",
                      "description": "How many more they may make now."
                    }
                  },
                  "required": [
                    "invites",
                    "limit",
                    "left"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "500": {
            "$ref": "#/components/responses/Error"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "405": {
            "description": "Method not allowed. The Allow header lists supported methods.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Sign-up invitations"
        ],
        "operationId": "createSignupInviteResource",
        "summary": "Make a sign-up invitation",
        "description": "Makes a sign-up invitation. Share the link `https://app.k8hq.com/#invite=<secret>`; the secret is in this answer only. The person is told when it's used.",
        "security": [
          {
            "session": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/contentSha256"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {},
                "description": "Send `{}`: the call takes nothing.",
                "required": []
              },
              "example": {}
            }
          }
        },
        "responses": {
          "200": {
            "description": "The invitation and, this once, its secret.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "invite": {
                      "$ref": "#/components/schemas/SignupInvite"
                    },
                    "secret": {
                      "type": "string",
                      "pattern": "^k8hq_sinv_"
                    }
                  },
                  "required": [
                    "invite",
                    "secret"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedStepUp"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "500": {
            "$ref": "#/components/responses/Error"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "409": {
            "description": "None left (`no_invites_left`), or another is being made at the same moment (`conflict`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "405": {
            "description": "Method not allowed. The Allow header lists supported methods.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        },
        "x-k8hq-step-up": true
      }
    },
    "/v1/account/signup-invites/{id}": {
      "delete": {
        "tags": [
          "Sign-up invitations"
        ],
        "operationId": "revokeSignupInviteResource",
        "summary": "Revoke a sign-up invitation",
        "description": "Ends an unused invitation; it no longer counts against the limit.",
        "security": [
          {
            "session": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/contentSha256"
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Resource ID.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Ok"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "500": {
            "$ref": "#/components/responses/Error"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "409": {
            "description": "It was already used or revoked (`conflict`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "405": {
            "description": "Method not allowed. The Allow header lists supported methods.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/v1/organizations/{orgId}/members": {
      "get": {
        "tags": [
          "Members"
        ],
        "operationId": "listMembersResource",
        "summary": "List members",
        "description": "The organization's members and their roles, by name, for anyone in it who can see it (`org.view`).",
        "security": [
          {
            "session": []
          },
          {
            "delegated": []
          }
        ],
        "parameters": [
          {
            "name": "orgId",
            "in": "path",
            "required": true,
            "description": "Organization ID.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The members.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "members": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Member"
                      }
                    }
                  },
                  "required": [
                    "members"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "500": {
            "$ref": "#/components/responses/Error"
          },
          "503": {
            "description": "Whether K8 is available couldn't be checked (`unavailable`); retry.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "404": {
            "description": "Not a member, or suspended (`not_found`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "405": {
            "description": "Method not allowed. The Allow header lists supported methods.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/v1/organizations/{orgId}/members/recovery": {
      "get": {
        "tags": [
          "Members"
        ],
        "operationId": "listMemberRecovery",
        "summary": "See which members can recover their accounts",
        "description": "Owners only (`members.recovery.view`), using their own session. Lists only this organization's members, with their member ID, display name and whether they have a way to recover their account. A member is recoverable with two or more passkeys. No passkey names, devices, counts or key material are returned. Suspended owners are refused.",
        "security": [
          {
            "session": []
          }
        ],
        "parameters": [
          {
            "name": "orgId",
            "in": "path",
            "required": true,
            "description": "Organization ID.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The members and whether they can recover their accounts.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "members": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "memberId": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "recoverable": {
                            "type": "boolean"
                          }
                        },
                        "required": [
                          "memberId",
                          "name",
                          "recoverable"
                        ],
                        "additionalProperties": false
                      }
                    }
                  },
                  "required": [
                    "members"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "members": [
                    {
                      "memberId": "mem_example",
                      "name": "Sam",
                      "recoverable": true
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "The caller lacks the recovery permission or is suspended, or is using an assistant’s token (`forbidden`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "404": {
            "description": "Not a member of this organization, or the organization is closed (`not_found`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "405": {
            "description": "Method not allowed. The Allow header lists supported methods.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/v1/organizations/{orgId}/members/{memberId}": {
      "patch": {
        "tags": [
          "Members"
        ],
        "operationId": "setRoleResource",
        "summary": "Change a member's role",
        "description": "Changes a member's role. A non-owner giving or taking people-power doesn't apply it but asks the owners (202). Owners can't be demoted yet; they leave instead.\n\nNeeds a passkey confirmation of this change (`x-k8hq-confirm`: `member.role`). Until confirmations are enforced, a passkey sign-in in the last five minutes also works.",
        "security": [
          {
            "session": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/contentSha256"
          },
          {
            "name": "orgId",
            "in": "path",
            "required": true,
            "description": "Organization ID.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "memberId",
            "in": "path",
            "required": true,
            "description": "Member ID.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "role": {
                    "type": "string",
                    "enum": [
                      "guest",
                      "member",
                      "developer",
                      "admin",
                      "owner"
                    ],
                    "description": "The member's organization role: `guest`, `member`, `developer`, `admin` or `owner`. Guest has no organization permissions and cannot list members, domains or roles."
                  }
                },
                "required": [
                  "role"
                ]
              },
              "example": {
                "role": "admin"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Changed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Ok"
                }
              }
            }
          },
          "202": {
            "description": "Owners must approve it: a pending change (see [Pending changes](#listChangesResource)).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "pending": {
                      "$ref": "#/components/schemas/Change"
                    }
                  },
                  "required": [
                    "pending"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedConfirm"
          },
          "403": {
            "description": "Their role or permissions don't allow it (`forbidden`); or a delegated token or foreign origin.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/Error"
          },
          "400": {
            "description": "The role isn't `member`, `developer`, `admin` or `owner`, or the request is malformed (`invalid`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "404": {
            "description": "They aren't a member of the organization (`not_found`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "409": {
            "description": "Refused by the organization's state, such as the last holder of a container, or who can do what in the organization changed while this ran: reload and try again (`conflict`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "405": {
            "description": "Method not allowed. The Allow header lists supported methods.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        },
        "x-k8hq-step-up": true,
        "x-k8hq-confirm": "member.role"
      },
      "delete": {
        "tags": [
          "Members"
        ],
        "operationId": "removeMemberResource",
        "summary": "Remove a member",
        "description": "Removes a member: their access ends and their tokens in the organization are revoked; they get an account notice. A non-owner removing someone with people-power asks the owners (202). Removing owners is refused. Refused when it would leave a container nobody can open; a board handed to an owner doesn't count.\n\nBoards left without a full member: preview with a bodyless DELETE and `x-k8hq-confirm: ?`. The 401 `confirmation_required` answer includes `action`, `summary` and `boards`, an array of `{boardId, zeroAccess}` (`zeroAccess` only when true) for the boards that would lose their last full member, sorted by board ID; view-and-comment, guest, expired and item-only access don't count as full access. Board names aren't included: show the names you know, else the ID. `ownerMemberId` is the owner who gets full access to the boards that aren't zero-access: the owner removing them, else the earliest-joined owner who isn't suspended (any owner if all are; member ID breaks ties). A removal the owners must approve has no `ownerMemberId` but `approverReceives: true`: the owner who approves it gets them. Zero-access boards are never handed over and no owner's key copy changes: an owner joins them later through key sharing. The probe makes no changes. Confirm the returned action through the Sign-in API and retry with the resulting `x-k8hq-confirm` token. The action binds a hash of the board list, how many boards are handed over and how many are zero-access, and the recipient; a changed list needs a fresh confirmation (409 `confirmation_mismatch`).\n\nEach handoff writes an `access.board.granted` audit event (`reason` `member_removed`, `departingMemberId`) in the same transaction as that board's revocation. Apps and agents can't confirm a board list: their removal is refused (403 `needs_person`).\n\nNeeds a passkey confirmation of this change (`x-k8hq-confirm`: `member.remove`), always when boards are listed. Otherwise, until confirmations are enforced, a passkey sign-in in the last five minutes also works.",
        "security": [
          {
            "session": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/contentSha256"
          },
          {
            "name": "orgId",
            "in": "path",
            "required": true,
            "description": "Organization ID.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "memberId",
            "in": "path",
            "required": true,
            "description": "Member ID.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Removed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Ok"
                }
              }
            }
          },
          "202": {
            "description": "Owners must approve it: a pending change (see [Pending changes](#listChangesResource)).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "pending": {
                      "$ref": "#/components/schemas/Change"
                    }
                  },
                  "required": [
                    "pending"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedConfirm"
          },
          "403": {
            "description": "Their role or permissions don't allow it (`forbidden`); or a delegated token or foreign origin.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/Error"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "404": {
            "description": "They aren't a member of the organization (`not_found`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "409": {
            "description": "It would leave a container nobody can open (a board handed to an owner doesn't count), or who can do what in the organization changed while this ran: reload and try again (`conflict`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "405": {
            "description": "Method not allowed. The Allow header lists supported methods.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        },
        "x-k8hq-step-up": true,
        "x-k8hq-confirm": "member.remove"
      }
    },
    "/v1/organizations/{orgId}/invites": {
      "get": {
        "tags": [
          "Invites"
        ],
        "operationId": "listInvitesResource",
        "summary": "List invites",
        "description": "The organization's invites, for members who may invite (`members.invite`).",
        "security": [
          {
            "session": []
          },
          {
            "delegated": []
          }
        ],
        "parameters": [
          {
            "name": "orgId",
            "in": "path",
            "required": true,
            "description": "Organization ID.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The invites.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "invites": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Invite"
                      }
                    }
                  },
                  "required": [
                    "invites"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Their role or permissions don't allow it (`forbidden`); or a delegated token or foreign origin.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/Error"
          },
          "503": {
            "description": "Whether K8 is available couldn't be checked (`unavailable`); retry.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "404": {
            "description": "They aren't a member of the organization (`not_found`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "405": {
            "description": "Method not allowed. The Allow header lists supported methods.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Invites"
        ],
        "operationId": "createInviteResource",
        "summary": "Invite someone",
        "description": "Makes an invite link to join the organization with a role and access to some containers, no more than the caller has and may share. Share `https://app.k8hq.com/#join=<secret>`; the secret is in this answer only. It expires after 7 days. Someone without an account can sign up with it once the organization has proven a domain. 10 invites a day per person.\n\nNeeds a passkey confirmation of this change (`x-k8hq-confirm`: `invite.create`). Until confirmations are enforced, a passkey sign-in in the last five minutes also works. A Guest invite to a task board gives Can view and comment access. Existing members keep any higher organization role and existing board access.",
        "security": [
          {
            "session": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/contentSha256"
          },
          {
            "name": "orgId",
            "in": "path",
            "required": true,
            "description": "Organization ID.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "role": {
                    "type": "string",
                    "enum": [
                      "guest",
                      "member",
                      "developer",
                      "admin",
                      "owner"
                    ],
                    "description": "The member's organization role: `guest`, `member`, `developer`, `admin` or `owner`. Guest has no organization permissions and cannot list members, domains or roles."
                  },
                  "containerIds": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "description": "Containers to give access to."
                  }
                },
                "required": [
                  "role"
                ]
              },
              "example": {
                "role": "member",
                "containerIds": [
                  "ibx_01J..."
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The invite and, this once, its secret.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "invite": {
                      "$ref": "#/components/schemas/Invite"
                    },
                    "secret": {
                      "type": "string",
                      "pattern": "^k8hq_inv_"
                    }
                  },
                  "required": [
                    "invite",
                    "secret"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedConfirm"
          },
          "402": {
            "description": "The organization is read-only (`read_only`, design note 0024): it has been out of credit for 60 days, so nobody can be invited to it or join it until an owner adds credit.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "403": {
            "description": "Their role or permissions don't allow it (`forbidden`); or a delegated token or foreign origin.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/Error"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "404": {
            "description": "They aren't a member of the organization (`not_found`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "Today's 10 invites are made (`rate_limited`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "405": {
            "description": "Method not allowed. The Allow header lists supported methods.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "409": {
            "description": "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`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        },
        "x-k8hq-step-up": true,
        "x-k8hq-confirm": "invite.create"
      }
    },
    "/v1/organizations/{orgId}/invites/{id}": {
      "delete": {
        "tags": [
          "Invites"
        ],
        "operationId": "revokeInviteResource",
        "summary": "Revoke an invite",
        "description": "Ends a pending invite.",
        "security": [
          {
            "session": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/contentSha256"
          },
          {
            "name": "orgId",
            "in": "path",
            "required": true,
            "description": "Organization ID.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Resource ID.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Ok"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Their role or permissions don't allow it (`forbidden`); or a delegated token or foreign origin.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/Error"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "404": {
            "description": "They aren't a member of the organization (`not_found`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "410": {
            "description": "It isn't pending any more (`invalid`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "405": {
            "description": "Method not allowed. The Allow header lists supported methods.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/v1/account/destinations": {
      "get": {
        "tags": [
          "Notifications"
        ],
        "operationId": "listDestinationsResource",
        "summary": "List notification destinations",
        "description": "The person's destinations, which kinds of notices are muted, and limits. Notices in K8 HQ always gets everything; destinations get copies. The first time the person can use an inbox, security notices start going to it if they're its only member; if every inbox they can use is shared, nothing is set and `ask` is true until they choose.",
        "security": [
          {
            "session": []
          }
        ],
        "parameters": [],
        "responses": {
          "200": {
            "description": "Destinations and preferences.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "destinations": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Destination"
                      }
                    },
                    "muted": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "ask": {
                      "type": "boolean",
                      "description": "Every inbox the person can use is shared: ask them once whether security notices should go to one (with the warning)."
                    },
                    "confirmationsLeft": {
                      "type": "integer",
                      "description": "Confirmation emails the person may still ask for today."
                    },
                    "limits": {
                      "type": "object",
                      "properties": {
                        "addresses": {
                          "type": "integer"
                        },
                        "inboxes": {
                          "type": "integer"
                        },
                        "confirmationsPerDay": {
                          "type": "integer"
                        }
                      },
                      "required": [
                        "addresses",
                        "inboxes",
                        "confirmationsPerDay"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "destinations",
                    "muted",
                    "ask",
                    "confirmationsLeft",
                    "limits"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "500": {
            "$ref": "#/components/responses/Error"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "405": {
            "description": "Method not allowed. The Allow header lists supported methods.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Notifications"
        ],
        "operationId": "addDestinationResource",
        "summary": "Add a destination",
        "description": "Copies of the person's notices also go to an inbox they can edit (at once) or to an outside address (once the code K8 HQ emails it is typed with [Confirm a destination](#confirmDestination)). At most 3 outside addresses and 5 confirmation emails a day. Every change is itself a security notice, copied to the destinations usable before it.\n\nNeeds a passkey confirmation of this change (`x-k8hq-confirm`: `destination.add`). Until confirmations are enforced, a passkey sign-in in the last five minutes also works.",
        "security": [
          {
            "session": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/contentSha256"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "kind": {
                    "enum": [
                      "inbox",
                      "email"
                    ]
                  },
                  "orgId": {
                    "type": "string"
                  },
                  "inboxId": {
                    "type": "string"
                  },
                  "address": {
                    "type": "string"
                  },
                  "routes": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "description": "`security`, `account`, and `org:<org_id>` for an organization's notices (organizations the person is in)."
                  },
                  "sharedOk": {
                    "type": "boolean",
                    "description": "An inbox others use too: the person saw the warning in the `shared_inbox` answer."
                  }
                },
                "required": [
                  "kind",
                  "routes"
                ]
              },
              "example": {
                "kind": "email",
                "address": "me@example.com",
                "routes": [
                  "security"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The new destination.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "destination": {
                      "$ref": "#/components/schemas/Destination"
                    }
                  },
                  "required": [
                    "destination"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedConfirm"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "500": {
            "$ref": "#/components/responses/Error"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "description": "Others use this inbox (`shared_inbox`: show the warning in `detail`, then retry with `sharedOk`), the address asked not to be emailed (`address_blocked`), it's already a destination (`exists`), or there are as many as allowed (`too_many`). Inbox access changed while saving (`conflict`): reload and try again. 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`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "No more confirmation emails today (`confirmations_limit`), or destination changes (`changes_limit`, 20 a day).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "405": {
            "description": "Method not allowed. The Allow header lists supported methods.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        },
        "x-k8hq-step-up": true,
        "x-k8hq-confirm": "destination.add"
      }
    },
    "/v1/account/destinations/{id}": {
      "delete": {
        "tags": [
          "Notifications"
        ],
        "operationId": "removeDestinationResource",
        "summary": "Remove a destination",
        "description": "Stops copies to it. The notice about the removal still goes there, and to every other destination.\n\nNeeds a passkey confirmation of this change (`x-k8hq-confirm`: `destination.remove`). Until confirmations are enforced, a passkey sign-in in the last five minutes also works.",
        "security": [
          {
            "session": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/contentSha256"
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Resource ID.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Removed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Ok"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedConfirm"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "500": {
            "$ref": "#/components/responses/Error"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "description": "No more destination changes today (`changes_limit`, 20 a day).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "405": {
            "description": "Method not allowed. The Allow header lists supported methods.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "409": {
            "description": "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`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        },
        "x-k8hq-step-up": true,
        "x-k8hq-confirm": "destination.remove"
      }
    },
    "/v1/account/destinations/{id}/routes": {
      "put": {
        "tags": [
          "Notifications"
        ],
        "operationId": "setDestinationRoutesResource",
        "summary": "Change what a destination gets",
        "description": "Sets the kinds of notices copied there. For an inbox K8 HQ put on hold because others now use it, `sharedOk` releases it.\n\nReplaces the complete routes array. Supply every value to retain. You need permission to edit an inbox to change which notices go there.\n\nNeeds a passkey confirmation of this change (`x-k8hq-confirm`: `destination.routes`). Until confirmations are enforced, a passkey sign-in in the last five minutes also works.",
        "security": [
          {
            "session": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/contentSha256"
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Resource ID.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "routes": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "description": "`security`, `account`, and `org:<org_id>` for an organization's notices (organizations the person is in)."
                  },
                  "sharedOk": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "routes"
                ]
              },
              "example": {
                "routes": [
                  "security",
                  "account"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The changed destination.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "destination": {
                      "$ref": "#/components/schemas/Destination"
                    }
                  },
                  "required": [
                    "destination"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedConfirm"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "500": {
            "$ref": "#/components/responses/Error"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "description": "Others use this inbox (`shared_inbox`): retry with `sharedOk`. Inbox access changed while saving (`conflict`): reload and try again. 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`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "No more destination changes today (`changes_limit`, 20 a day).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "405": {
            "description": "Method not allowed. The Allow header lists supported methods.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        },
        "x-k8hq-step-up": true,
        "x-k8hq-confirm": "destination.routes"
      }
    },
    "/v1/account/notice-preferences": {
      "put": {
        "tags": [
          "Notifications"
        ],
        "operationId": "muteNoticesResource",
        "summary": "Mute kinds of notices",
        "description": "Kinds of notices copied to no destination (they're still in Notices): `account`, or `org:<org_id>` for an organization's. Security notices can't be muted. Replaces the list.\n\nReplaces the complete muted array. Supply every value to retain.",
        "security": [
          {
            "session": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/contentSha256"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "muted": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  }
                },
                "required": [
                  "muted"
                ]
              },
              "example": {
                "muted": [
                  "account"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The muted kinds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "const": true
                    },
                    "muted": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "muted"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "500": {
            "$ref": "#/components/responses/Error"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "405": {
            "description": "Method not allowed. The Allow header lists supported methods.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/v1/organizations/{orgId}/k8-settings": {
      "get": {
        "tags": [
          "K8"
        ],
        "operationId": "getK8SettingsResource",
        "summary": "Get K8 settings",
        "description": "The organization's K8 settings, for any member.",
        "security": [
          {
            "session": []
          }
        ],
        "parameters": [
          {
            "name": "orgId",
            "in": "path",
            "required": true,
            "description": "Organization ID.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The settings.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/K8Settings"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "500": {
            "$ref": "#/components/responses/Error"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "404": {
            "description": "They aren't a member (`not_found`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "405": {
            "description": "Method not allowed. The Allow header lists supported methods.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      },
      "put": {
        "tags": [
          "K8"
        ],
        "operationId": "changeK8SettingsResource",
        "summary": "Change K8 settings",
        "description": "Sets both K8 settings; owners only (`org.settings.change`).\n\nReplaces both K8 switches. Supply `membersUseK8` and `messagesAllowed`; omitted switches retain the legacy behavior of becoming false.\n\nNeeds a passkey confirmation of this change (`x-k8hq-confirm`: `k8.messages_allowed`). Until confirmations are enforced, a passkey sign-in in the last five minutes also works.",
        "security": [
          {
            "session": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/contentSha256"
          },
          {
            "name": "orgId",
            "in": "path",
            "required": true,
            "description": "Organization ID.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "membersUseK8": {
                    "type": "boolean"
                  },
                  "messagesAllowed": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "membersUseK8",
                  "messagesAllowed"
                ]
              },
              "example": {
                "membersUseK8": true,
                "messagesAllowed": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Changed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Ok"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedConfirm"
          },
          "403": {
            "description": "Only owners change K8 settings (`forbidden`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/Error"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "404": {
            "description": "They aren't a member (`not_found`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "405": {
            "description": "Method not allowed. The Allow header lists supported methods.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "409": {
            "description": "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`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        },
        "x-k8hq-step-up": true,
        "x-k8hq-confirm": "k8.messages_allowed"
      }
    },
    "/v1/organizations/{orgId}/changes": {
      "get": {
        "tags": [
          "Pending changes"
        ],
        "operationId": "listChangesResource",
        "summary": "List pending changes",
        "description": "Changes to people waiting for an owner: all of them for owners, the caller's own requests for others.",
        "security": [
          {
            "session": []
          },
          {
            "delegated": []
          }
        ],
        "parameters": [
          {
            "name": "orgId",
            "in": "path",
            "required": true,
            "description": "Organization ID.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The changes.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "changes": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Change"
                      }
                    }
                  },
                  "required": [
                    "changes"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Their role or permissions don't allow it (`forbidden`); or a delegated token or foreign origin.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/Error"
          },
          "503": {
            "description": "Whether K8 is available couldn't be checked (`unavailable`); retry.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "404": {
            "description": "They aren't a member of the organization (`not_found`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "405": {
            "description": "Method not allowed. The Allow header lists supported methods.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/v1/account/policy-status": {
      "get": {
        "tags": [
          "Policies"
        ],
        "operationId": "policyStatusResource",
        "summary": "Policy versions to accept",
        "description": "The current versions the person hasn't accepted yet (a newer version took effect since they last accepted one), and the versions they've accepted. Not available to an assistant's delegated token. `first` is true when the person has accepted no version yet (an account from before acceptance was recorded): ask them to review and accept, rather than saying the policies were updated.",
        "security": [
          {
            "session": []
          }
        ],
        "parameters": [],
        "responses": {
          "200": {
            "description": "What's needed, and what's recorded.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "needed": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/PolicyVersion"
                      }
                    },
                    "accepted": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "doc": {
                            "type": "string"
                          },
                          "version": {
                            "type": "string"
                          },
                          "acceptedAt": {
                            "type": "string",
                            "format": "date-time"
                          }
                        },
                        "required": [
                          "doc",
                          "version",
                          "acceptedAt"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "first": {
                      "type": "boolean",
                      "description": "No version accepted yet."
                    }
                  },
                  "required": [
                    "needed",
                    "accepted",
                    "first"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "500": {
            "$ref": "#/components/responses/Error"
          },
          "405": {
            "description": "Method not allowed; Allow lists supported methods.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/v1/keys/wraps": {
      "post": {
        "tags": [
          "User keys"
        ],
        "operationId": "addKeyWrapResource",
        "summary": "Add a sealed copy of the key",
        "description": "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.",
        "security": [
          {
            "session": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/contentSha256"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/KeyWrap"
              },
              "example": {
                "id": "pk-iphone",
                "kind": "prf",
                "credentialId": "q1w2e3...",
                "salt": "base64...",
                "wrapped": "base64..."
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Stored.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Ok"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedStepUp"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "500": {
            "$ref": "#/components/responses/Error"
          },
          "400": {
            "description": "The wrap's shape is wrong (`invalid`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "409": {
            "description": "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`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "405": {
            "description": "Method not allowed. The Allow header lists supported methods.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "426": {
            "description": "K8 HQ has been updated. Reload this page.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        },
        "x-k8hq-step-up": true
      }
    },
    "/v1/account/session": {
      "delete": {
        "tags": [
          "Sessions"
        ],
        "operationId": "logoutResource",
        "summary": "Sign out",
        "description": "Ends this session: its access and refresh tokens stop working at once (other services check revocation on every request).",
        "security": [
          {
            "session": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/contentSha256"
          }
        ],
        "responses": {
          "200": {
            "description": "Signed out.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Ok"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "500": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "description": "Your account changed meanwhile (another passkey, session or name change won the race), so nothing was changed (`conflict`); reload and try again.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "405": {
            "description": "Method not allowed. The Allow header lists supported methods.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/v1/account/sessions": {
      "delete": {
        "tags": [
          "Sessions"
        ],
        "operationId": "logoutAllResource",
        "summary": "Sign out everywhere",
        "description": "Ends every session of the person's, and revokes their API tokens in every organization. Their mail app tokens (IMAP and SMTP only) keep working unless `mailApps` is true.",
        "security": [
          {
            "session": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/contentSha256"
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "mailApps": {
                    "type": "boolean",
                    "description": "Also revoke mail app tokens."
                  }
                }
              },
              "example": {
                "mailApps": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Signed out everywhere.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Ok"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "500": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "description": "Some tokens couldn't be revoked yet because who can do what in their organization kept changing, or your account changed meanwhile (another passkey, session or name change won the race) (`conflict`): not signed out everywhere; try again.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "405": {
            "description": "Method not allowed. The Allow header lists supported methods.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/v1/account/browser-sessions": {
      "delete": {
        "tags": [
          "Sessions"
        ],
        "operationId": "logoutBrowser",
        "summary": "Sign out of this browser",
        "description": "Forget this browser's server sign-out (design note 0034): advances this browser's revocation epoch, so every session that signed in with this browser's `partitionSecret` ends at once, anyone's, this one included; a sign-in completing at the same moment fails with `browser_changed` and is tried again. This session must have signed in with that secret. A repeat, once this session has ended because the browser was signed out after it started, answers 200 again. The audit event `access.browser.signed_out` goes to each of the person's organizations (or their own scope beyond 48). Not available to assistants.",
        "security": [
          {
            "session": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/contentSha256"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "partitionSecret": {
                    "type": "string",
                    "pattern": "^[A-Za-z0-9_-]{43}$",
                    "description": "This browser's secret, the one this session signed in with."
                  }
                },
                "required": [
                  "partitionSecret"
                ]
              },
              "example": {
                "partitionSecret": "q0d8J3k5ZQyL2b9sV7mXrT1uW4nC6hA0eF8gP2iK5oM"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Every session in this browser has ended, this one included.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Ok"
                }
              }
            }
          },
          "400": {
            "description": "`partitionSecret` is missing or isn't a browser secret (`invalid`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "405": {
            "description": "Method not allowed. The Allow header lists supported methods.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "description": "This session can't sign the browser out: it signed in from this browser before its storage was reset (`browser_mismatch`), or it's from before browser secrets (`browser_unbound`). Nothing was signed out. Sign this session out with `DELETE /v1/account/session`; for `browser_mismatch` the browser's other sessions remain until Sign out everywhere or they expire. Also `conflict`: the account changed meanwhile; try again.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/v1/organizations/{orgId}/membership": {
      "delete": {
        "tags": [
          "Members"
        ],
        "operationId": "leaveResource",
        "summary": "Leave an organization",
        "description": "The person leaves the organization; their tokens there are revoked. The last owner can't leave. Boards they would leave without a full member are listed as for removing a member: the 401 `confirmation_required` answer includes `boards` and `ownerMemberId` (the earliest-joined owner who isn't suspended), the confirmation is always needed then, and confirming gives that owner full access to the boards that aren't zero-access (`access.board.granted`, `reason` `member_left`). A changed list needs a fresh confirmation (409 `confirmation_mismatch`).\n\nNeeds a passkey confirmation of this change (`x-k8hq-confirm`: `member.leave`). Until confirmations are enforced, a passkey sign-in in the last five minutes also works.",
        "security": [
          {
            "session": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/contentSha256"
          },
          {
            "name": "orgId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "The organization (`org_...`).",
              "pattern": "^org_"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Left.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Ok"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedConfirm"
          },
          "403": {
            "description": "Their role or permissions don't allow it (`forbidden`); or a delegated token or foreign origin.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/Error"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "404": {
            "description": "They aren't a member of the organization (`not_found`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "409": {
            "description": "They're the last owner, or the last who can open a container (a board handed to an owner doesn't count), or who can do what in the organization changed while this ran: reload and try again (`conflict`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "405": {
            "description": "Method not allowed. The Allow header lists supported methods.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        },
        "x-k8hq-step-up": true,
        "x-k8hq-confirm": "member.leave"
      }
    },
    "/v1/organizations/{orgId}/members/{memberId}/suspension": {
      "put": {
        "tags": [
          "Members"
        ],
        "operationId": "suspendMemberResource",
        "summary": "Suspend a member",
        "description": "Suspends a member for 24 hours: no access to the organization until it ends or is lifted (`members.suspend`, and only members whose permissions are within the caller's).\n\nNeeds a passkey confirmation of this change (`x-k8hq-confirm`: `member.suspend`). Until confirmations are enforced, a passkey sign-in in the last five minutes also works.",
        "security": [
          {
            "session": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/contentSha256"
          },
          {
            "name": "orgId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "The organization (`org_...`).",
              "pattern": "^org_"
            }
          },
          {
            "name": "memberId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The suspension.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "suspension": {
                      "$ref": "#/components/schemas/Suspension"
                    }
                  },
                  "required": [
                    "suspension"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedConfirm"
          },
          "403": {
            "description": "Their role or permissions don't allow it (`forbidden`); or a delegated token or foreign origin.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/Error"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "404": {
            "description": "They aren't a member of the organization (`not_found`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "409": {
            "description": "They're already suspended (`conflict`). 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`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "405": {
            "description": "Method not allowed. The Allow header lists supported methods.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        },
        "x-k8hq-step-up": true,
        "x-k8hq-confirm": "member.suspend"
      },
      "delete": {
        "tags": [
          "Members"
        ],
        "operationId": "unsuspendMemberResource",
        "summary": "Lift a suspension",
        "description": "Lifts a suspension early: owners, or whoever suspended them.",
        "security": [
          {
            "session": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/contentSha256"
          },
          {
            "name": "orgId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "The organization (`org_...`).",
              "pattern": "^org_"
            }
          },
          {
            "name": "memberId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Lifted.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Ok"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedStepUp"
          },
          "403": {
            "description": "Their role or permissions don't allow it (`forbidden`); or a delegated token or foreign origin.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/Error"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "404": {
            "description": "They aren't a member of the organization (`not_found`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "409": {
            "description": "They aren't suspended (`conflict`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "405": {
            "description": "Method not allowed. The Allow header lists supported methods.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        },
        "x-k8hq-step-up": true
      }
    },
    "/v1/account/notices": {
      "patch": {
        "tags": [
          "Notices"
        ],
        "operationId": "archiveNoticesResource",
        "summary": "Mark notices read",
        "description": "Archives the named notices (up to 100), or all of them (`all`) a bounded step at a time: while `more` is true, call again with `nextCursor`.",
        "security": [
          {
            "session": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/contentSha256"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "notices": {
                    "type": "array",
                    "items": {
                      "$ref": "#/components/schemas/NoticeRef"
                    },
                    "description": "Up to 100."
                  },
                  "all": {
                    "type": "boolean"
                  },
                  "cursor": {
                    "type": "string",
                    "description": "With `all`: `nextCursor` from the previous step."
                  }
                }
              },
              "example": {
                "notices": [
                  {
                    "id": "evt_01J...",
                    "seq": "00000000000000000042"
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Archived.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "const": true
                    },
                    "more": {
                      "type": "boolean",
                      "description": "There's more to do: call again with `nextCursor`."
                    },
                    "nextCursor": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "ok",
                    "more"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "500": {
            "$ref": "#/components/responses/Error"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "404": {
            "description": "A named notice isn't one of theirs (`not_found`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "405": {
            "description": "Method not allowed. The Allow header lists supported methods.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Notices"
        ],
        "operationId": "deleteNoticesResource",
        "summary": "Delete notices",
        "description": "Removes archived notices from Notices for good: the named ones, or every archived one (`archivedAll`, a bounded step at a time like archiving). The events stay in the account's audit record until the account is deleted. Needs a recent passkey, so a stolen session can't hide the notice about what it did.",
        "security": [
          {
            "session": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/contentSha256"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "notices": {
                    "type": "array",
                    "items": {
                      "$ref": "#/components/schemas/NoticeRef"
                    },
                    "description": "Up to 100, all archived."
                  },
                  "archivedAll": {
                    "type": "boolean"
                  },
                  "cursor": {
                    "type": "string",
                    "description": "With `archivedAll`: `nextCursor` from the previous step."
                  }
                }
              },
              "example": {
                "archivedAll": true
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Deleted.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "const": true
                    },
                    "more": {
                      "type": "boolean",
                      "description": "There's more to do: call again with `nextCursor`."
                    },
                    "nextCursor": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "ok",
                    "more"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedStepUp"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "500": {
            "$ref": "#/components/responses/Error"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "404": {
            "description": "A named notice isn't one of theirs (`not_found`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "409": {
            "description": "A named notice isn't archived; open it first (`conflict`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "405": {
            "description": "Method not allowed. The Allow header lists supported methods.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        },
        "x-k8hq-step-up": true
      }
    },
    "/v1/confirm/begin": {
      "post": {
        "tags": [
          "Sessions"
        ],
        "operationId": "confirmBegin",
        "summary": "Begin a confirmation",
        "description": "Starts a passkey confirmation of one change (`action`) or an ordered list of up to 5 different changes (`actions`), or up to 20 when every change moves an address to a new inbox or changes an inbox's addresses, as the routes described them in their `confirmation_required` answers. Send exactly one form. Every change must belong to the same sign-in and organization; account changes can be listed only with other account changes. Address descriptions bind the method and route through their operation (add, status, delete or move), the source inbox, address, endpoint and current status where present, and the destination inbox for a move. Returns the passkey request, whose challenge commits to the whole ordered list of canonical descriptions, and a summary listing every change in K8 HQ's words with names it looked up. The challenge lasts 5 minutes. A person's own session only, never an assistant's. At most 30 a person every 10 minutes.",
        "security": [
          {
            "session": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/contentSha256"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "oneOf": [
                  { "required": ["action"] },
                  { "required": ["actions"] }
                ],
                "properties": {
                  "action": {
                    "$ref": "#/components/schemas/Action"
                  },
                  "actions": {
                    "type": "array",
                    "items": {
                      "$ref": "#/components/schemas/Action"
                    },
                    "description": "Up to 5 changes, or up to 20 when every kind is address.change or inbox.promote.",
                    "minItems": 1,
                    "maxItems": 20
                  }
                }
              },
              "example": {
                "action": {
                  "v": 1,
                  "kind": "member.role",
                  "svc": "auth",
                  "sub": "usr_01J...",
                  "sid": "ses_01J...",
                  "org": "org_01J...",
                  "target": "mem_01J...",
                  "params": {
                    "role": "admin",
                    "fromRole": "member"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The passkey request and what it confirms.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "challengeId": {
                      "type": "string",
                      "pattern": "^chl_",
                      "description": "Valid 5 minutes, once."
                    },
                    "options": {
                      "type": "object",
                      "description": "For `navigator.credentials.get()`: the person's own passkeys, user verification required."
                    },
                    "summary": {
                      "type": "string",
                      "description": "Every action's summary, one line each."
                    },
                    "summaries": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "challengeId",
                    "options",
                    "summary",
                    "summaries"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Not a change K8 HQ can confirm, another session's change, mixed organizations, repeated changes or too many changes of these kinds (`invalid_action`), or malformed (`invalid`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "description": "Too many confirmations begun (`rate_limited`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/v1/confirm/finish": {
      "post": {
        "tags": [
          "Sessions"
        ],
        "operationId": "confirmFinish",
        "summary": "Finish a confirmation",
        "description": "Checks the passkey's answer (the same person's passkey, user verified, over the challenge naming the actions, from the same session), records `access.action.confirmed` and a security notice to the person, and returns the confirmation: send it in `x-k8hq-confirm` with the change, within 2 minutes. Reuse the same confirmation for each listed request. Each request still checks current permissions and must match its listed description. Each entry can be used once, even when requests run at the same time; a replay returns `confirmation_used` and a request outside the list returns `confirmation_mismatch`. The two-minute expiry applies to the whole list and is never extended by use. A confirmation never counts as a recent passkey use. For seven days after recovery, bound actions in organizations with another owner become pending changes. Answers 202 with changes after the passkey check. Another owner approves through the existing changes routes; repeat the confirmation in the same session, then retry the original request. Each approval permits one confirmation of exactly the described action. Lists wait for all approvals. Adding a destination or turning off the key copy is refused during the seven days.",
        "security": [
          {
            "session": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/contentSha256"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "challengeId": {
                    "type": "string"
                  },
                  "credential": {
                    "type": "object",
                    "description": "The passkey's answer (`PublicKeyCredential.toJSON()`)."
                  }
                },
                "required": [
                  "challengeId",
                  "credential"
                ]
              },
              "example": {
                "challengeId": "chl_01J...",
                "credential": {
                  "id": "...",
                  "type": "public-key",
                  "response": {}
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The confirmation.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "confirmation": {
                      "type": "string",
                      "description": "Send it in `x-k8hq-confirm`."
                    },
                    "expiresAt": {
                      "type": "string",
                      "format": "date-time"
                    }
                  },
                  "required": [
                    "confirmation",
                    "expiresAt"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Malformed, or the challenge is unknown, expired, used or another session's, or the passkey's answer couldn't be read (`invalid`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "401": {
            "description": "No session or it expired (`unauthenticated`), or the passkey isn't recognized or isn't theirs.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "description": "The saved list of changes is no longer valid (`invalid_action`). Review the changes and start again.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "Too many failed passkey ceremonies from this address (`rate_limited`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/Error"
          },
          "202": {
            "description": "Waiting for another owner to approve. No confirmation was issued.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "changes": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Change"
                      }
                    }
                  },
                  "required": [
                    "changes"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "409": {
            "description": "The approval request was declined, expired or already used. Review the change and try again.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/v1/recovery/begin": {
      "post": {
        "tags": [
          "Sign-in recovery"
        ],
        "operationId": "recoveryBegin",
        "summary": "Ask for a recovery code",
        "description": "No sign-in needed. Always returns the same answer and a fresh request ID, whether or not the address belongs to an account. Address checks and sending have a fixed time budget; refusals and sender failures give the same answer. Only a confirmed outside address routed for security notices for at least seven days can recover an account, and only while K8 HQ keeps a copy of its key and it has no zero-access inboxes. At most three code or explanation emails per address per UTC day, across all accounts. Code emails have no link. The code works for thirty minutes. A separate recovery sender checks whether the address is blocked or has bounced before sending. All recovery routes share a limit of ten requests per client IP per UTC hour, in addition to the auth limit at the edge. Answers are never cached.",
        "security": [],
        "parameters": [
          {
            "$ref": "#/components/parameters/contentSha256"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "address": {
                    "type": "string",
                    "description": "The outside address used for security notices.",
                    "maxLength": 320
                  }
                },
                "required": [
                  "address"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The recovery answer.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "requestId": {
                      "type": "string",
                      "description": "A fresh opaque request ID, also made for unknown addresses.",
                      "pattern": "^rrq_[0-9A-Z]{26}$"
                    },
                    "message": {
                      "type": "string",
                      "const": "If that address can recover a K8 HQ account, we've sent it a code."
                    }
                  },
                  "required": [
                    "requestId",
                    "message"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid request, or recovery_unavailable: the code or recovery cannot be used.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "403": {
            "description": "The browser origin is not allowed.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "Too many recovery requests or failed sign-in attempts (rate_limited).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/v1/recovery/verify": {
      "post": {
        "tags": [
          "Sign-in recovery"
        ],
        "operationId": "recoveryVerify",
        "summary": "Check a recovery code",
        "description": "No sign-in needed. Counts the try before checking any code. Each request allows five tries; wrong codes also count toward the sign-in failure limit. A request that does not exist costs no code check. A matching code returns the account's name, the month it was created, and creation options for a new passkey. The challenge lasts five minutes, requests PRF support and uses the account's existing passkey handle. Pass options to navigator.credentials.create(), then send the result to Start the recovery. Wrong, expired and refused codes have the same answer. All recovery routes share a limit of ten requests per client IP per UTC hour, in addition to the auth limit at the edge. Answers are never cached.",
        "security": [],
        "parameters": [
          {
            "$ref": "#/components/parameters/contentSha256"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "requestId": {
                    "type": "string",
                    "description": "The request ID returned by begin.",
                    "maxLength": 100
                  },
                  "code": {
                    "type": "string",
                    "description": "The eight-digit code in the latest recovery email.",
                    "pattern": "^[0-9]{8}$"
                  }
                },
                "required": [
                  "requestId",
                  "code"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The recovery answer.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "recoveryId": {
                      "type": "string",
                      "description": "The recovery ID."
                    },
                    "account": {
                      "type": "object",
                      "properties": {
                        "displayName": {
                          "type": "string",
                          "description": "The name the person chose; may be empty."
                        },
                        "createdMonth": {
                          "type": "string",
                          "description": "The month the account was created, YYYY-MM."
                        }
                      },
                      "required": [
                        "displayName",
                        "createdMonth"
                      ],
                      "additionalProperties": false
                    },
                    "challengeId": {
                      "type": "string",
                      "description": "The single-use creation challenge."
                    },
                    "options": {
                      "type": "object",
                      "description": "WebAuthn credential creation options with publicKey and PRF requested."
                    }
                  },
                  "required": [
                    "recoveryId",
                    "account",
                    "challengeId",
                    "options"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid request, or recovery_unavailable: the code or recovery cannot be used.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "403": {
            "description": "The browser origin is not allowed.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "Too many recovery requests or failed sign-in attempts (rate_limited).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/v1/recovery/start": {
      "post": {
        "tags": [
          "Sign-in recovery"
        ],
        "operationId": "recoveryStart",
        "summary": "Start the recovery",
        "description": "No sign-in needed. Checks the new passkey against the recovery challenge and checks eligibility again. In one transaction saves the passkey as pending, starts a seventy-two-hour wait, locks the account to one waiting recovery, and records security notices for the person and the other owners of organizations where they hold people or access powers. The pending passkey cannot sign in. The wait applies to this passkey only. Recovery can be finished for seven days after the wait. At most three starts in thirty days, and none within twenty-four hours after cancellation; a cancel link sent to a different destination counts toward neither limit. Requests that only asked for a code do not count as starts. This call issues no session or key-release ticket. All recovery routes share a limit of ten requests per client IP per UTC hour, in addition to the auth limit at the edge. Answers are never cached.",
        "security": [],
        "parameters": [
          {
            "$ref": "#/components/parameters/contentSha256"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "recoveryId": {
                    "type": "string",
                    "description": "The recovery ID from verify.",
                    "maxLength": 100
                  },
                  "challengeId": {
                    "type": "string",
                    "description": "The creation challenge ID from verify.",
                    "maxLength": 100
                  },
                  "credential": {
                    "type": "object",
                    "description": "The browser WebAuthn creation response."
                  },
                  "device": {
                    "type": "string",
                    "description": "An optional name for this device.",
                    "maxLength": 200
                  }
                },
                "required": [
                  "recoveryId",
                  "challengeId",
                  "credential"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The recovery answer.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "recoveryId": {
                      "type": "string",
                      "description": "The waiting recovery."
                    },
                    "readyAt": {
                      "type": "string",
                      "description": "When the seventy-two-hour wait ends.",
                      "format": "date-time"
                    },
                    "expiresAt": {
                      "type": "string",
                      "description": "When the recovery expires.",
                      "format": "date-time"
                    }
                  },
                  "required": [
                    "recoveryId",
                    "readyAt",
                    "expiresAt"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid request, or recovery_unavailable: the code or recovery cannot be used.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "403": {
            "description": "The browser origin is not allowed.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "Too many recovery requests or failed sign-in attempts (rate_limited).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/v1/recovery/cancel": {
      "post": {
        "tags": [
          "Sign-in recovery"
        ],
        "operationId": "recoveryCancel",
        "summary": "Cancel a recovery",
        "description": "Use a cancel token from a recovery notice, without signing in, or send recoveryId with your own session and a passkey confirmation in the last five minutes. In-app notices have no cancel token. Cancelling through a link sent to another destination counts toward neither the start cap nor the cancel cooldown. Cancel and completion compete in one transaction; only one can win.",
        "security": [],
        "parameters": [
          {
            "$ref": "#/components/parameters/contentSha256"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "token": {
                    "type": "string",
                    "maxLength": 300,
                    "description": "The token from a recovery notice link."
                  },
                  "recoveryId": {
                    "type": "string",
                    "description": "The waiting recovery, when cancelling from your own signed-in session.",
                    "maxLength": 100
                  }
                },
                "required": [],
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The recovery answer.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Ok"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request, or recovery_unavailable: the code or recovery cannot be used.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "403": {
            "description": "The browser origin is not allowed.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "Too many recovery requests or failed sign-in attempts (rate_limited).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      }
    },
    "/v1/recovery/complete/begin": {
      "post": {
        "tags": [
          "Sign-in recovery"
        ],
        "operationId": "recoveryCompleteBegin",
        "summary": "Finish recovery with the new passkey",
        "description": "After the seventy-two-hour wait, asks for the pending passkey only. Checks that recovery still waits, has not expired and remains eligible. The assertion challenge lasts five minutes.",
        "security": [],
        "parameters": [
          {
            "$ref": "#/components/parameters/contentSha256"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "recoveryId": {
                    "type": "string",
                    "description": "The waiting recovery from verify.",
                    "maxLength": 100
                  }
                },
                "required": [
                  "recoveryId"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The recovery answer.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Challenge"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request, or recovery_unavailable: the code or recovery cannot be used.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "403": {
            "description": "The browser origin is not allowed.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "Too many recovery requests or failed sign-in attempts (rate_limited).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/v1/recovery/complete": {
      "post": {
        "tags": [
          "Sign-in recovery"
        ],
        "operationId": "recoveryComplete",
        "summary": "Complete recovery",
        "description": "Checks the pending passkey and all eligibility again, including transaction conditions on the waiting record, ACTIVE, unchanged confirmed security-routed recovery address, block record, server copy and zero-access markers. Replaces all old passkeys, removes PRF and old recovery-kit wraps, signs out old sessions, always revokes API and mail app tokens, records completion and owner notices, and starts a new session. The new session can use the one-time release ticket to unlock the same user key. Keep the server copy on, add a PRF wrap when supported, and require a new recovery kit confirmed by reopening the file. Records the seven-day recently recovered period.",
        "security": [],
        "parameters": [
          {
            "$ref": "#/components/parameters/contentSha256"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "challengeId": {
                    "type": "string",
                    "description": "The creation challenge ID from verify.",
                    "maxLength": 100
                  },
                  "credential": {
                    "type": "object",
                    "description": "The browser WebAuthn assertion response for the pending passkey."
                  },
                  "device": {
                    "type": "string",
                    "description": "An optional name for this device.",
                    "maxLength": 200
                  },
                  "mailApps": {
                    "type": "boolean",
                    "description": "Accepted for compatibility. Mail app tokens are always revoked."
                  },
                  "partitionSecret": {
                    "type": "string",
                    "pattern": "^[A-Za-z0-9_-]{43}$",
                    "description": "This browser's secret for signing out: 32 random bytes in base64url (no padding), made once per browser storage partition and kept there. K8 HQ keeps only a hash of it, so knowing a browser's ID never lets another sign-in join that browser. Sent with every sign-in from the web app, so Forget this browser can end them all (`DELETE /v1/account/browser-sessions`); the session keeps it through refreshes. Leave it out from anything but the web app. A value that isn't one is refused (`invalid`) before the passkey answer is used."
                  }
                },
                "required": [
                  "challengeId",
                  "credential"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The recovery answer.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "userId": {
                      "type": "string",
                      "description": "The same account, with its organizations, grants and user key.",
                      "maxLength": 100
                    },
                    "tokens": {
                      "$ref": "#/components/schemas/Tokens"
                    },
                    "releaseTicket": {
                      "type": "string",
                      "description": "A single-use ticket to unlock the existing server copy in this session; valid five minutes.",
                      "maxLength": 100
                    },
                    "newRecoveryKitRequired": {
                      "type": "boolean",
                      "description": "Make a new recovery kit and confirm it by reopening its file."
                    }
                  },
                  "required": [
                    "userId",
                    "tokens",
                    "newRecoveryKitRequired"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid request, or recovery_unavailable: the code or recovery cannot be used.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "403": {
            "description": "The browser origin is not allowed.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "Too many recovery requests or failed sign-in attempts (rate_limited).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "description": "This browser was signed out while this sign-in completed (`browser_changed`), so no session started; sign in again.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/v1/recovery/status": {
      "get": {
        "tags": [
          "Sign-in recovery"
        ],
        "operationId": "recoveryStatus",
        "summary": "See a waiting recovery",
        "description": "Reads the ACTIVE recovery lock. Use this for the banner on every page. Deleting or reading a notice cannot hide a waiting recovery. No cancel token is returned.",
        "security": [
          {
            "session": []
          }
        ],
        "parameters": [],
        "responses": {
          "200": {
            "description": "The recovery answer.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "recovery": {
                      "type": [
                        "object",
                        "null"
                      ],
                      "properties": {
                        "recoveryId": {
                          "type": "string",
                          "description": "The waiting recovery."
                        },
                        "destinationId": {
                          "type": "string",
                          "description": "The recovery address destination."
                        },
                        "startedAt": {
                          "type": "string",
                          "description": "When recovery started."
                        },
                        "readyAt": {
                          "type": "string",
                          "description": "When the wait ends."
                        },
                        "network": {
                          "type": "string",
                          "description": "The requesting network."
                        },
                        "country": {
                          "type": "string",
                          "description": "The requesting country."
                        }
                      },
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "recovery"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "500": {
            "$ref": "#/components/responses/Error"
          },
          "405": {
            "description": "Method not allowed. The Allow header lists supported methods.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/v1/agent-key-bindings/challenges": {
      "post": {
        "tags": [
          "Agent key bindings"
        ],
        "operationId": "agentKeyChallenge",
        "summary": "Start pairing an app's keys",
        "description": "An app proposes its X25519 and Ed25519 public keys for its own connection in one organization. K8 HQ assigns the binding ID and returns a fresh challenge sealed to the X25519 key, valid 5 minutes. A public key grants nothing.",
        "security": [
          {
            "app": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "16 to 128 visible ASCII characters, new for each change."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The sealed challenge.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AgentKeyBinding"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Key sharing with apps is off (`not_found`), or no such binding you may see.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "description": "This pairing request has expired (`challenge_expired`), another pairing is waiting for confirmation, or the Idempotency-Key was used for different input (`conflict`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "Four pairing requests are already waiting (`rate_limited`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/v1/agent-key-bindings": {
      "post": {
        "tags": [
          "Agent key bindings"
        ],
        "operationId": "agentKeyProof",
        "summary": "Prove an app holds its keys",
        "description": "The app returns the signed binding with the challenge digest, its signature and the opened challenge. The binding is stored pending until the person confirms it.",
        "security": [
          {
            "app": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "16 to 128 visible ASCII characters, new for each change."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The binding.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AgentKeyBinding"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Key sharing with apps is off (`not_found`), or no such binding you may see.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "description": "The challenge expired (`challenge_expired`), was already answered (`conflict`), or the keys are already bound (`keys_bound`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "422": {
            "description": "The proof of possession didn't verify (`invalid_proof`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/v1/agent-key-bindings/{id}": {
      "get": {
        "tags": [
          "Agent key bindings"
        ],
        "operationId": "agentKeyBinding",
        "summary": "Read an app's key binding",
        "description": "The person who connected the app reads its binding: the signed fields, the fingerprint to check through a channel they trust, its confirmation deadline and who the app, provider and organization are.",
        "security": [
          {
            "session": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The binding (akb_)."
          },
          {
            "name": "ownerKind",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "ownerId",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "orgId",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The binding.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AgentKeyBinding"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Key sharing with apps is off (`not_found`), or no such binding you may see.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/v1/agent-key-bindings/{id}/verify": {
      "post": {
        "tags": [
          "Agent key bindings"
        ],
        "operationId": "agentKeyVerify",
        "summary": "Confirm an app's key binding",
        "description": "The person signs the binding with their own key after checking its fingerprint, before its confirmation deadline.",
        "security": [
          {
            "session": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The binding (akb_)."
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "16 to 128 visible ASCII characters, new for each change."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The binding.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AgentKeyBinding"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedStepUp"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Key sharing with apps is off (`not_found`), or no such binding you may see.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "description": "The deadline passed (`challenge_expired`), the binding was revoked (`revoked`) or isn't pending (`conflict`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "422": {
            "description": "The signature didn't verify with your key (`invalid_proof`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        },
        "x-k8hq-step-up": true
      }
    },
    "/v1/agent-key-bindings/{id}/replace": {
      "post": {
        "tags": [
          "Agent key bindings"
        ],
        "operationId": "agentKeyReplace",
        "summary": "Replace an app's key binding",
        "description": "The person replaces an older binding with a newer confirmed one. Keys shared with the old binding stop being available from K8 HQ; the affected inboxes need new keys for future content.",
        "security": [
          {
            "session": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The binding (akb_)."
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "16 to 128 visible ASCII characters, new for each change."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The replacement's outcome.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AgentKeyBinding"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedStepUp"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Key sharing with apps is off (`not_found`), or no such binding you may see.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "description": "The binding was already replaced by another (`revoked`) or the new one isn't confirmed (`conflict`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        },
        "x-k8hq-step-up": true
      }
    },
    "/v1/members/compromise": {
      "post": {
        "tags": [
          "Members"
        ],
        "operationId": "reportCompromise",
        "summary": "Report an inbox's keys as possibly exposed",
        "description": "An owner reports that a zero-access inbox's keys may be exposed (design note 0032 B.2), naming 0 to 4 of its key holders whose encryption key may be. In one change: the people named are suspended for 24 hours, their keys are refused in every K8 HQ organization from now on, and every zero-access inbox of the organization they hold gets one request to update its encryption. It is refused when it would leave any of those inboxes with nobody who can open it. To get access again, a person named replaces their key and a holder gives the new key access. Send `Idempotency-Key: <operationId>:compromise`; the same report again answers `replayed: true`. Only an owner's own session.\n\nNeeds a passkey confirmation of this report (`x-k8hq-confirm`: `member.compromise`). Until confirmations are enforced, a passkey sign-in in the last five minutes also works. Off unless zero-access is turned on (404). Responses use Cache-Control: no-store.",
        "security": [
          {
            "session": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/contentSha256"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "`<operationId>:compromise`."
          }
        ],
        "x-k8hq-confirm": "member.compromise",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "schemaVersion",
                  "orgId",
                  "inboxId",
                  "operationId",
                  "suspectMemberIds"
                ],
                "properties": {
                  "schemaVersion": {
                    "type": "integer",
                    "const": 1
                  },
                  "orgId": {
                    "type": "string",
                    "pattern": "^org_"
                  },
                  "inboxId": {
                    "type": "string",
                    "pattern": "^ibx_"
                  },
                  "operationId": {
                    "type": "string",
                    "pattern": "^akr_",
                    "description": "A new operation ID for this report (`akr_...`)."
                  },
                  "suspectMemberIds": {
                    "type": "array",
                    "maxItems": 4,
                    "uniqueItems": true,
                    "items": {
                      "type": "string",
                      "pattern": "^mem_"
                    },
                    "description": "The holders whose key may be exposed; empty when only the inbox key is suspected."
                  }
                }
              },
              "example": {
                "schemaVersion": 1,
                "orgId": "org_01J...",
                "inboxId": "ibx_01J...",
                "operationId": "akr_01J...",
                "suspectMemberIds": [
                  "mem_01J..."
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Reported (or the same report replayed).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "schemaVersion",
                    "operationId",
                    "suspended",
                    "exposedKeyCount",
                    "replayed"
                  ],
                  "properties": {
                    "schemaVersion": {
                      "type": "integer",
                      "const": 1
                    },
                    "operationId": {
                      "type": "string"
                    },
                    "suspended": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      },
                      "description": "The members named, all suspended now."
                    },
                    "exposedKeyCount": {
                      "type": "integer",
                      "description": "How many keys this report newly recorded as exposed."
                    },
                    "replayed": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "The body or the Idempotency-Key isn't valid (`invalid`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedConfirm"
          },
          "403": {
            "description": "Not an owner (`owner_only`); a suspension the report would make isn't allowed, or it names two owners (`forbidden`); an API token or assistant asked (`needs_person`); or the confirmation isn't this session's (`confirmation_invalid`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "404": {
            "description": "Off, or the caller isn't a current member with access to the inbox (`not_found`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "409": {
            "description": "The inbox isn't zero-access (`zero_access`) or its switch isn't finished (`in_progress`); the operation was used for another report, someone named can't be, or something changed meanwhile (`conflict`); an inbox would be left with nobody who can open it (`last_holder`); the report is too large (`report_too_large`); or the confirmation doesn't match (`confirmation_*`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/Error"
          },
          "503": {
            "description": "An affected inbox still has 32 encryption updates waiting (`rotation_backlog`, with `Retry-After`), or reports aren't available yet: K8 HQ hasn't finished recording who owns each key (`unavailable`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "426": {
            "description": "K8 HQ has been updated. Reload this page.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/v1/organizations/{orgId}/k8-settings/boards": {
      "put": {
        "operationId": "changeK8BoardsSettingsResource",
        "tags": [
          "K8"
        ],
        "summary": "Change K8 for Boards",
        "x-k8hq-confirm": "k8.boards_allowed",
        "description": "An owner or admin changes only `boardsAllowed`. Needs your own sign-in. Turning it on needs a passkey confirmation of this change; other changes need passkey sign-in within five minutes. Keeps the other K8 settings. You can change this setting while K8 for Boards is unavailable. Turning it on does not make K8 for Boards available or let K8 read a board without your permission for that request.",
        "parameters": [
          {
            "name": "orgId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "boardsAllowed": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "boardsAllowed"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The setting changed.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "ok"
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedConfirm"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "500": {
            "$ref": "#/components/responses/Error"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "404": {
            "description": "They aren't a member (`not_found`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "405": {
            "description": "Method not allowed. The Allow header lists supported methods.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "409": {
            "description": "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`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        },
        "security": [
          {
            "session": []
          }
        ]
      }
    },
    "/v1/organizations/{orgId}/k8-settings/contacts": {
      "put": {
        "operationId": "changeK8ContactsSettingsResource",
        "tags": [
          "K8"
        ],
        "summary": "Change K8 for Contacts",
        "x-k8hq-confirm": "k8.contacts_allowed",
        "description": "An owner or admin changes only `contactsAllowed`. Needs your own sign-in. Turning it on needs a passkey confirmation of this change; other changes need passkey sign-in within five minutes. Keeps the other K8 settings. You can change this setting while K8 for Contacts is unavailable. Turning it on does not make K8 for Contacts available or let K8 read contacts without your permission for that request.",
        "parameters": [
          {
            "name": "orgId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "contactsAllowed": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "contactsAllowed"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The setting changed.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "ok"
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedConfirm"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "500": {
            "$ref": "#/components/responses/Error"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "404": {
            "description": "They aren't a member (`not_found`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "405": {
            "description": "Method not allowed. The Allow header lists supported methods.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "409": {
            "description": "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`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        },
        "security": [
          {
            "session": []
          }
        ]
      }
    },
    "/v1/organizations/{orgId}/k8-settings/notices": {
      "put": {
        "operationId": "changeK8OrgNoticesSettingsResource",
        "tags": [
          "K8"
        ],
        "summary": "Change K8 for Notices",
        "x-k8hq-confirm": "k8.org_notices_allowed",
        "description": "An owner or admin changes only `noticesAllowed`. Needs your own sign-in. Turning it on needs a passkey confirmation of this change; other changes need passkey sign-in within five minutes. Keeps the other K8 settings. Members can let K8 read their notices. Each person must also turn on their own Notices switch and confirm each request. This setting starts off and can be changed while K8 HQ for Notices is unavailable. AI use counts toward this organization’s K8 HQ usage.",
        "parameters": [
          {
            "name": "orgId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "noticesAllowed": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "noticesAllowed"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The setting changed.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "ok"
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedConfirm"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "500": {
            "$ref": "#/components/responses/Error"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "404": {
            "description": "They aren't a member (`not_found`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "405": {
            "description": "Method not allowed. The Allow header lists supported methods.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "409": {
            "description": "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`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        },
        "security": [
          {
            "session": []
          }
        ]
      }
    },
    "/v1/organizations/{orgId}/k8-settings/forms": {
      "put": {
        "operationId": "changeK8FormsSettingsResource",
        "tags": [
          "K8"
        ],
        "summary": "Change K8 for Forms",
        "x-k8hq-confirm": "k8.forms_allowed",
        "description": "An owner or admin changes only `formsAllowed`. Needs your own sign-in. Turning it on needs a passkey confirmation of this change; other changes need passkey sign-in within five minutes. Keeps the other K8 settings. You can change this setting while K8 for Forms is unavailable. Turning it on does not make K8 for Forms available or let K8 read forms without your permission for that request.",
        "parameters": [
          {
            "name": "orgId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "formsAllowed": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "formsAllowed"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The setting changed.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "ok"
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedConfirm"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "500": {
            "$ref": "#/components/responses/Error"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "404": {
            "description": "They aren't a member (`not_found`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "405": {
            "description": "Method not allowed. The Allow header lists supported methods.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "409": {
            "description": "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`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        },
        "security": [
          {
            "session": []
          }
        ]
      }
    },
    "/v1/organizations/{orgId}/k8-settings/health": {
      "put": {
        "operationId": "changeK8HealthSettingsResource",
        "tags": [
          "K8"
        ],
        "summary": "Change K8 for Health",
        "x-k8hq-confirm": "k8.health_allowed",
        "description": "An owner or admin changes only `healthAllowed`. Needs your own sign-in. Turning it on needs a passkey confirmation of this change; other changes need passkey sign-in within five minutes. Keeps the other K8 settings. You can change this setting while K8 for Health is unavailable. Turning it on does not make K8 for Health available or let K8 read health without your permission for that request.",
        "parameters": [
          {
            "name": "orgId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "healthAllowed": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "healthAllowed"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The setting changed.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "ok"
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedConfirm"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "500": {
            "$ref": "#/components/responses/Error"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "404": {
            "description": "They aren't a member (`not_found`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "405": {
            "description": "Method not allowed. The Allow header lists supported methods.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "409": {
            "description": "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`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        },
        "security": [
          {
            "session": []
          }
        ]
      }
    },
    "/v1/account/k8-notices": {
      "put": {
        "operationId": "changeK8NoticesSettingsResource",
        "tags": [
          "K8"
        ],
        "summary": "Change your K8 HQ Notices setting",
        "x-k8hq-confirm": "k8.notices_allowed",
        "description": "Only your own sign-in can change this setting. It starts off. Turning it on needs passkey confirmation of k8.notices_allowed; turning it off needs a recent passkey sign-in. Each read still needs your consent. K8 HQ reads only your selected notice messages or release notes and never marks them read. K8 answers are excluded.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "noticesAllowed": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "noticesAllowed"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The setting changed.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "ok"
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedConfirm"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "500": {
            "$ref": "#/components/responses/Error"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "405": {
            "description": "Method not allowed. The Allow header lists supported methods.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "409": {
            "description": "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`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        },
        "security": [
          {
            "session": []
          }
        ]
      },
      "get": {
        "summary": "Your K8 HQ Notices setting",
        "operationId": "getK8NoticesSettings",
        "security": [
          {
            "session": []
          }
        ],
        "responses": {
          "200": {
            "description": "Off unless you turn it on.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "noticesAllowed": {
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "noticesAllowed"
                  ]
                }
              }
            }
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          }
        },
        "tags": [
          "K8"
        ]
      }
    }
  },
  "components": {
    "securitySchemes": {
      "session": {
        "type": "apiKey",
        "in": "header",
        "name": "x-k8hq-token",
        "description": "A person's session: the access token from signing up or in, or from a passkey confirmation."
      },
      "delegated": {
        "type": "apiKey",
        "in": "header",
        "name": "x-k8hq-token",
        "description": "K8 Admin's delegated token (audience `k8hq-k8-admin`), accepted only where an operation lists it, for the organization it was made for, sent with that `orgId`."
      },
      "app": {
        "type": "http",
        "scheme": "bearer",
        "description": "An external app's personal access or manual credential (`k8a1_` or `k8m1_`), sent alone."
      }
    },
    "parameters": {
      "contentSha256": {
        "name": "x-amz-content-sha256",
        "in": "header",
        "required": true,
        "description": "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`.",
        "schema": {
          "type": "string",
          "pattern": "^[0-9a-f]{64}$"
        }
      }
    },
    "responses": {
      "BadRequest": {
        "description": "The request is malformed or a field is invalid (`invalid`).",
        "content": {
          "application/problem+json": {
            "schema": {
              "$ref": "#/components/schemas/Problem"
            }
          }
        }
      },
      "Unauthorized": {
        "description": "No session, or it expired or was revoked (`unauthenticated`): refresh, or sign in again.",
        "content": {
          "application/problem+json": {
            "schema": {
              "$ref": "#/components/schemas/Problem"
            }
          }
        }
      },
      "UnauthorizedStepUp": {
        "description": "No session or it expired (`unauthenticated`), or its passkey confirmation is more than 5 minutes old (`step_up_required`).",
        "content": {
          "application/problem+json": {
            "schema": {
              "$ref": "#/components/schemas/Problem"
            }
          }
        }
      },
      "Forbidden": {
        "description": "Not allowed (`forbidden`): an assistant's delegated token, or a browser origin other than the web app's.",
        "content": {
          "application/problem+json": {
            "schema": {
              "$ref": "#/components/schemas/Problem"
            }
          }
        }
      },
      "NotFound": {
        "description": "No such record, or one you may not see (`not_found`).",
        "content": {
          "application/problem+json": {
            "schema": {
              "$ref": "#/components/schemas/Problem"
            }
          }
        }
      },
      "Error": {
        "description": "A temporary problem (`unavailable`); retry.",
        "content": {
          "application/problem+json": {
            "schema": {
              "$ref": "#/components/schemas/Problem"
            }
          }
        }
      },
      "UnauthorizedConfirm": {
        "description": "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`.",
        "content": {
          "application/problem+json": {
            "schema": {
              "$ref": "#/components/schemas/Problem"
            }
          }
        }
      }
    },
    "schemas": {
      "Challenge": {
        "type": "object",
        "properties": {
          "challengeId": {
            "type": "string",
            "description": "Send it back with the passkey's answer. Valid 5 minutes, once.",
            "pattern": "^chl_"
          },
          "options": {
            "type": "object",
            "properties": {
              "publicKey": {
                "type": "object",
                "description": "WebAuthn `PublicKeyCredentialCreationOptions` (creating a passkey) or `PublicKeyCredentialRequestOptions` (using one), with binary fields as base64url strings."
              }
            },
            "required": [
              "publicKey"
            ],
            "description": "Options for `navigator.credentials.create()` or `.get()`. The relying party is `k8hq.com`; user verification is required, and new passkeys are discoverable (signing in needs no username)."
          }
        },
        "required": [
          "challengeId",
          "options"
        ],
        "description": "The start of a passkey ceremony.",
        "additionalProperties": false
      },
      "Change": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "orgId": {
            "type": "string",
            "description": "The organization (`org_...`).",
            "pattern": "^org_"
          },
          "kind": {
            "type": "string",
            "enum": [
              "role",
              "remove",
              "recovery_action"
            ]
          },
          "memberId": {
            "type": "string",
            "description": "Whom it changes."
          },
          "role": {
            "type": "string",
            "description": "For `role`: the new role."
          },
          "requestedBy": {
            "type": "string",
            "description": "The member who asked (`mem_...`)."
          },
          "description": {
            "type": "string",
            "description": "What it does, in words."
          },
          "status": {
            "type": "string",
            "enum": [
              "pending",
              "approved",
              "declined",
              "cancelled",
              "failed"
            ]
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "expiresAt": {
            "type": "string",
            "description": "A pending change lapses after 7 days.",
            "format": "date-time"
          },
          "requestedAttribution": {
            "$ref": "#/components/schemas/Attribution"
          },
          "updatedAttribution": {
            "$ref": "#/components/schemas/Attribution"
          },
          "action": {
            "type": "object",
            "description": "For recovery_action: the exact action and session another owner is asked to approve."
          }
        },
        "required": [
          "id",
          "orgId",
          "kind",
          "memberId",
          "requestedBy",
          "description",
          "status",
          "createdAt",
          "expiresAt"
        ],
        "description": "A change to people that waits for an owner: a non-owner giving or removing people-power (inviting, assigning roles, removing, suspending). A recovery_action asks another owner to approve a bound organization action during the seven days after account recovery. Approval permits one confirmation; the requester retries the same action after confirming again.",
        "additionalProperties": false
      },
      "Invite": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "orgId": {
            "type": "string",
            "description": "The organization (`org_...`).",
            "pattern": "^org_"
          },
          "role": {
            "type": "string",
            "enum": [
              "guest",
              "member",
              "developer",
              "admin",
              "owner"
            ],
            "description": "The member's organization role: `guest`, `member`, `developer`, `admin` or `owner`. Guest has no organization permissions and cannot list members, domains or roles."
          },
          "containerIds": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Containers it gives access to, besides membership."
          },
          "madeBy": {
            "type": "string",
            "description": "The member who made it (`mem_...`)."
          },
          "status": {
            "type": "string",
            "enum": [
              "pending",
              "accepted",
              "revoked"
            ],
            "description": "`pending` past `expiresAt` has expired."
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "expiresAt": {
            "type": "string",
            "description": "7 days after it was made.",
            "format": "date-time"
          },
          "madeAttribution": {
            "$ref": "#/components/schemas/Attribution"
          }
        },
        "required": [
          "id",
          "orgId",
          "role",
          "madeBy",
          "status",
          "createdAt",
          "expiresAt"
        ],
        "description": "An invitation to join an organization.",
        "additionalProperties": false
      },
      "JWKS": {
        "type": "object",
        "properties": {
          "keys": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "kty": {
                  "const": "EC"
                },
                "crv": {
                  "const": "P-256"
                },
                "use": {
                  "const": "sig"
                },
                "alg": {
                  "const": "ES256"
                },
                "kid": {
                  "type": "string",
                  "description": "Matches the `kid` in access tokens' headers."
                },
                "x": {
                  "type": "string",
                  "description": "base64url"
                },
                "y": {
                  "type": "string",
                  "description": "base64url"
                }
              },
              "required": [
                "kty",
                "crv",
                "use",
                "alg",
                "kid",
                "x",
                "y"
              ],
              "additionalProperties": false
            }
          }
        },
        "required": [
          "keys"
        ],
        "description": "A JSON Web Key Set: the public keys access tokens are signed with.",
        "additionalProperties": false
      },
      "K8Settings": {
        "type": "object",
        "properties": {
          "membersUseK8": {
            "type": "boolean",
            "description": "Members without `k8.use` may use K8 (on unless an owner turns it off)."
          },
          "messagesAllowed": {
            "type": "boolean",
            "description": "K8 Messages, which reads messages, may be turned on for inboxes (off unless an owner turns it on)."
          },
          "boardsAllowed": {
            "type": "boolean",
            "description": "K8 for Boards is allowed by the organization. Off by default; the server rollout must also be enabled."
          },
          "contactsAllowed": {
            "type": "boolean",
            "description": "K8 for Contacts is allowed by the organization. Off by default; the server rollout must also be enabled."
          },
          "noticesAllowed": {
            "type": "boolean",
            "description": "Members can let K8 read their notices. Off by default; each person must also turn on their own switch and confirm each request."
          },
          "formsAllowed": {
            "type": "boolean",
            "description": "K8 for Forms is allowed by the organization. Off by default; the server rollout must also be enabled."
          },
          "healthAllowed": {
            "type": "boolean",
            "description": "K8 for Health is allowed by the organization. Off by default; the server rollout must also be enabled."
          }
        },
        "required": [
          "membersUseK8",
          "messagesAllowed",
          "boardsAllowed",
          "contactsAllowed",
          "noticesAllowed",
          "formsAllowed",
          "healthAllowed"
        ],
        "description": "An organization's K8 settings (design note 0010).",
        "additionalProperties": false
      },
      "KeyWrap": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "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": {
            "type": "string",
            "enum": [
              "prf",
              "recovery"
            ],
            "description": "`prf`: sealed with a passkey's PRF secret; `recovery`: sealed with the recovery kit's secret."
          },
          "credentialId": {
            "type": "string",
            "description": "For `prf`: the passkey's credential ID (base64url)."
          },
          "salt": {
            "type": "string",
            "description": "The HKDF salt, 32 bytes, standard base64.",
            "contentEncoding": "base64"
          },
          "wrapped": {
            "type": "string",
            "description": "AES-256-GCM (nonce, then ciphertext) of the private key bundle, 28 to 1024 bytes, standard base64. K8 HQ can't open it.",
            "contentEncoding": "base64"
          },
          "createdAt": {
            "type": "string",
            "description": "Set by K8 HQ.",
            "format": "date-time"
          }
        },
        "required": [
          "id",
          "kind",
          "salt",
          "wrapped"
        ],
        "description": "The person's private key, sealed with a secret only they hold (design note 0003).",
        "additionalProperties": false
      },
      "Member": {
        "type": "object",
        "properties": {
          "memberId": {
            "type": "string"
          },
          "role": {
            "type": "string",
            "enum": [
              "guest",
              "member",
              "developer",
              "admin",
              "owner"
            ],
            "description": "The member's organization role: `guest`, `member`, `developer`, `admin` or `owner`. Guest has no organization permissions and cannot list members, domains or roles."
          },
          "name": {
            "type": "string",
            "description": "Their display name; empty if they chose none."
          },
          "you": {
            "type": "boolean",
            "description": "This is the caller."
          },
          "suspendedUntil": {
            "type": "string",
            "description": "Set while they're suspended.",
            "format": "date-time"
          }
        },
        "required": [
          "memberId",
          "role",
          "name",
          "you"
        ],
        "description": "A member of an organization.",
        "additionalProperties": false
      },
      "Notice": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "The event (`evt_...`).",
            "pattern": "^evt_"
          },
          "seq": {
            "type": "string",
            "description": "Its place in the person's stream, 20 digits. Archive and delete name a notice by `id` and `seq`.",
            "pattern": "^[0-9]{20}$"
          },
          "kind": {
            "type": "string",
            "enum": [
              "passkey_added",
              "passkey_removed",
              "signin_new_network",
              "token_new_network",
              "signup_invite_used",
              "member_removed",
              "member_left",
              "userkey_server_copy_released",
              "policy_change"
            ]
          },
          "title": {
            "type": "string"
          },
          "text": {
            "type": "string",
            "description": "What happened and what to do, ending with how to tell a real notice from a fake one. Paragraphs separated by a blank line; no links."
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "archived": {
            "type": "boolean",
            "description": "Read."
          },
          "network": {
            "type": "string",
            "description": "The /24 or /48 network it came from, where it applies."
          },
          "country": {
            "type": "string",
            "description": "The ISO 3166 country code CloudFront saw, where known."
          },
          "orgId": {
            "type": "string",
            "description": "The organization (`org_...`).",
            "pattern": "^org_"
          },
          "org": {
            "type": "string",
            "description": "The organization's display name, cleaned."
          },
          "url": {
            "type": "string",
            "format": "uri",
            "description": "A policy change's new version on K8 HQ's website, for the app to link. Never in `text`."
          }
        },
        "required": [
          "id",
          "seq",
          "kind",
          "title",
          "text",
          "createdAt",
          "archived"
        ],
        "description": "An account notice: something that changed on the person's account (design note 0012).",
        "additionalProperties": false
      },
      "NoticeRef": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^evt_"
          },
          "seq": {
            "type": "string",
            "pattern": "^[0-9]{20}$"
          }
        },
        "required": [
          "id",
          "seq"
        ],
        "description": "Names one notice."
      },
      "Ok": {
        "type": "object",
        "properties": {
          "ok": {
            "const": true
          }
        },
        "required": [
          "ok"
        ],
        "description": "Done.",
        "additionalProperties": false
      },
      "OrgToken": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^tok_"
          },
          "label": {
            "type": "string"
          },
          "memberId": {
            "type": "string",
            "description": "The member it acts for (`mem_...`)."
          },
          "scopes": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "containerIds": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "type": "string"
            },
            "description": "The containers it's narrowed to; null for all its member's."
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "expiresAt": {
            "type": "string",
            "description": "When it expires; empty for never."
          },
          "lastUsedAt": {
            "type": "string",
            "description": "When it was last used, to within an hour; empty for never. Where from isn't shown here: that's its member's to see."
          },
          "kind": {
            "type": "string",
            "enum": [
              "bounded_http"
            ],
            "description": "Present for an agent-issued bounded personal HTTP credential; legacy tokens omit this field."
          },
          "appId": {
            "type": "string",
            "pattern": "^app_"
          },
          "connectionId": {
            "type": "string",
            "pattern": "^cnx_"
          },
          "ceiling": {
            "type": "object",
            "description": "The bounded HTTP credential’s frozen permission and content-capability declaration. Every request also needs its current personal user, resource, application, approval, consent and credential authority."
          }
        },
        "required": [
          "id",
          "label",
          "memberId",
          "scopes",
          "containerIds",
          "createdAt",
          "expiresAt",
          "lastUsedAt"
        ],
        "description": "A token in an organization, as its owners and admins see it.",
        "additionalProperties": false
      },
      "Passkey": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "The credential ID, base64url."
          },
          "provider": {
            "type": "string",
            "description": "Where the passkey lives, when its authenticator says (such as `iCloud Keychain`, `Google Password Manager`, `1Password`); else `Passkey` or `Security key or passkey provider`."
          },
          "addedAt": {
            "type": "string",
            "format": "date-time"
          },
          "lastUsedAt": {
            "type": "string",
            "description": "Its last sign-in or confirmation.",
            "format": "date-time"
          },
          "unlocks": {
            "type": "boolean",
            "description": "A copy of the person's key is sealed with this passkey's PRF secret, so it can unlock zero-access inboxes."
          }
        },
        "required": [
          "id",
          "provider",
          "addedAt",
          "unlocks"
        ],
        "description": "One of a person's passkeys.",
        "additionalProperties": false
      },
      "Problem": {
        "type": "object",
        "description": "An RFC 9457 problem detail.",
        "required": [
          "type",
          "title",
          "status",
          "code"
        ],
        "properties": {
          "type": {
            "type": "string",
            "format": "uri",
            "description": "This page's explanation of the code."
          },
          "title": {
            "type": "string"
          },
          "status": {
            "type": "integer"
          },
          "code": {
            "type": "string",
            "enum": [
              "invalid",
              "unauthenticated",
              "step_up_required",
              "forbidden",
              "approval_required",
              "not_found",
              "conflict",
              "service_disabled",
              "read_only",
              "rate_limited",
              "invite_required",
              "invite_used",
              "org_invite_no_domain",
              "org_signup_limit",
              "policy_acceptance_required",
              "policy_outdated",
              "no_invites_left",
              "not_for_you",
              "exists",
              "too_many",
              "shared_inbox",
              "address_blocked",
              "confirmations_limit",
              "wrong_code",
              "code_expired",
              "too_many_tries",
              "not_pending",
              "changes_limit",
              "no_server_copy",
              "zero_access",
              "wrap_exists",
              "unavailable",
              "confirmation_required",
              "confirmation_invalid",
              "confirmation_expired",
              "confirmation_mismatch",
              "confirmation_used",
              "needs_person",
              "invalid_action",
              "recovery_unavailable",
              "challenge_expired",
              "invalid_proof",
              "keys_bound",
              "revoked",
              "no_key",
              "key_retired",
              "key_exposed",
              "recently_recovered",
              "owner_only",
              "last_holder",
              "rotation_backlog",
              "in_progress",
              "report_too_large",
              "key_in_use",
              "client_outdated",
              "browser_mismatch",
              "browser_unbound",
              "browser_changed"
            ],
            "description": "Stable: branch on this.",
            "x-enumDescriptions": {
              "invalid": "400 (also 405 and 410): malformed or refused input; `detail` says what. 410 here is an invite link that isn't valid any more.",
              "unauthenticated": "401: no session, or it expired or was revoked: refresh, or sign in again. Also a passkey that isn't recognized.",
              "step_up_required": "401: the action needs a passkey used in the last 5 minutes. Run [Start a passkey confirmation](#stepUpBegin) and [Finish it](#stepUpFinish), then retry with the new access token.",
              "forbidden": "403: not allowed: the member's role or permissions, an assistant's delegated token where it isn't accepted, or a browser `Origin` other than the web app's.",
              "approval_required": "403: This connection needs approval for that, and approval isn't available yet.",
              "not_found": "404: no such record, or one you may not see (organizations you aren't in answer the same way).",
              "conflict": "409: refused by the current state, such as the last passkey or the last owner.",
              "service_disabled": "403: K8 is disabled for this organization; an owner or admin can enable it in Services settings.",
              "read_only": "402: the organization is read-only because it's out of credit (design note 0024): nobody can be invited to it or join it until an owner adds credit.",
              "rate_limited": "429: too many requests from this network (wait a few minutes), too many failed passkey ceremonies (wait 15 minutes), or today's invites are made.",
              "invite_required": "403: signing up needs an invitation: a sign-up invitation or an organization's invite link.",
              "invite_used": "410: the sign-up invitation was used, revoked or has expired.",
              "org_invite_no_domain": "403: the organization's invite can't sign up new people until the organization proves a domain.",
              "org_signup_limit": "429: the organization has signed up as many new people as it may today.",
              "policy_acceptance_required": "400: accept the current Terms of Service and Privacy Policy: name each current version in `accepted`.",
              "policy_outdated": "409: a policy version named isn't the current one (or isn't published): fetch the current versions and ask the person again.",
              "no_invites_left": "409: the person has no sign-up invitations left; revoked and expired ones come back.",
              "not_for_you": "404: a notice link that isn't for the signed-in person (or was changed, or made up). Every real notice is also in Notices.",
              "exists": "409: that inbox or address is already one of the person's destinations.",
              "too_many": "409: the person has as many destinations as allowed (3 outside addresses, 5 inboxes).",
              "shared_inbox": "409: others use this inbox too: show `detail` (what they'd see) and retry with `sharedOk` if the person still wants it.",
              "address_blocked": "409: whoever reads this address said a K8 HQ confirmation mail wasn't for them; K8 HQ won't email it again.",
              "confirmations_limit": "429: the person has had today's 5 confirmation emails.",
              "wrong_code": "400: the confirmation code isn't right (or hasn't arrived yet).",
              "code_expired": "410: the confirmation code has expired: send a new one.",
              "too_many_tries": "429: too many wrong codes: send a new one.",
              "not_pending": "409: the destination isn't waiting for a confirmation code.",
              "changes_limit": "429: the person has made today's 20 destination changes (each is a security notice to every destination).",
              "no_server_copy": "404: K8 HQ keeps no copy of the person's key; unlock with a passkey that supports it, or the recovery kit.",
              "zero_access": "409: the person uses a zero-access inbox, which needs their own key, so K8 HQ can't keep a copy of it.",
              "wrap_exists": "409: the person's key already has a wrap with that ID. Wraps are never replaced; add the new one under a new ID.",
              "unavailable": "500 or 503: a temporary problem on K8 HQ's side; retry with backoff.",
              "confirmation_required": "401: the change needs a passkey confirmation of exactly it (design note 0013). The answer carries `action` (the description to confirm) and a short `summary`: send `action` to [Begin a confirmation](/auth/docs#confirmBegin), run the passkey prompt, [finish it](/auth/docs#confirmFinish) and retry the same request with the confirmation in `x-k8hq-confirm`. Asking with `x-k8hq-confirm: ?` gets this answer without the change being made.",
              "confirmation_invalid": "403: the confirmation isn't valid for this session (another session's or person's, or not signed by K8 HQ): confirm again.",
              "confirmation_expired": "409: the confirmation timed out (it lives 2 minutes): confirm again.",
              "confirmation_mismatch": "409: the change isn't the one confirmed: the request, or what it changes, is different now. Show the current state and let the person confirm again; never retry silently.",
              "confirmation_used": "409: the confirmation was already used (each confirms one change, once): confirm again.",
              "needs_person": "403: only a person signed in to K8 HQ can make this change with a passkey confirmation, never an API token or an assistant.",
              "invalid_action": "400: that isn't a change K8 HQ can confirm (not a route's description, another session's, or an invalid list). 409: the saved list of changes is no longer valid at confirmation finish.",
              "recovery_unavailable": "400: The recovery code is wrong or expired, or the recovery no longer meets the checks. Ask for a new code.",
              "challenge_expired": "409: the pairing request or the binding's confirmation deadline passed; start pairing again with new keys.",
              "invalid_proof": "422: a proof of possession or a signature didn't verify.",
              "keys_bound": "409: these public keys are already bound; generate new keys.",
              "revoked": "409: the binding was revoked or replaced.",
              "no_key": "409: the person has no key yet: set one up first.",
              "key_retired": "409: the new key was this person's before and was replaced; a replaced key never comes back. Make a new one.",
              "key_exposed": "409: the new key was reported as possibly exposed. Make a new one.",
              "recently_recovered": "403: the person recovered their account by email in the last 7 days; `until` says when the change becomes possible.",
              "owner_only": "403: only an owner of the organization may do this.",
              "last_holder": "409: the change would leave a zero-access inbox with nobody who can open it.",
              "rotation_backlog": "503: K8 HQ is still updating an inbox's encryption after earlier changes; retry after `Retry-After` seconds.",
              "in_progress": "409: the inbox's switch to zero-access isn't finished yet.",
              "report_too_large": "409: the report would be too large for one change: report at most two people at once, or one at a time.",
              "key_in_use": "409: the new key belongs to another account; every key has one owner. Make a new one.",
              "client_outdated": "426: K8 HQ has been updated. Reload this page.",
              "browser_mismatch": "409: the session signed in from this browser before its storage was reset (`DELETE /v1/account/browser-sessions`): the browser's other sessions can't be found from it. Nothing was signed out; sign this session out with `DELETE /v1/account/session` and use Sign out everywhere for the rest.",
              "browser_unbound": "409: the session is from before browser secrets (`DELETE /v1/account/browser-sessions`). Nothing was signed out; sign this session out with `DELETE /v1/account/session` instead.",
              "browser_changed": "409: the browser was signed out (`DELETE /v1/account/browser-sessions`) while this sign-in completed, so no session started. Start the sign-in again."
            }
          },
          "detail": {
            "type": "string",
            "description": "For people; may change."
          },
          "until": {
            "type": "string",
            "format": "date-time",
            "description": "With `recently_recovered`: when the change becomes possible."
          }
        }
      },
      "ServerCopy": {
        "type": "object",
        "properties": {
          "enabledAt": {
            "type": "string",
            "format": "date-time",
            "description": "When it was turned on."
          }
        },
        "required": [
          "enabledAt"
        ],
        "additionalProperties": false,
        "description": "K8 HQ keeps a copy of the person's key (design note 0003 section 11)."
      },
      "SignupInvite": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^siv_"
          },
          "status": {
            "type": "string",
            "enum": [
              "pending",
              "accepted",
              "revoked"
            ],
            "description": "`pending` past `expiresAt` has expired."
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "expiresAt": {
            "type": "string",
            "description": "14 days after it was made.",
            "format": "date-time"
          },
          "usedAt": {
            "type": "string",
            "description": "When someone signed up with it.",
            "format": "date-time"
          }
        },
        "required": [
          "id",
          "status",
          "createdAt",
          "expiresAt"
        ],
        "description": "A sign-up invitation a person made.",
        "additionalProperties": false
      },
      "Suspension": {
        "type": "object",
        "properties": {
          "memberId": {
            "type": "string"
          },
          "by": {
            "type": "string",
            "description": "The member who suspended them."
          },
          "until": {
            "type": "string",
            "description": "24 hours after it began.",
            "format": "date-time"
          },
          "attribution": {
            "$ref": "#/components/schemas/Attribution"
          }
        },
        "required": [
          "memberId",
          "by",
          "until"
        ],
        "description": "A member's suspension: no access to the organization until it ends or is lifted.",
        "additionalProperties": false
      },
      "Token": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "The token's ID (`tok_...`), not its secret.",
            "pattern": "^tok_"
          },
          "label": {
            "type": "string"
          },
          "orgId": {
            "type": "string",
            "description": "The organization (`org_...`).",
            "pattern": "^org_"
          },
          "scopes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "What it may do; see the content API's description of scopes."
          },
          "containerIds": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The containers it's narrowed to; absent for all the member's."
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "expiresAt": {
            "type": "string",
            "description": "Absent for a token that doesn't expire.",
            "format": "date-time"
          },
          "lastUsedAt": {
            "type": "string",
            "description": "When it was last used (an API request, or a mail app signing in or staying signed in), to within an hour. Absent if it hasn't been used.",
            "format": "date-time"
          },
          "lastUsedNetwork": {
            "type": "string",
            "description": "The network it was last used from: the /24 (IPv4) or /48 (IPv6) around the client, as in a new-network notice. Absent if unknown."
          },
          "kind": {
            "type": "string",
            "enum": [
              "bounded_http"
            ],
            "description": "Present for an agent-issued bounded personal HTTP credential; legacy tokens omit this field."
          },
          "appId": {
            "type": "string",
            "pattern": "^app_"
          },
          "connectionId": {
            "type": "string",
            "pattern": "^cnx_"
          },
          "ceiling": {
            "type": "object",
            "description": "The bounded HTTP credential’s frozen permission and content-capability declaration. Every request also needs its current personal user, resource, application, approval, consent and credential authority."
          },
          "state": {
            "type": "string",
            "enum": [
              "active",
              "expired",
              "revoked"
            ]
          }
        },
        "required": [
          "id",
          "label",
          "orgId",
          "scopes",
          "createdAt"
        ],
        "description": "One of a person's access tokens.",
        "additionalProperties": false
      },
      "Tokens": {
        "type": "object",
        "properties": {
          "accessToken": {
            "type": "string",
            "description": "Send it as `x-k8hq-token` to this API, the Setup API and the content API. A JWT, valid 15 minutes."
          },
          "accessExpiresAt": {
            "type": "string",
            "description": "When the access token expires; refresh before then.",
            "format": "date-time"
          },
          "refreshToken": {
            "type": "string",
            "description": "Exchange at [Refresh a session](#refresh) for new tokens. Works once; keep it secret (the web app keeps it in local storage). Absent after a passkey confirmation, which keeps the session's refresh token."
          }
        },
        "required": [
          "accessToken",
          "accessExpiresAt"
        ],
        "description": "A session's tokens.",
        "additionalProperties": false
      },
      "UserKey": {
        "type": "object",
        "properties": {
          "x25519": {
            "type": "string",
            "description": "The public X25519 key (for sealing inbox keys to the person), 32 bytes, standard base64.",
            "contentEncoding": "base64"
          },
          "ed25519": {
            "type": "string",
            "description": "The public Ed25519 key (signing), 32 bytes, standard base64.",
            "contentEncoding": "base64"
          },
          "wraps": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/KeyWrap"
            },
            "description": "Sealed copies of the private keys: 1 to 20, at least one `recovery`."
          },
          "suite": {
            "$ref": "#/components/schemas/HPKESuite"
          }
        },
        "required": [
          "x25519",
          "ed25519",
          "wraps"
        ],
        "description": "A person's key pair for zero-access inboxes: the public halves, and the private halves sealed on their devices.",
        "additionalProperties": false
      },
      "Destination": {
        "type": "object",
        "description": "Where copies of a person's notices go besides Notices. Copies to an outside address carry an organization notice's subject only.",
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^dst_"
          },
          "kind": {
            "enum": [
              "inbox",
              "email"
            ],
            "description": "An inbox the person can use in one of their organizations, or an outside address (an inbox in an organization they aren't in is one)."
          },
          "status": {
            "enum": [
              "active",
              "pending",
              "confirmed",
              "blocked"
            ],
            "description": "Inboxes are `active` at once; outside addresses are `pending` until their code is typed, and `blocked` if their reader said the mail wasn't for them."
          },
          "orgId": {
            "type": "string"
          },
          "inboxId": {
            "type": "string"
          },
          "address": {
            "type": "string",
            "description": "An outside address (as the person typed it, lowercased)."
          },
          "routes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "`security`, `account`, and `org:<org_id>` for an organization's notices (organizations the person is in)."
          },
          "announcementMutes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Organizations whose optional service announcements are not copied to this destination. This does not mute security, account or other organization notices. Omitted when none are saved."
          },
          "sharedOk": {
            "type": "boolean",
            "description": "The person was warned that others use this inbox, and chose it anyway."
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "confirmedAt": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "id",
          "kind",
          "status",
          "routes",
          "createdAt"
        ],
        "additionalProperties": false
      },
      "LinkTarget": {
        "type": "object",
        "description": "What a notice link opens: an account notice, or an organization notice in the person's personal notice inbox there (read it with the Content API).",
        "properties": {
          "kind": {
            "enum": [
              "account",
              "org"
            ]
          },
          "notice": {
            "$ref": "#/components/schemas/Notice"
          },
          "orgId": {
            "type": "string"
          },
          "inboxId": {
            "type": "string"
          },
          "messageId": {
            "type": "string"
          }
        },
        "required": [
          "kind"
        ],
        "additionalProperties": false
      },
      "PolicyVersion": {
        "type": "object",
        "description": "A published version of K8 HQ's Terms of Service or Privacy Policy. A version's ID is its effective date.",
        "properties": {
          "doc": {
            "type": "string",
            "enum": [
              "terms",
              "privacy"
            ]
          },
          "title": {
            "type": "string",
            "description": "The document's name, e.g. Terms of Service."
          },
          "version": {
            "type": "string",
            "description": "The version: its effective date (YYYY-MM-DD, from 00:00 UTC).",
            "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}$"
          },
          "effective": {
            "type": "string",
            "format": "date",
            "description": "When it takes effect (the same date as `version`)."
          },
          "url": {
            "type": "string",
            "format": "uri",
            "description": "This version's own page on K8 HQ's website."
          },
          "summary": {
            "type": "string",
            "description": "What changed from the previous version, in a sentence or two."
          },
          "sha256": {
            "type": "string",
            "pattern": "^[0-9a-f]{64}$",
            "description": "The SHA-256 of the version's binding text on its page (the HTML between `<!-- policy-text -->` and `<!-- /policy-text -->`, ASCII whitespace runs made one space, ends trimmed). A version's text never changes: any edit is a new version."
          }
        },
        "required": [
          "doc",
          "title",
          "version",
          "effective",
          "url",
          "summary",
          "sha256"
        ],
        "additionalProperties": false
      },
      "Accepted": {
        "type": "object",
        "description": "The versions the person accepts, by document: each must be the current version or a newer published one.",
        "properties": {
          "terms": {
            "type": "string",
            "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}$"
          },
          "privacy": {
            "type": "string",
            "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}$"
          }
        },
        "additionalProperties": false
      },
      "Attribution": {
        "type": "object",
        "description": "Where a sign-up came from, from the link that brought the person to K8 HQ's website (carried on its links; nothing is stored in the browser). Each field is optional; a field that doesn't pass its check is dropped, not refused. Kept with the account for 24 months and reported only as totals.",
        "properties": {
          "utm_source": {
            "type": "string",
            "maxLength": 100,
            "description": "The campaign source tag (letters, digits, spaces and `._~+-`)."
          },
          "utm_medium": {
            "type": "string",
            "maxLength": 100
          },
          "utm_campaign": {
            "type": "string",
            "maxLength": 100
          },
          "ref": {
            "type": "string",
            "maxLength": 100,
            "description": "A referral tag."
          },
          "referrer": {
            "type": "string",
            "description": "The referring site: only its domain is kept (a URL is cut down to its host)."
          },
          "landing": {
            "type": "string",
            "maxLength": 200,
            "description": "The first page landed on: a path on k8hq.com, without a query."
          }
        }
      },
      "Action": {
        "type": "object",
        "description": "An action description (design note 0013): what a confirmation names. The route that makes the change builds it from the request and the current state and checks a confirmation against its hash; send it back unchanged. Closed: `v`, `kind`, `svc`, `sub`, `sid`, `org`, `target` and `params` (the kind's fields), IDs rather than names.",
        "properties": {
          "v": {
            "type": "integer"
          },
          "kind": {
            "type": "string",
            "description": "What kind of change, e.g. `member.role`, `forward.create`."
          },
          "svc": {
            "type": "string",
            "enum": [
              "auth",
              "setup",
              "content"
            ]
          },
          "sub": {
            "type": "string"
          },
          "sid": {
            "type": "string"
          },
          "org": {
            "type": "string"
          },
          "target": {
            "type": "string"
          },
          "params": {
            "type": "object"
          }
        },
        "required": [
          "v",
          "kind",
          "svc",
          "sub",
          "sid",
          "params"
        ]
      },
      "HPKESuite": {
        "type": "object",
        "description": "The HPKE IDs for this key: KEM 32 (X25519), KDF 1 (HKDF-SHA256), AEAD 2 (AES-256-GCM). If absent on an older record, use these IDs. Refuse any other suite.",
        "properties": {
          "kem": {
            "type": "integer",
            "minimum": 1,
            "maximum": 65535
          },
          "kdf": {
            "type": "integer",
            "minimum": 1,
            "maximum": 65535
          },
          "aead": {
            "type": "integer",
            "minimum": 1,
            "maximum": 65535
          }
        },
        "required": [
          "kem",
          "kdf",
          "aead"
        ],
        "additionalProperties": false
      },
      "AgentKeyBinding": {
        "type": "object",
        "description": "A recipient binding: the signed binding `B` (A.2 transport: unpadded base64url bytes, decimal-string integers), the app's signature, its state and, for a person, its confirmation deadline and fingerprint.",
        "properties": {
          "schemaVersion": {
            "type": "integer"
          },
          "binding": {
            "type": "object"
          },
          "agentSignature": {
            "type": "string"
          },
          "state": {
            "type": "string",
            "enum": [
              "pending",
              "verified",
              "revoked"
            ]
          },
          "confirmBy": {
            "type": "string",
            "description": "Unix seconds the person must confirm a pending binding by (24 hours, at most the connection's expiry)."
          },
          "fingerprint": {
            "type": "string",
            "description": "The full binding fingerprint, lowercase hex."
          },
          "authority": {
            "type": "string",
            "enum": [
              "active",
              "revoked"
            ]
          },
          "pairingSignerId": {
            "type": "string"
          },
          "pairingSignature": {
            "type": "string"
          },
          "display": {
            "type": "object",
            "description": "Trusted display identities from K8 HQ's records, never from the app: the app and its publisher from the app registry, the key provider (the app itself when self-hosted) and the organization's name. Only on the person's read.",
            "properties": {
              "app": {
                "type": "object",
                "properties": {
                  "id": {
                    "type": "string"
                  },
                  "name": {
                    "type": "string"
                  }
                }
              },
              "publisher": {
                "type": "object",
                "properties": {
                  "id": {
                    "type": "string"
                  },
                  "domain": {
                    "type": "string"
                  },
                  "domainVerified": {
                    "type": "boolean"
                  }
                }
              },
              "provider": {
                "type": "object",
                "properties": {
                  "id": {
                    "type": "string"
                  },
                  "name": {
                    "type": "string"
                  },
                  "selfHosted": {
                    "type": "boolean"
                  }
                }
              },
              "organization": {
                "type": "object",
                "properties": {
                  "id": {
                    "type": "string"
                  },
                  "name": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "required": [
          "schemaVersion"
        ]
      }
    }
  }
}
