{
  "openapi": "3.1.0",
  "info": {
    "title": "KeyKeeper Mail and Custom Domain API",
    "version": "2.13.0",
    "description": "Create a mailbox, receive and read mail, and send with existing credits. Receiving and reading are free. New agents start with zero sending credits. A $1 card or native USDC top-up buys 10,000 mail credits for standard sending. New senders start with up to 10 recipients/day and 3/minute; the plan limit applies if lower. Buying credits does not raise sending permissions. Higher-volume use has separate pricing and review. See /docs/sending-safety. Agent mail uses API keys. Custom-domain management at /api/user/domains accepts owner sessions, full agent account keys and explicit domains:read/domains:write keys. Mail-only keys have no domain authority. DNS preparation is free; address creation requires paid owner access. See /docs/domains#api.",
    "contact": {
      "url": "https://keykeeper.world/docs"
    }
  },
  "servers": [
    {
      "url": "https://keykeeper.world"
    }
  ],
  "paths": {
    "/api/v1/agent/sending": {
      "get": {
        "operationId": "getSendingStatus",
        "summary": "Inspect sending permissions",
        "description": "Returns your probation, standard, reviewed or paused state, current per-account limits and review status. Readable by full and limited keys. Shared and related-mailbox caps also apply. /docs/sending-safety.",
        "security": [
          {
            "agentKey": []
          }
        ],
        "tags": [
          "Agent mail"
        ],
        "parameters": [],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SendingStatus"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Insufficient sending credits",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Account or sender not permitted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Message not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Conflict or unresolved previous send",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Payload or message too large",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Callback ownership verification failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Request or daily sending limit",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "Internal error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "Mail submission failed or outcome unknown",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Dependency or feature unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "requestSenderReview",
        "summary": "Request a sending review",
        "description": "Full account key required. Three requests per day. Requests never grant sending permission automatically; repeated requests retain the first pending purpose.",
        "security": [
          {
            "agentKey": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SenderReviewRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Review requested",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SenderReviewResult"
                }
              }
            }
          },
          "400": {
            "description": "Invalid purpose",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Invalid key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Full account key required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Request limit reached",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/agent/register": {
      "post": {
        "operationId": "registerAgent",
        "summary": "Create an agent mailbox",
        "description": "Creates an account and mailbox together. Save the API key from this response: it cannot be retrieved later. No payment is required. Registration is limited to five requests per IP per hour.",
        "security": [],
        "tags": [
          "Agent mail"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RegisterAgent"
              }
            }
          }
        },
        "parameters": [],
        "responses": {
          "201": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AgentAccount"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Insufficient sending credits",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Account or sender not permitted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Message not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Conflict or unresolved previous send",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Payload or message too large",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Callback ownership verification failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Request or daily sending limit",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "Internal error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "Mail submission failed or outcome unknown",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Dependency or feature unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/agent/inbox": {
      "get": {
        "operationId": "listInbox",
        "summary": "List messages",
        "description": "Lists recent messages, newest first. Receiving and reading do not spend credits. Message IDs are IMAP UIDs scoped to a folder.",
        "security": [
          {
            "agentKey": []
          }
        ],
        "tags": [
          "Agent mail"
        ],
        "parameters": [
          {
            "name": "folder",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "default": "INBOX"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            }
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 0,
              "default": 0
            }
          },
          {
            "name": "search",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 200
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Inbox"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Insufficient sending credits",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Account or sender not permitted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Message not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Conflict or unresolved previous send",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Payload or message too large",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Callback ownership verification failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Request or daily sending limit",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "Internal error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "Mail submission failed or outcome unknown",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Dependency or feature unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/agent/email/{id}": {
      "get": {
        "operationId": "readMessage",
        "summary": "Read a message",
        "description": "Reads the full message and inline attachment content. Full account keys mark it read unless markAsRead=false; limited keys always read without changing flags and reject markAsRead=true. Messages over 10 MB require an IMAP client.",
        "security": [
          {
            "agentKey": []
          }
        ],
        "tags": [
          "Agent mail"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[1-9][0-9]{0,9}$"
            }
          },
          {
            "name": "folder",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "default": "INBOX"
            }
          },
          {
            "name": "markAsRead",
            "in": "query",
            "required": false,
            "schema": {
              "type": "boolean"
            },
            "description": "Full account keys default to true; limited keys require false or omission."
          },
          {
            "name": "uidValidity",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^[1-9][0-9]{0,9}$"
            },
            "description": "Reject reused message UIDs after a mailbox identity change"
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Message"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Insufficient sending credits",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Account or sender not permitted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Message not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Conflict or unresolved previous send",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Payload or message too large",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Callback ownership verification failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Request or daily sending limit",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "Internal error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "Mail submission failed or outcome unknown",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Dependency or feature unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/agent/email/{id}/raw": {
      "get": {
        "operationId": "readRawMessage",
        "summary": "Download a message exactly as received",
        "description": "Returns the message's original bytes as message/rfc822 (an .eml file), headers and DKIM signatures intact, so its authenticity can be checked later. Never changes flags; limited keys need mail:read. Optional uidValidity rejects a UID reused after a mailbox identity change; the response header X-Mailbox-UID-Validity reports the current value. Messages over 16 MB require an IMAP client.",
        "security": [
          {
            "agentKey": []
          }
        ],
        "tags": [
          "Agent mail"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[1-9][0-9]{0,9}$"
            }
          },
          {
            "name": "folder",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "default": "INBOX"
            }
          },
          {
            "name": "uidValidity",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^[1-9][0-9]{0,9}$"
            },
            "description": "Reject reused message UIDs after a mailbox identity change"
          }
        ],
        "responses": {
          "200": {
            "description": "The message exactly as received (RFC 5322)",
            "headers": {
              "X-Mailbox-UID-Validity": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "message/rfc822": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Insufficient sending credits",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Account or sender not permitted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Message not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Conflict or unresolved previous send",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Payload or message too large",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Callback ownership verification failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Request or daily sending limit",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "Internal error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "Mail submission failed or outcome unknown",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Dependency or feature unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/agent/balance": {
      "get": {
        "operationId": "getBalance",
        "summary": "Check the account and credits",
        "description": "Returns the mailbox address, account state and sending credit balance.",
        "security": [
          {
            "agentKey": []
          }
        ],
        "tags": [
          "Agent mail"
        ],
        "parameters": [],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Balance"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Insufficient sending credits",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Account or sender not permitted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Message not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Conflict or unresolved previous send",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Payload or message too large",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Callback ownership verification failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Request or daily sending limit",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "Internal error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "Mail submission failed or outcome unknown",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Dependency or feature unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/agent/send": {
      "post": {
        "operationId": "sendEmail",
        "summary": "Send prepaid mail",
        "description": "Costs one credit per accepted recipient across To, Cc and Bcc. Use the same Idempotency-Key and message for retries. SMTP acceptance is not proof of delivery to a remote inbox. Add mail credits by card or native USDC on Polygon.",
        "security": [
          {
            "agentKey": []
          }
        ],
        "tags": [
          "Agent mail"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SendMessage"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 128
            },
            "description": "Strongly recommended. Reuse the same key and message after a timeout."
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SendResult"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Insufficient sending credits",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Account or sender not permitted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Message not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Conflict or unresolved previous send",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Payload or message too large",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Callback ownership verification failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Request or daily sending limit",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "Internal error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "Mail submission failed or outcome unknown",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Dependency or feature unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/agent/keys": {
      "post": {
        "operationId": "rotateAgentKey",
        "summary": "Rotate an agent key",
        "description": "Use the current key to prepare a replacement, save and test it, then authenticate with the replacement to activate it and revoke the old key. Both keys work for 30 minutes before activation. Cancel a lost replacement using the original key. One replacement at a time; 12 mutations per account per 15 minutes. GET on this route returns rotation state without secrets.",
        "security": [
          {
            "agentKey": []
          }
        ],
        "tags": [
          "Agent mail"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/KeyAction"
              }
            }
          }
        },
        "parameters": [],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/KeyActionResult"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Insufficient sending credits",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Account or sender not permitted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Message not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Conflict or unresolved previous send",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Payload or message too large",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Callback ownership verification failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Request or daily sending limit",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "Internal error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "Mail submission failed or outcome unknown",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Dependency or feature unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "get": {
        "operationId": "getAgentKeyState",
        "summary": "Inspect rotation state without revealing keys",
        "security": [
          {
            "agentKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "Mailbox address, replacementPending, replacementExpiresAt, lastRotatedAt, authenticatedWithReplacement"
          },
          "401": {
            "description": "Invalid API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/agent/access-keys": {
      "post": {
        "operationId": "createAccessKey",
        "summary": "Give an integration limited access",
        "description": "Full account key required. Issue a separately revocable mail or domain key with expiry, exact sending addresses, recipient restrictions and daily/total recipient budgets. GET lists up to 100 keys (active first) without secrets. Limited keys cannot manage keys, purchase credits, change webhooks, use escrow, or access SMTP/IMAP directly. Use /ai/keys for the management screen.",
        "security": [
          {
            "agentKey": []
          }
        ],
        "tags": [
          "Agent mail"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AccessKeyCreate"
              }
            }
          }
        },
        "parameters": [],
        "responses": {
          "201": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AccessKeyCreated"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Insufficient sending credits",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Account or sender not permitted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Message not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Conflict or unresolved previous send",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Payload or message too large",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Callback ownership verification failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Request or daily sending limit",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "Internal error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "Mail submission failed or outcome unknown",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Dependency or feature unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "get": {
        "operationId": "listAccessKeys",
        "summary": "List access-key metadata, active keys first",
        "security": [
          {
            "agentKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "email and keys array; key secrets and digests are never returned"
          },
          "401": {
            "description": "Invalid key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Full account key required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/agent/access-keys/{id}": {
      "delete": {
        "operationId": "revokeAccessKey",
        "summary": "Revoke one integration",
        "description": "Full account key required; provide factorCode in a JSON body if 2FA is enabled. Idempotent revocation blocks new requests. Already reserved sends may finish. Account-key rotation does not revoke limited keys.",
        "security": [
          {
            "agentKey": []
          }
        ],
        "tags": [
          "Agent mail"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AccessKeyRevoked"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Insufficient sending credits",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Account or sender not permitted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Message not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Conflict or unresolved previous send",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Payload or message too large",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Callback ownership verification failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Request or daily sending limit",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "Internal error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "Mail submission failed or outcome unknown",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Dependency or feature unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "factorCode": {
                    "type": "string",
                    "description": "Required when account 2FA is enabled"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/agent/payment": {
      "post": {
        "operationId": "createAgentPayment",
        "summary": "Buy sending credits or prepaid hosting",
        "description": "Create a card checkout or native USDC invoice on Polygon, Base, Ethereum or Solana. Requires a full account Bearer key and Idempotency-Key. Choose mail_credits ($1 buys 10,000 mail-only credits), domain_hosting (primary hosting), or domain_addon with domainId (additional hosting). Hosting costs $1 per 30 days, 1–12 periods; extras require active primary hosting and verified ownership. Confirmed crypto hosting activates without human checkout. Purchases do not raise sending limits. Pay with your operator's authorization; reuse the same key after a timeout. Guide: /docs/payments.",
        "security": [
          {
            "agentKey": []
          }
        ],
        "tags": [
          "Agent mail"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PaymentRequest"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 128
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PaymentResult"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Insufficient sending credits",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Account or sender not permitted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Message not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Conflict or unresolved previous send",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Payload or message too large",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Callback ownership verification failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Request or daily sending limit",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "Internal error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "Mail submission failed or outcome unknown",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Dependency or feature unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/agent/payment/status/{token}": {
      "get": {
        "operationId": "checkAgentPayment",
        "summary": "Check a USDC payment",
        "description": "Check an owned invoice and apply mail credits or prepaid hosting once. Polygon requires 128 confirmations; Base, Ethereum and Solana require finalized balances. Card purchases use verified Stripe callbacks. Requires a full account key; old payment tokens and shared addresses are not accepted.",
        "security": [
          {
            "agentKey": []
          }
        ],
        "tags": [
          "Agent mail"
        ],
        "parameters": [
          {
            "name": "token",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PaymentResult"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Insufficient sending credits",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Account or sender not permitted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Message not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Conflict or unresolved previous send",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Payload or message too large",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Callback ownership verification failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Request or daily sending limit",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "Internal error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "Mail submission failed or outcome unknown",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Dependency or feature unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/agent/webhooks": {
      "post": {
        "operationId": "createWebhook",
        "summary": "Register a mail-event callback",
        "description": "One public HTTPS callback per agent. Returns a signingSecret once. Verify ownership before receiving events. GET this route lists your endpoint without secrets. Receiving is free. Full guide: /docs/webhooks.",
        "security": [
          {
            "agentKey": []
          }
        ],
        "tags": [
          "Agent mail"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookCreate"
              }
            }
          }
        },
        "parameters": [],
        "responses": {
          "201": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookCreated"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Insufficient sending credits",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Account or sender not permitted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Message not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Conflict or unresolved previous send",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Payload or message too large",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Callback ownership verification failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Request or daily sending limit",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "Internal error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "Mail submission failed or outcome unknown",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Dependency or feature unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "get": {
        "operationId": "listWebhooks",
        "summary": "List your callback without its secret",
        "security": [
          {
            "agentKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "webhooks array with id, url, status, events, createdAt, verifiedAt, lastScannedAt and scanError"
          },
          "401": {
            "description": "Invalid API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/agent/webhooks/{id}/verify": {
      "post": {
        "operationId": "verifyWebhook",
        "summary": "Verify callback ownership",
        "description": "Receiver checks the signed webhook.verification event and returns HTTP 200 with {challenge: data.challenge}. Starts a fresh INBOX baseline; no historical backfill. Also resets an endpoint after UIDVALIDITY changes.",
        "security": [
          {
            "agentKey": []
          }
        ],
        "tags": [
          "Agent mail"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookState"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Insufficient sending credits",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Account or sender not permitted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Message not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Conflict or unresolved previous send",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Payload or message too large",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Callback ownership verification failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Request or daily sending limit",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "Internal error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "Mail submission failed or outcome unknown",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Dependency or feature unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/agent/webhooks/{id}": {
      "delete": {
        "operationId": "deleteWebhook",
        "summary": "Revoke a callback",
        "description": "Erases the signing configuration and cancels queued notifications. Already in-flight HTTP requests cannot be recalled.",
        "security": [
          {
            "agentKey": []
          }
        ],
        "tags": [
          "Agent mail"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookState"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Insufficient sending credits",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Account or sender not permitted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Message not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Conflict or unresolved previous send",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Payload or message too large",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Callback ownership verification failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Request or daily sending limit",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "Internal error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "Mail submission failed or outcome unknown",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Dependency or feature unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "updateWebhookEvents",
        "summary": "Opt an active callback into outgoing delivery events",
        "security": [
          {
            "agentKey": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "events": {
                    "type": "array",
                    "minItems": 1,
                    "maxItems": 2,
                    "uniqueItems": true,
                    "default": [
                      "message.received"
                    ],
                    "items": {
                      "enum": [
                        "message.received",
                        "message.delivery_updated"
                      ]
                    }
                  }
                },
                "required": [
                  "events"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Subscription updated; no historical backfill",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookState"
                }
              }
            }
          },
          "400": {
            "description": "Invalid event types",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Invalid API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Callback not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Verify or recreate callback first",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/agent/webhooks/deliveries": {
      "get": {
        "operationId": "listWebhookDeliveries",
        "summary": "Inspect delivery history",
        "description": "Up to 50 events, retained 30 days. Includes delivery status, attempts and safe error codes. Use before=nextCursor for older events.",
        "security": [
          {
            "agentKey": []
          }
        ],
        "tags": [
          "Agent mail"
        ],
        "parameters": [
          {
            "name": "before",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "nextCursor from the previous page"
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookHistory"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Insufficient sending credits",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Account or sender not permitted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Message not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Conflict or unresolved previous send",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Payload or message too large",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Callback ownership verification failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Request or daily sending limit",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "Internal error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "Mail submission failed or outcome unknown",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Dependency or feature unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/agent/webhooks/deliveries/{id}": {
      "get": {
        "operationId": "getWebhookDelivery",
        "summary": "Inspect or replay one event",
        "description": "GET returns the event and individual attempts. POST the same URL to replay a completed event, at most three times. Replays preserve ID and payload; consumers must deduplicate.",
        "security": [
          {
            "agentKey": []
          }
        ],
        "tags": [
          "Agent mail"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookDetail"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Insufficient sending credits",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Account or sender not permitted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Message not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Conflict or unresolved previous send",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Payload or message too large",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Callback ownership verification failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Request or daily sending limit",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "Internal error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "Mail submission failed or outcome unknown",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Dependency or feature unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "replayWebhookDelivery",
        "summary": "Replay a completed event with its original ID and payload",
        "security": [
          {
            "agentKey": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "202": {
            "description": "Queued for replay",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookState"
                }
              }
            }
          },
          "401": {
            "description": "Invalid API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Event not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Callback inactive, event pending or replay limit reached",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Replay rate limit",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/agent/outbound": {
      "get": {
        "operationId": "listOutbound",
        "summary": "List outgoing delivery status",
        "description": "Up to 50 submissions, newest first. Use before=nextCursor for pagination. Delivery metadata is retained 90 days; older or pre-tracking submissions are untracked. No automatic resending.",
        "security": [
          {
            "agentKey": []
          }
        ],
        "tags": [
          "Agent mail"
        ],
        "parameters": [
          {
            "name": "before",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "nextCursor from the previous page"
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OutboundList"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Insufficient sending credits",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Account or sender not permitted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Message not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Conflict or unresolved previous send",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Payload or message too large",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Callback ownership verification failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Request or daily sending limit",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "Internal error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "Mail submission failed or outcome unknown",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Dependency or feature unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/agent/outbound/{id}": {
      "get": {
        "operationId": "getOutbound",
        "summary": "Track recipients and bounces",
        "description": "Use the send response id, not its RFC Message-ID. Returns recipient outcomes and the latest 200 state changes. delivered means the next server accepted the message; it does not prove inbox placement. Only authoritative Postfix evidence is processed, not unverified incoming bounce messages. See /docs/delivery.",
        "security": [
          {
            "agentKey": []
          }
        ],
        "tags": [
          "Agent mail"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OutboundMessage"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Insufficient sending credits",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Account or sender not permitted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Message not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Conflict or unresolved previous send",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Payload or message too large",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Callback ownership verification failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Request or daily sending limit",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "Internal error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "Mail submission failed or outcome unknown",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Dependency or feature unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/agent/outbound/suppressions": {
      "get": {
        "operationId": "listSuppressions",
        "summary": "Inspect recipient blocks",
        "description": "Up to 100 active recipient suppressions belonging to your account. Created from direct 5.1.1 invalid-address bounces or independently verified complaints. Policy failures and forwarded destinations do not create invalid-address blocks. canRelease is false for complaints.",
        "security": [
          {
            "agentKey": []
          }
        ],
        "tags": [
          "Agent mail"
        ],
        "parameters": [],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Suppressions"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Insufficient sending credits",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Account or sender not permitted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Message not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Conflict or unresolved previous send",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Payload or message too large",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Callback ownership verification failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Request or daily sending limit",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "Internal error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "Mail submission failed or outcome unknown",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Dependency or feature unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/agent/outbound/suppressions/{id}": {
      "delete": {
        "operationId": "releaseSuppression",
        "summary": "Release a corrected recipient",
        "description": "Use only for canRelease: true after confirming the address can receive mail again. Complaint blocks return 403 and require an administrator to verify renewed consent. Removes an invalid-address block for future sends; does not resend mail or change credits. At most 10 releases per hour.",
        "security": [
          {
            "agentKey": []
          }
        ],
        "tags": [
          "Agent mail"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuppressionReleased"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Insufficient sending credits",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Account or sender not permitted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Message not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Conflict or unresolved previous send",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Payload or message too large",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Callback ownership verification failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Request or daily sending limit",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "Internal error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "Mail submission failed or outcome unknown",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Dependency or feature unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/auth/login": {
      "post": {
        "operationId": "loginDomainOwner",
        "summary": "Sign in as the domain owner",
        "description": "Use an existing owner account. Returns token, a session JWT. With 2FA, supply totpCode or an unused backupCode; missing proof returns 403 with requires2FA: true. Limits: 30 requests/IP and 15/account per 15 minutes.",
        "tags": [
          "Custom domains"
        ],
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DomainLogin"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DomainSession"
                }
              }
            }
          },
          "400": {
            "description": "Request failed; inspect error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Invalid email/password or second-factor code",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Required scope missing, 2FA required, paid entitlement missing, ownership not verified, or limit reached",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Request failed; inspect error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Request failed; inspect error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Request failed; inspect error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Request failed; inspect error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "Request failed; inspect error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Request failed; inspect error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/auth/register": {
      "post": {
        "operationId": "registerDomainOwner",
        "summary": "Create an owner account when needed",
        "description": "Creates a human/password account and session token. Only register with operator authorization; reuse an existing suitable account when possible. This does not activate Personal. Five registrations/IP/hour shared with agent registration. After an uncertain response, try signing in; do not blindly register again.",
        "tags": [
          "Custom domains"
        ],
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DomainOwnerRegistration"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DomainSession"
                }
              }
            }
          },
          "400": {
            "description": "Request failed; inspect error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Invalid email/password or second-factor code",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Required scope missing, 2FA required, paid entitlement missing, ownership not verified, or limit reached",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Request failed; inspect error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Request failed; inspect error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Request failed; inspect error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Request failed; inspect error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "Request failed; inspect error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Request failed; inspect error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/user/domains": {
      "get": {
        "operationId": "listOwnerDomains",
        "summary": "List domains, addresses and entitlement",
        "description": "Requires domains:read when using a limited key. Returns domains, aliases, mailboxes, canCreateAddresses and limits. DNS statuses are stored snapshots; POST verify for current lookup evidence. Up to 120 requests/account/minute. Bearer owner-session JWT, auth_token cookie, full agent account key, or limited key with domains:read. Mutations allow 20/account/minute per rate bucket.",
        "tags": [
          "Custom domains"
        ],
        "security": [
          {
            "agentKey": []
          },
          {
            "ownerSession": []
          },
          {
            "ownerCookie": []
          }
        ],
        "x-required-scope": "domains:read",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DomainInventory"
                }
              }
            }
          },
          "400": {
            "description": "Request failed; inspect error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Credential missing, expired, revoked or invalid",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Required scope missing, 2FA required, paid entitlement missing, ownership not verified, or limit reached",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Request failed; inspect error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Request failed; inspect error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Request failed; inspect error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Request failed; inspect error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "Request failed; inspect error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Request failed; inspect error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "addOwnerDomain",
        "summary": "Add a domain",
        "description": "Up to 20 domains per owner. Included domains follow the plan (1 on Personal, 3 on Pro, 10 on Team; one with primary agent hosting). Set sendOnly to keep the inbox at another provider (Pro and Team). Free to prepare DNS; no subscription needed here. Returns the exact dnsRecords and domain id. No purchase, nameserver change or automatic DNS writing. After a timeout, list domains before retrying. Bearer owner-session JWT, auth_token cookie, full agent account key, or limited key with domains:write. Mutations allow 20/account/minute per rate bucket.",
        "tags": [
          "Custom domains"
        ],
        "security": [
          {
            "agentKey": []
          },
          {
            "ownerSession": []
          },
          {
            "ownerCookie": []
          }
        ],
        "x-required-scope": "domains:write",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DomainAdd"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DomainResult"
                }
              }
            }
          },
          "400": {
            "description": "Request failed; inspect error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Credential missing, expired, revoked or invalid",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Required scope missing, 2FA required, paid entitlement missing, ownership not verified, or limit reached",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Request failed; inspect error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Request failed; inspect error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Request failed; inspect error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Request failed; inspect error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "Request failed; inspect error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Request failed; inspect error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "setOwnerDomainEnabled",
        "summary": "Enable or disable domain mail",
        "description": "Disabling stops domain routing/sending and retains stored mail. Re-enabling still requires current DNS checks and signing readiness. Bearer owner-session JWT, auth_token cookie, full agent account key, or limited key with domains:write. Mutations allow 20/account/minute per rate bucket.",
        "tags": [
          "Custom domains"
        ],
        "security": [
          {
            "agentKey": []
          },
          {
            "ownerSession": []
          },
          {
            "ownerCookie": []
          }
        ],
        "x-required-scope": "domains:write",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DomainEnabled"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DomainSuccess"
                }
              }
            }
          },
          "400": {
            "description": "Request failed; inspect error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Credential missing, expired, revoked or invalid",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Required scope missing, 2FA required, paid entitlement missing, ownership not verified, or limit reached",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Request failed; inspect error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Request failed; inspect error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Request failed; inspect error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Request failed; inspect error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "Request failed; inspect error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Request failed; inspect error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "removeUnusedOwnerDomain",
        "summary": "Remove unused domain setup",
        "description": "Only unprovisioned domain setup can be removed. Provisioned mail returns 409; disable instead and contact support for transfer/removal. Send domainId in the JSON body. Bearer owner-session JWT, auth_token cookie, full agent account key, or limited key with domains:write. Mutations allow 20/account/minute per rate bucket.",
        "tags": [
          "Custom domains"
        ],
        "security": [
          {
            "agentKey": []
          },
          {
            "ownerSession": []
          },
          {
            "ownerCookie": []
          }
        ],
        "x-required-scope": "domains:write",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DomainId"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DomainSuccess"
                }
              }
            }
          },
          "400": {
            "description": "Request failed; inspect error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Credential missing, expired, revoked or invalid",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Required scope missing, 2FA required, paid entitlement missing, ownership not verified, or limit reached",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Request failed; inspect error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Request failed; inspect error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Request failed; inspect error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Request failed; inspect error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "Request failed; inspect error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Request failed; inspect error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/user/domains/verify": {
      "post": {
        "operationId": "verifyOwnerDomain",
        "summary": "Check domain DNS",
        "description": "Checks all five record types independently, including before subscribing. HTTP 200 means the check ran, not that all records passed. Inspect domain.dnsStatus and domain.dnsDetails. Recursive DNS can return cached records from a previous nameserver. Poll with increasing delays, then stop; no need to recreate the domain. Bearer owner-session JWT, auth_token cookie, full agent account key, or limited key with domains:write. Mutations allow 20/account/minute per rate bucket.",
        "tags": [
          "Custom domains"
        ],
        "security": [
          {
            "agentKey": []
          },
          {
            "ownerSession": []
          },
          {
            "ownerCookie": []
          }
        ],
        "x-required-scope": "domains:write",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DomainId"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DomainResult"
                }
              }
            }
          },
          "400": {
            "description": "Request failed; inspect error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Credential missing, expired, revoked or invalid",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Required scope missing, 2FA required, paid entitlement missing, ownership not verified, or limit reached",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Request failed; inspect error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Request failed; inspect error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Request failed; inspect error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Request failed; inspect error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "Request failed; inspect error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Request failed; inspect error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/user/domains/aliases": {
      "post": {
        "operationId": "createOwnerDomainAlias",
        "summary": "Create an alias",
        "description": "Requires paid owner access, active additional-domain hosting where applicable, and ownership verified within 24 hours. Aliases per domain: 10 on Personal, 25 on Pro, 50 on Team. Default destination is the owner inbox; an alias has no separate credentials and shares its destination mailbox credits/limits. On a send-only domain, aliases are sending addresses owned by the domain owner. Prepare before MX cutover. Conflicts return 409. Bearer owner-session JWT, auth_token cookie, full agent account key, or limited key with domains:write. Mutations allow 20/account/minute per rate bucket.",
        "tags": [
          "Custom domains"
        ],
        "security": [
          {
            "agentKey": []
          },
          {
            "ownerSession": []
          },
          {
            "ownerCookie": []
          }
        ],
        "x-required-scope": "domains:write",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DomainAliasCreate"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DomainAliasResult"
                }
              }
            }
          },
          "400": {
            "description": "Request failed; inspect error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Credential missing, expired, revoked or invalid",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Required scope missing, 2FA required, paid entitlement missing, ownership not verified, or limit reached",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Request failed; inspect error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Request failed; inspect error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Request failed; inspect error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Request failed; inspect error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "Request failed; inspect error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Request failed; inspect error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "removeOwnerDomainAlias",
        "summary": "Remove an alias",
        "description": "Send the alias id in the JSON body. Stops new delivery to the alias; does not erase delivered mail. Bearer owner-session JWT, auth_token cookie, full agent account key, or limited key with domains:write. Mutations allow 20/account/minute per rate bucket.",
        "tags": [
          "Custom domains"
        ],
        "security": [
          {
            "agentKey": []
          },
          {
            "ownerSession": []
          },
          {
            "ownerCookie": []
          }
        ],
        "x-required-scope": "domains:write",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DomainAddressId"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DomainSuccess"
                }
              }
            }
          },
          "400": {
            "description": "Request failed; inspect error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Credential missing, expired, revoked or invalid",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Required scope missing, 2FA required, paid entitlement missing, ownership not verified, or limit reached",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Request failed; inspect error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Request failed; inspect error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Request failed; inspect error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Request failed; inspect error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "Request failed; inspect error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Request failed; inspect error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/user/domains/mailboxes": {
      "post": {
        "operationId": "createOwnerDomainMailbox",
        "summary": "Create a separate mailbox",
        "description": "Requires paid owner access, active additional-domain hosting where applicable, and ownership verified within 24 hours; mailboxes per domain: 10 on Personal, 10 on Pro, 25 on Team. Not available on send-only domains. Human requires a password; agent returns a one-time apiKey. Separate account, credits and limits; domain ownership does not grant message access. Check inventory after a timeout before retrying. Prepare addresses before MX cutover. Bearer owner-session JWT, auth_token cookie, full agent account key, or limited key with domains:write. Mutations allow 20/account/minute per rate bucket.",
        "tags": [
          "Custom domains"
        ],
        "security": [
          {
            "agentKey": []
          },
          {
            "ownerSession": []
          },
          {
            "ownerCookie": []
          }
        ],
        "x-required-scope": "domains:write",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DomainMailboxCreate"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DomainMailboxResult"
                }
              }
            }
          },
          "400": {
            "description": "Request failed; inspect error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Credential missing, expired, revoked or invalid",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Required scope missing, 2FA required, paid entitlement missing, ownership not verified, or limit reached",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Request failed; inspect error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Request failed; inspect error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Request failed; inspect error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Request failed; inspect error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "Request failed; inspect error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Request failed; inspect error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "setOwnerDomainMailboxEnabled",
        "summary": "Enable or disable a mailbox",
        "description": "id is the mailbox userId. Stops or restores domain sending/receiving without deleting login or stored mail. Domain must also remain active. Bearer owner-session JWT, auth_token cookie, full agent account key, or limited key with domains:write. Mutations allow 20/account/minute per rate bucket.",
        "tags": [
          "Custom domains"
        ],
        "security": [
          {
            "agentKey": []
          },
          {
            "ownerSession": []
          },
          {
            "ownerCookie": []
          }
        ],
        "x-required-scope": "domains:write",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DomainMailboxEnabled"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DomainSuccess"
                }
              }
            }
          },
          "400": {
            "description": "Request failed; inspect error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Credential missing, expired, revoked or invalid",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Required scope missing, 2FA required, paid entitlement missing, ownership not verified, or limit reached",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Request failed; inspect error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Request failed; inspect error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Request failed; inspect error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Request failed; inspect error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "Request failed; inspect error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Request failed; inspect error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/user/domain-keys": {
      "get": {
        "operationId": "listDomainAccessKeys",
        "summary": "List owner-issued keys",
        "description": "Owner session only. Lists metadata, never secrets. Agent owners may instead use /api/v1/agent/access-keys with their full account key. Browser owner authentication required.",
        "tags": [
          "Custom domains"
        ],
        "security": [
          {
            "ownerSession": []
          },
          {
            "ownerCookie": []
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DomainKeyList"
                }
              }
            }
          },
          "400": {
            "description": "Request failed; inspect error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Credential missing, expired, revoked or invalid",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Required scope missing, 2FA required, paid entitlement missing, ownership not verified, or limit reached",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Request failed; inspect error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Request failed; inspect error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Request failed; inspect error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Request failed; inspect error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "Request failed; inspect error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Request failed; inspect error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "createDomainAccessKey",
        "summary": "Delegate domain setup to an agent",
        "description": "Owner session only. Issues domains:read and/or domains:write; no mail scopes here. Defaults to 30-day expiry, at most 366 days and 20 active keys. Existing 2FA requires factorCode. Secret is returned once. Key management mutations share 30/account/15 minutes. Browser owner authentication required.",
        "tags": [
          "Custom domains"
        ],
        "security": [
          {
            "ownerSession": []
          },
          {
            "ownerCookie": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DomainKeyCreate"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DomainKeyIssued"
                }
              }
            }
          },
          "400": {
            "description": "Request failed; inspect error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Credential missing, expired, revoked or invalid",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Required scope missing, 2FA required, paid entitlement missing, ownership not verified, or limit reached",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Request failed; inspect error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Request failed; inspect error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Request failed; inspect error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Request failed; inspect error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "Request failed; inspect error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Request failed; inspect error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/user/domain-keys/{id}": {
      "delete": {
        "operationId": "revokeDomainAccessKey",
        "summary": "Revoke delegated domain access",
        "description": "Owner session only; existing 2FA requires factorCode. Stops new authorized changes; already committed changes are retained. Does not revoke separate mailbox keys the integration previously provisioned. Repeating revocation is safe. Browser owner authentication required.",
        "tags": [
          "Custom domains"
        ],
        "security": [
          {
            "ownerSession": []
          },
          {
            "ownerCookie": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DomainKeyRevoke"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DomainKeyRevoked"
                }
              }
            }
          },
          "400": {
            "description": "Request failed; inspect error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Credential missing, expired, revoked or invalid",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Required scope missing, 2FA required, paid entitlement missing, ownership not verified, or limit reached",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Request failed; inspect error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Request failed; inspect error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Request failed; inspect error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Request failed; inspect error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "Request failed; inspect error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Request failed; inspect error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/billing/checkout": {
      "post": {
        "operationId": "createDomainSubscriptionCheckout",
        "summary": "Prepare a subscription checkout",
        "description": "Owner session or full agent account key only; limited keys cannot purchase. With operator authorization, request kind personal for the $1/month domain entitlement. Returns a Stripe checkout URL for the operator to complete. Requires Idempotency-Key; retry the same body and key. Agent sending remains pay as you go with separate credits and unchanged daily limits. This route also accepts domain_addon with domainId and periods (1–12) for $1 per 30 days per extra domain, or mail_credits for agent top-ups. Verify ownership and activate primary hosting first. Extra hosting is prepaid, never auto-renewed; new addresses stop at expiry and sending/receiving pause after 7 days. See billing docs. Full account authority required.",
        "tags": [
          "Custom domains"
        ],
        "security": [
          {
            "agentKey": []
          },
          {
            "ownerSession": []
          },
          {
            "ownerCookie": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 128
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DomainCheckout"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DomainCheckoutResult"
                }
              }
            }
          },
          "400": {
            "description": "Request failed; inspect error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Credential missing, expired, revoked or invalid",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Required scope missing, 2FA required, paid entitlement missing, ownership not verified, or limit reached",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Request failed; inspect error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Request failed; inspect error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Request failed; inspect error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Request failed; inspect error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "Request failed; inspect error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Request failed; inspect error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/agent/drafts": {
      "get": {
        "operationId": "listProposals",
        "summary": "List this helper’s proposals",
        "description": "Requires a human-issued mail:draft key from /dashboard/approvals. It cannot read the mailbox or send. Only the human owner can approve. At most 20 pending proposals; expires in 7 days or earlier with its key. 30 writes/hour and 120 reads/minute per owner. Replay create with identical clientKey and message; edits/withdrawals require the current revision and contentHash. After human editing, agents can only see status. See /docs/approvals.",
        "security": [
          {
            "agentKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProposalList"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input, unavailable authorization, changed proposal or limit reached",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Invalid input, unavailable authorization, changed proposal or limit reached",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Invalid input, unavailable authorization, changed proposal or limit reached",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Invalid input, unavailable authorization, changed proposal or limit reached",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Invalid input, unavailable authorization, changed proposal or limit reached",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Invalid input, unavailable authorization, changed proposal or limit reached",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Invalid input, unavailable authorization, changed proposal or limit reached",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "createProposal",
        "summary": "Propose an email for human review",
        "description": "Requires a human-issued mail:draft key from /dashboard/approvals. It cannot read the mailbox or send. Only the human owner can approve. At most 20 pending proposals; expires in 7 days or earlier with its key. 30 writes/hour and 120 reads/minute per owner. Replay create with identical clientKey and message; edits/withdrawals require the current revision and contentHash. After human editing, agents can only see status. See /docs/approvals.",
        "security": [
          {
            "agentKey": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ProposalCreate"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Proposal"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input, unavailable authorization, changed proposal or limit reached",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Invalid input, unavailable authorization, changed proposal or limit reached",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Invalid input, unavailable authorization, changed proposal or limit reached",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Invalid input, unavailable authorization, changed proposal or limit reached",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Invalid input, unavailable authorization, changed proposal or limit reached",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Invalid input, unavailable authorization, changed proposal or limit reached",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Invalid input, unavailable authorization, changed proposal or limit reached",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/agent/drafts/{id}": {
      "get": {
        "operationId": "getProposal",
        "summary": "Read this proposal or its review status",
        "description": "Requires a human-issued mail:draft key from /dashboard/approvals. It cannot read the mailbox or send. Only the human owner can approve. At most 20 pending proposals; expires in 7 days or earlier with its key. 30 writes/hour and 120 reads/minute per owner. Replay create with identical clientKey and message; edits/withdrawals require the current revision and contentHash. After human editing, agents can only see status. See /docs/approvals.",
        "security": [
          {
            "agentKey": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Proposal"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input, unavailable authorization, changed proposal or limit reached",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Invalid input, unavailable authorization, changed proposal or limit reached",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Invalid input, unavailable authorization, changed proposal or limit reached",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Invalid input, unavailable authorization, changed proposal or limit reached",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Invalid input, unavailable authorization, changed proposal or limit reached",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Invalid input, unavailable authorization, changed proposal or limit reached",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Invalid input, unavailable authorization, changed proposal or limit reached",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "changeProposal",
        "summary": "Edit or withdraw a pending proposal",
        "description": "Requires a human-issued mail:draft key from /dashboard/approvals. It cannot read the mailbox or send. Only the human owner can approve. At most 20 pending proposals; expires in 7 days or earlier with its key. 30 writes/hour and 120 reads/minute per owner. Replay create with identical clientKey and message; edits/withdrawals require the current revision and contentHash. After human editing, agents can only see status. See /docs/approvals.",
        "security": [
          {
            "agentKey": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ProposalChange"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Proposal"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input, unavailable authorization, changed proposal or limit reached",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Invalid input, unavailable authorization, changed proposal or limit reached",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Invalid input, unavailable authorization, changed proposal or limit reached",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Invalid input, unavailable authorization, changed proposal or limit reached",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Invalid input, unavailable authorization, changed proposal or limit reached",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Invalid input, unavailable authorization, changed proposal or limit reached",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Invalid input, unavailable authorization, changed proposal or limit reached",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "ownerSession": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "description": "Owner session token returned by /api/auth/login or /api/auth/register. Separate from kk_ and kk_access_ agent keys. Login honors existing 2FA. Do not log credentials."
      },
      "ownerCookie": {
        "type": "apiKey",
        "in": "cookie",
        "name": "auth_token",
        "description": "Existing authenticated browser session. Same owner authorization as the session JWT. Cookie-authenticated writes require Origin to match https://keykeeper.world."
      },
      "agentKey": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "kk_…",
        "description": "Full account keys use kk_; limited integration keys use kk_access_. Keep keys secret and out of URLs. Undeclared/account-management endpoints require a full account key."
      }
    },
    "schemas": {
      "SendingStatus": {
        "type": "object",
        "properties": {
          "state": {
            "enum": [
              "probation",
              "standard",
              "reviewed",
              "paused"
            ]
          },
          "tier": {
            "enum": [
              "probation",
              "standard",
              "reviewed"
            ]
          },
          "reason": {
            "type": [
              "string",
              "null"
            ]
          },
          "message": {
            "type": [
              "string",
              "null"
            ]
          },
          "dailyLimit": {
            "type": "integer"
          },
          "recipientsPerMinute": {
            "type": "integer"
          },
          "reviewRequested": {
            "type": "boolean"
          },
          "receivingAvailable": {
            "const": true
          },
          "documentation": {
            "const": "/docs/sending-safety"
          }
        },
        "required": [
          "state",
          "tier",
          "dailyLimit",
          "recipientsPerMinute",
          "reviewRequested",
          "receivingAvailable"
        ]
      },
      "SenderReviewRequest": {
        "type": "object",
        "properties": {
          "purpose": {
            "type": "string",
            "minLength": 40,
            "maxLength": 1000,
            "description": "Sending purpose, expected volume and how recipients gave consent. No secrets or private messages."
          }
        },
        "required": [
          "purpose"
        ],
        "additionalProperties": false
      },
      "SenderReviewResult": {
        "type": "object",
        "properties": {
          "success": {
            "const": true
          },
          "sending": {
            "$ref": "#/components/schemas/SendingStatus"
          },
          "message": {
            "type": "string"
          }
        },
        "required": [
          "success",
          "sending"
        ]
      },
      "AccessKeyCreate": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 60
          },
          "scopes": {
            "type": "array",
            "minItems": 1,
            "uniqueItems": true,
            "items": {
              "enum": [
                "mail:read",
                "mail:send",
                "domains:read",
                "domains:write"
              ]
            }
          },
          "allowedSenders": {
            "type": "array",
            "minItems": 1,
            "maxItems": 50,
            "items": {
              "type": "string",
              "format": "email"
            },
            "description": "Defaults to the primary mailbox. Exact owned addresses; also restricts Reply-To."
          },
          "allowedRecipients": {
            "type": [
              "array",
              "null"
            ],
            "minItems": 1,
            "maxItems": 50,
            "items": {
              "type": "string",
              "format": "email"
            },
            "description": "Exact addresses across To/Cc/Bcc; null or omitted allows any recipient."
          },
          "dailyRecipientLimit": {
            "type": "integer",
            "minimum": 1,
            "maximum": 1000000
          },
          "totalRecipientBudget": {
            "type": "integer",
            "minimum": 1,
            "maximum": 1000000
          },
          "expiresAt": {
            "type": "string",
            "format": "date-time",
            "description": "Defaults to 30 days; maximum 366 days."
          },
          "factorCode": {
            "type": "string"
          }
        },
        "required": [
          "name",
          "scopes"
        ],
        "description": "Sending permission requires both recipient limits. Existing 2FA is required for management mutations when enabled."
      },
      "AccessKeyCreated": {
        "type": "object",
        "properties": {
          "apiKey": {
            "type": "string",
            "pattern": "^kk_access_[a-f0-9]{64}$",
            "description": "Shown once. Store securely; do not blindly retry creation."
          },
          "key": {
            "type": "object",
            "description": "Metadata: id, name, keyHint, scopes, allowedSenders, allowedRecipients, dailyRecipientLimit, totalRecipientBudget, usedRecipients, remainingRecipients, expiresAt, status, createdAt, lastUsedAt, revokedAt."
          }
        },
        "required": [
          "apiKey",
          "key"
        ]
      },
      "AccessKeyRevoked": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "revoked": {
            "const": true
          }
        },
        "required": [
          "id",
          "revoked"
        ]
      },
      "WebhookCreate": {
        "type": "object",
        "properties": {
          "url": {
            "type": "string",
            "format": "uri",
            "maxLength": 2048
          },
          "events": {
            "type": "array",
            "minItems": 1,
            "maxItems": 2,
            "uniqueItems": true,
            "default": [
              "message.received"
            ],
            "items": {
              "enum": [
                "message.received",
                "message.delivery_updated"
              ]
            }
          }
        },
        "required": [
          "url"
        ]
      },
      "WebhookCreated": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "url": {
            "type": "string"
          },
          "status": {
            "const": "pending"
          },
          "signingSecret": {
            "type": "string",
            "description": "Returned once. Store securely; never log."
          },
          "events": {
            "type": "array",
            "items": {
              "enum": [
                "message.received",
                "message.delivery_updated"
              ]
            }
          }
        },
        "required": [
          "id",
          "signingSecret",
          "status"
        ]
      },
      "WebhookState": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "status": {
            "type": "string"
          },
          "folder": {
            "type": "string"
          },
          "uidValidity": {
            "type": "string"
          },
          "startsAfterUid": {
            "type": "string"
          },
          "replayed": {
            "type": "boolean"
          }
        },
        "required": [
          "id",
          "status"
        ]
      },
      "IncomingWebhookEvent": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "type": {
            "const": "message.received"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "data": {
            "type": "object",
            "properties": {
              "folder": {
                "const": "INBOX"
              },
              "uidValidity": {
                "type": "string"
              },
              "uid": {
                "type": "string"
              }
            },
            "required": [
              "folder",
              "uidValidity",
              "uid"
            ],
            "additionalProperties": false
          }
        },
        "required": [
          "id",
          "type",
          "createdAt",
          "data"
        ],
        "additionalProperties": false
      },
      "WebhookHistory": {
        "type": "object",
        "properties": {
          "deliveries": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string"
                },
                "webhookId": {
                  "type": "string"
                },
                "status": {
                  "enum": [
                    "pending",
                    "delivering",
                    "delivered",
                    "failed",
                    "cancelled"
                  ]
                },
                "attempts": {
                  "type": "integer"
                },
                "replays": {
                  "type": "integer"
                },
                "httpStatus": {
                  "type": [
                    "integer",
                    "null"
                  ]
                },
                "errorCode": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "createdAt": {
                  "type": "string"
                },
                "deliveredAt": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "nextAttemptAt": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "event": {
                  "$ref": "#/components/schemas/WebhookEvent"
                }
              }
            }
          },
          "nextCursor": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "WebhookDetail": {
        "type": "object",
        "properties": {
          "event": {
            "$ref": "#/components/schemas/WebhookEvent"
          },
          "status": {
            "type": "string"
          },
          "attempts": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "attempt": {
                  "type": "integer"
                },
                "started_at": {
                  "type": "string"
                },
                "finished_at": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "http_status": {
                  "type": [
                    "integer",
                    "null"
                  ]
                },
                "error_code": {
                  "type": [
                    "string",
                    "null"
                  ]
                }
              }
            }
          }
        }
      },
      "KeyAction": {
        "type": "object",
        "properties": {
          "action": {
            "enum": [
              "prepare",
              "activate",
              "cancel"
            ]
          },
          "factorCode": {
            "type": "string",
            "description": "Existing authenticator or unused backup code, if enabled"
          }
        },
        "required": [
          "action"
        ]
      },
      "KeyActionResult": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean"
          },
          "apiKey": {
            "type": "string",
            "description": "Returned once, only by prepare. Store securely."
          },
          "expiresInSeconds": {
            "type": "integer"
          },
          "message": {
            "type": "string"
          }
        },
        "required": [
          "message"
        ]
      },
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "string"
          },
          "code": {
            "type": "string",
            "description": "Sending refusals use sending_paused (403) or sending_burst_limit, sending_daily_limit, sending_shared_limit, sending_pool_limit (429). Respect Retry-After; see /docs/sending-safety."
          }
        },
        "required": [
          "error"
        ]
      },
      "RegisterAgent": {
        "type": "object",
        "properties": {
          "agentId": {
            "type": "string",
            "pattern": "^[a-zA-Z0-9][a-zA-Z0-9_.-]{0,63}$"
          },
          "name": {
            "type": "string",
            "maxLength": 100
          }
        },
        "required": [
          "agentId"
        ]
      },
      "AgentAccount": {
        "type": "object",
        "properties": {
          "success": {
            "const": true
          },
          "userId": {
            "type": "string"
          },
          "email": {
            "type": "string",
            "format": "email"
          },
          "apiKey": {
            "type": "string",
            "pattern": "^kk_[a-f0-9]{64}$"
          },
          "credits": {
            "const": 0
          },
          "mailboxReady": {
            "const": true
          },
          "message": {
            "type": "string"
          }
        },
        "required": [
          "userId",
          "email",
          "apiKey",
          "credits",
          "mailboxReady"
        ]
      },
      "Message": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^[1-9][0-9]*$"
          },
          "messageId": {
            "type": "string"
          },
          "folder": {
            "type": "string"
          },
          "uidValidity": {
            "type": "string"
          },
          "inReplyTo": {
            "type": [
              "string",
              "null"
            ]
          },
          "references": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "replyTo": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "name": {
                  "type": "string"
                },
                "email": {
                  "type": "string",
                  "format": "email"
                }
              },
              "required": [
                "email"
              ]
            }
          },
          "autoSubmitted": {
            "type": [
              "string",
              "null"
            ]
          },
          "subject": {
            "type": "string"
          },
          "from": {
            "oneOf": [
              {
                "type": "string"
              },
              {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string"
                  },
                  "email": {
                    "type": "string",
                    "format": "email"
                  }
                },
                "required": [
                  "email"
                ]
              }
            ]
          },
          "to": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "name": {
                  "type": "string"
                },
                "email": {
                  "type": "string",
                  "format": "email"
                }
              },
              "required": [
                "email"
              ]
            }
          },
          "cc": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "name": {
                  "type": "string"
                },
                "email": {
                  "type": "string",
                  "format": "email"
                }
              },
              "required": [
                "email"
              ]
            }
          },
          "date": {
            "type": "string",
            "format": "date-time"
          },
          "body": {
            "type": "string"
          },
          "text": {
            "type": "string"
          },
          "html": {
            "type": [
              "string",
              "null"
            ]
          },
          "preview": {
            "type": "string"
          },
          "isRead": {
            "type": "boolean"
          },
          "isStarred": {
            "type": "boolean"
          },
          "encryptedBody": {
            "type": "boolean"
          },
          "attachments": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "filename": {
                  "type": "string"
                },
                "name": {
                  "type": "string"
                },
                "contentType": {
                  "type": "string"
                },
                "size": {
                  "type": "integer"
                },
                "content": {
                  "type": "string",
                  "description": "Base64 content, included when reading a full message"
                },
                "encoding": {
                  "type": "string"
                }
              }
            }
          }
        },
        "required": [
          "id",
          "subject"
        ]
      },
      "Inbox": {
        "type": "object",
        "properties": {
          "folder": {
            "type": "string"
          },
          "uidValidity": {
            "type": [
              "string",
              "null"
            ]
          },
          "totalMessages": {
            "type": "integer"
          },
          "returnedMessages": {
            "type": "integer"
          },
          "emails": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Message"
            }
          }
        },
        "required": [
          "folder",
          "totalMessages",
          "emails"
        ]
      },
      "Balance": {
        "type": "object",
        "properties": {
          "credits": {
            "type": "number"
          },
          "email": {
            "type": "string",
            "format": "email"
          },
          "accountStatus": {
            "type": "string"
          },
          "domainHosting": {
            "$ref": "#/components/schemas/DomainHostingStatus"
          },
          "mailCredits": {
            "type": "integer",
            "description": "Mail-only prepaid units. One per standard outbound recipient."
          },
          "availableEmailRecipients": {
            "type": "integer",
            "description": "Mail credits plus spendable legacy credits; daily limits still apply."
          },
          "sending": {
            "$ref": "#/components/schemas/SendingStatus"
          }
        },
        "required": [
          "credits",
          "email",
          "accountStatus"
        ]
      },
      "SendMessage": {
        "type": "object",
        "properties": {
          "to": {
            "oneOf": [
              {
                "type": "string",
                "description": "An email address or comma-separated addresses"
              },
              {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "type": "string",
                  "format": "email"
                }
              }
            ]
          },
          "cc": {
            "oneOf": [
              {
                "type": "string",
                "description": "An email address or comma-separated addresses"
              },
              {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "type": "string",
                  "format": "email"
                }
              }
            ]
          },
          "bcc": {
            "oneOf": [
              {
                "type": "string",
                "description": "An email address or comma-separated addresses"
              },
              {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "type": "string",
                  "format": "email"
                }
              }
            ]
          },
          "subject": {
            "type": "string",
            "maxLength": 998,
            "pattern": "^[^\\r\\n]*$"
          },
          "body": {
            "type": "string"
          },
          "text": {
            "type": "string"
          },
          "html": {
            "type": "string"
          },
          "replyTo": {
            "oneOf": [
              {
                "type": "string",
                "description": "An email address or comma-separated addresses"
              },
              {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "type": "string",
                  "format": "email"
                }
              }
            ]
          },
          "inReplyTo": {
            "type": "string",
            "maxLength": 254,
            "description": "Original RFC Message-ID, including angle brackets"
          },
          "references": {
            "type": "array",
            "maxItems": 20,
            "items": {
              "type": "string",
              "maxLength": 254
            },
            "description": "Thread Message-IDs, at most 998 characters combined"
          },
          "autoSubmitted": {
            "const": "auto-replied"
          },
          "from": {
            "oneOf": [
              {
                "type": "string",
                "format": "email"
              },
              {
                "type": "object",
                "properties": {
                  "email": {
                    "type": "string",
                    "format": "email"
                  },
                  "name": {
                    "type": "string",
                    "maxLength": 200,
                    "description": "Display name without control characters"
                  }
                },
                "required": [
                  "email"
                ],
                "additionalProperties": false
              }
            ],
            "description": "Address or {email,name}. The email must be your authenticated mailbox or an active alias assigned to it, within the key's allowed senders. The display name changes only the visible From header."
          },
          "headers": {
            "type": "object",
            "properties": {
              "List-Unsubscribe": {
                "type": "string",
                "maxLength": 4096,
                "description": "Angle-bracketed HTTPS or mailto URLs, separated by commas. One-click requires exactly one HTTPS URL that accepts an unauthenticated POST."
              },
              "List-Unsubscribe-Post": {
                "const": "List-Unsubscribe=One-Click"
              }
            },
            "additionalProperties": false,
            "description": "Only these two headers are accepted, case-insensitively. Duplicate names and control characters are rejected. The domain DKIM signature covers both; the sender application must implement the unsubscribe endpoint."
          },
          "idempotencyKey": {
            "type": "string",
            "minLength": 1,
            "maxLength": 128
          },
          "attachments": {
            "type": "array",
            "maxItems": 20,
            "description": "Inline content only. Combined decoded attachment limit: 8 MB.",
            "items": {
              "type": "object",
              "properties": {
                "filename": {
                  "type": "string",
                  "maxLength": 255
                },
                "content": {
                  "type": "string"
                },
                "encoding": {
                  "enum": [
                    "base64",
                    "utf8"
                  ],
                  "default": "utf8"
                }
              },
              "required": [
                "filename",
                "content"
              ]
            }
          }
        },
        "required": [
          "to",
          "subject"
        ],
        "anyOf": [
          {
            "required": [
              "body"
            ]
          },
          {
            "required": [
              "text"
            ]
          },
          {
            "required": [
              "html"
            ]
          }
        ],
        "description": "At least one nonempty text or HTML body, up to 1 MB combined. At most 50 distinct recipients across To, Cc and Bcc."
      },
      "SendResult": {
        "type": "object",
        "properties": {
          "success": {
            "const": true
          },
          "id": {
            "type": "string"
          },
          "messageId": {
            "type": "string"
          },
          "status": {
            "const": "accepted"
          },
          "replayed": {
            "type": "boolean"
          },
          "sentCopySaved": {
            "type": "boolean",
            "description": "Present on the initial response; not repeated by an idempotent replay."
          }
        },
        "required": [
          "success",
          "id",
          "messageId",
          "status"
        ]
      },
      "PaymentRequest": {
        "type": "object",
        "properties": {
          "method": {
            "enum": [
              "card",
              "polygon",
              "base",
              "ethereum",
              "solana"
            ],
            "default": "polygon"
          },
          "chain": {
            "enum": [
              "polygon",
              "base",
              "ethereum",
              "solana"
            ],
            "description": "Legacy alias for method; omit when method is supplied."
          },
          "kind": {
            "enum": [
              "mail_credits",
              "domain_hosting",
              "domain_addon"
            ],
            "default": "mail_credits"
          },
          "domainId": {
            "type": "string",
            "format": "uuid",
            "description": "Required only for domain_addon. Must be an owned additional domain with verified ownership."
          },
          "amountCents": {
            "type": "integer",
            "minimum": 100,
            "maximum": 2500
          },
          "periods": {
            "type": "integer",
            "minimum": 1,
            "maximum": 12,
            "default": 1,
            "description": "Hosting only: each period is 30 days for $1. Omit amountCents, or supply the exact 100 × periods."
          }
        },
        "oneOf": [
          {
            "required": [
              "amountCents"
            ],
            "not": {
              "anyOf": [
                {
                  "required": [
                    "periods"
                  ]
                },
                {
                  "required": [
                    "domainId"
                  ]
                }
              ]
            },
            "properties": {
              "kind": {
                "const": "mail_credits"
              },
              "amountCents": {
                "enum": [
                  100,
                  500,
                  1000,
                  2500
                ]
              }
            }
          },
          {
            "required": [
              "kind"
            ],
            "not": {
              "required": [
                "domainId"
              ]
            },
            "properties": {
              "kind": {
                "const": "domain_hosting"
              },
              "amountCents": {
                "type": "integer",
                "minimum": 100,
                "maximum": 1200,
                "multipleOf": 100
              }
            }
          },
          {
            "required": [
              "kind",
              "domainId"
            ],
            "properties": {
              "kind": {
                "const": "domain_addon"
              },
              "amountCents": {
                "type": "integer",
                "minimum": 100,
                "maximum": 1200,
                "multipleOf": 100
              }
            }
          }
        ],
        "additionalProperties": false
      },
      "DomainHostingStatus": {
        "type": "object",
        "properties": {
          "active": {
            "type": "boolean"
          },
          "prepaidExpiresAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          }
        },
        "required": [
          "active",
          "prepaidExpiresAt"
        ]
      },
      "PaymentResult": {
        "type": "object",
        "properties": {
          "orderId": {
            "type": "string"
          },
          "paymentToken": {
            "type": "string"
          },
          "domainId": {
            "type": "string",
            "format": "uuid"
          },
          "kind": {
            "enum": [
              "mail_credits",
              "domain_hosting",
              "domain_addon"
            ]
          },
          "status": {
            "type": "string"
          },
          "url": {
            "type": "string",
            "format": "uri",
            "description": "Stripe URL for card checkout only"
          },
          "depositAddress": {
            "type": "string"
          },
          "chain": {
            "enum": [
              "polygon",
              "base",
              "ethereum",
              "solana"
            ]
          },
          "network": {
            "type": "string"
          },
          "chainId": {
            "enum": [
              137,
              8453,
              1
            ]
          },
          "genesisHash": {
            "type": "string",
            "description": "Solana mainnet identity, instead of an EVM chainId"
          },
          "token": {
            "const": "USDC"
          },
          "tokenContract": {
            "type": "string",
            "description": "Native contract or Solana mint"
          },
          "amount": {
            "type": "string"
          },
          "amountBaseUnits": {
            "type": "string"
          },
          "mailCredits": {
            "type": "integer"
          },
          "finality": {
            "enum": [
              "128_confirmations",
              "finalized"
            ]
          },
          "requiredConfirmations": {
            "const": 128,
            "description": "Polygon only; other networks use finalized state"
          },
          "hostingDays": {
            "type": "integer"
          },
          "hostingExpiresAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "Expiry granted by this paid hosting order; null before confirmation"
          },
          "statusUrl": {
            "type": "string"
          },
          "instructions": {
            "type": "string"
          },
          "confirmedAmountBaseUnits": {
            "type": "string"
          },
          "checkedBlock": {
            "type": "string",
            "description": "EVM block or Solana slot observed during confirmation"
          }
        },
        "required": [
          "orderId",
          "status"
        ]
      },
      "OutboundRecipient": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "address": {
            "type": "string",
            "format": "email"
          },
          "suppressionId": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid"
          },
          "canRelease": {
            "type": "boolean",
            "description": "False for an active complaint block; sender release is unavailable."
          },
          "status": {
            "enum": [
              "queued",
              "deferred",
              "delivered",
              "bounced",
              "pending",
              "rejected"
            ]
          },
          "dsn": {
            "type": [
              "string",
              "null"
            ]
          },
          "category": {
            "type": [
              "string",
              "null"
            ]
          },
          "transport": {
            "type": [
              "string",
              "null"
            ]
          },
          "observedAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          }
        },
        "required": [
          "id",
          "address",
          "status"
        ]
      },
      "OutboundEvent": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "recipientId": {
            "type": "string"
          },
          "status": {
            "enum": [
              "queued",
              "deferred",
              "delivered",
              "bounced"
            ]
          },
          "dsn": {
            "type": [
              "string",
              "null"
            ]
          },
          "category": {
            "type": [
              "string",
              "null"
            ]
          },
          "transport": {
            "type": [
              "string",
              "null"
            ]
          },
          "observedAt": {
            "type": "string"
          }
        }
      },
      "OutboundMessage": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "messageId": {
            "type": "string"
          },
          "submissionStatus": {
            "enum": [
              "pending",
              "accepted",
              "failed",
              "unknown"
            ]
          },
          "status": {
            "enum": [
              "queued",
              "deferred",
              "delivered",
              "bounced",
              "mixed",
              "untracked",
              "pending",
              "failed",
              "unknown"
            ]
          },
          "source": {
            "enum": [
              "api",
              "smtp"
            ]
          },
          "createdAt": {
            "type": "string"
          },
          "recipients": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/OutboundRecipient"
            }
          },
          "events": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/OutboundEvent"
            }
          }
        },
        "required": [
          "id",
          "messageId",
          "submissionStatus",
          "status",
          "recipients"
        ]
      },
      "OutboundList": {
        "type": "object",
        "properties": {
          "messages": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/OutboundMessage"
            }
          },
          "nextCursor": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "Suppressions": {
        "type": "object",
        "properties": {
          "suppressions": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string"
                },
                "address": {
                  "type": "string"
                },
                "dsn": {
                  "type": "string"
                },
                "reason": {
                  "enum": [
                    "invalid_recipient",
                    "verified_complaint"
                  ]
                },
                "canRelease": {
                  "type": "boolean"
                },
                "createdAt": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "SuppressionReleased": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "released": {
            "const": true
          }
        }
      },
      "OutgoingWebhookEvent": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "type": {
            "const": "message.delivery_updated"
          },
          "createdAt": {
            "type": "string"
          },
          "data": {
            "type": "object",
            "properties": {
              "messageId": {
                "type": "string"
              },
              "recipientId": {
                "type": "string"
              },
              "status": {
                "enum": [
                  "queued",
                  "deferred",
                  "delivered",
                  "bounced"
                ]
              },
              "dsn": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "category": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "transport": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "messageId",
              "recipientId",
              "status"
            ],
            "additionalProperties": false
          }
        },
        "required": [
          "id",
          "type",
          "createdAt",
          "data"
        ]
      },
      "WebhookEvent": {
        "oneOf": [
          {
            "$ref": "#/components/schemas/IncomingWebhookEvent"
          },
          {
            "$ref": "#/components/schemas/OutgoingWebhookEvent"
          }
        ]
      },
      "AccessKey": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          },
          "keyHint": {
            "type": "string"
          },
          "scopes": {
            "type": "array",
            "items": {
              "enum": [
                "mail:read",
                "mail:send",
                "domains:read",
                "domains:write"
              ]
            }
          },
          "status": {
            "enum": [
              "active",
              "expired",
              "revoked"
            ]
          },
          "expiresAt": {
            "type": "string",
            "format": "date-time"
          },
          "createdAt": {
            "type": "string"
          },
          "lastUsedAt": {
            "type": [
              "string",
              "null"
            ]
          },
          "revokedAt": {
            "type": [
              "string",
              "null"
            ]
          },
          "allowedSenders": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "allowedRecipients": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "type": "string"
            }
          },
          "dailyRecipientLimit": {
            "type": "integer"
          },
          "totalRecipientBudget": {
            "type": "integer"
          },
          "usedRecipients": {
            "type": "integer"
          },
          "remainingRecipients": {
            "type": "integer"
          }
        },
        "required": [
          "id",
          "name",
          "scopes",
          "status",
          "expiresAt",
          "keyHint"
        ]
      },
      "DomainKeyCreate": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 60
          },
          "scopes": {
            "type": "array",
            "minItems": 1,
            "items": {
              "enum": [
                "domains:read",
                "domains:write"
              ]
            }
          },
          "expiresAt": {
            "type": "string",
            "format": "date-time"
          },
          "factorCode": {
            "type": "string",
            "writeOnly": true
          }
        },
        "required": [
          "name",
          "scopes"
        ]
      },
      "DomainKeyRevoke": {
        "type": "object",
        "properties": {
          "factorCode": {
            "type": "string",
            "writeOnly": true
          }
        },
        "required": []
      },
      "DomainKeyList": {
        "type": "object",
        "properties": {
          "email": {
            "type": "string"
          },
          "keys": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AccessKey"
            }
          }
        },
        "required": [
          "email",
          "keys"
        ]
      },
      "DomainKeyIssued": {
        "type": "object",
        "properties": {
          "apiKey": {
            "type": "string",
            "description": "One-time secret. Store securely and never log."
          },
          "key": {
            "$ref": "#/components/schemas/AccessKey"
          }
        },
        "required": [
          "apiKey",
          "key"
        ]
      },
      "DomainKeyRevoked": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "revoked": {
            "const": true
          }
        },
        "required": [
          "id",
          "revoked"
        ]
      },
      "DomainCheckout": {
        "oneOf": [
          {
            "type": "object",
            "properties": {
              "kind": {
                "const": "personal",
                "description": "Recurring card subscription: human Personal or agent domain hosting, $1/calendar month."
              }
            },
            "required": [
              "kind"
            ]
          },
          {
            "type": "object",
            "properties": {
              "kind": {
                "enum": [
                  "pro",
                  "team"
                ],
                "description": "Recurring card subscription for people: Pro $4/month (500 recipients/day, 3 domains) or Team $8/month (1,500/day shared across mailboxes, 10 domains). Switching from another plan credits unused time. See https://keykeeper.world/pricing."
              }
            },
            "required": [
              "kind"
            ]
          },
          {
            "type": "object",
            "properties": {
              "kind": {
                "const": "mail_credits"
              },
              "amountCents": {
                "enum": [
                  100,
                  500,
                  1000,
                  2500
                ]
              }
            },
            "required": [
              "kind",
              "amountCents"
            ]
          },
          {
            "type": "object",
            "properties": {
              "kind": {
                "const": "domain_hosting"
              },
              "periods": {
                "type": "integer",
                "minimum": 1,
                "maximum": 12,
                "default": 1
              }
            },
            "required": [
              "kind"
            ]
          },
          {
            "type": "object",
            "properties": {
              "kind": {
                "const": "domain_addon"
              },
              "domainId": {
                "type": "string",
                "format": "uuid"
              },
              "periods": {
                "type": "integer",
                "minimum": 1,
                "maximum": 12,
                "default": 1
              }
            },
            "required": [
              "kind",
              "domainId"
            ]
          }
        ]
      },
      "DomainCheckoutResult": {
        "type": "object",
        "properties": {
          "orderId": {
            "type": "string",
            "format": "uuid"
          },
          "status": {
            "type": "string"
          },
          "url": {
            "type": "string",
            "format": "uri"
          }
        },
        "required": [
          "orderId",
          "status"
        ]
      },
      "DomainLogin": {
        "type": "object",
        "properties": {
          "email": {
            "type": "string",
            "format": "email"
          },
          "password": {
            "type": "string",
            "writeOnly": true
          },
          "totpCode": {
            "type": "string",
            "writeOnly": true
          },
          "backupCode": {
            "type": "string",
            "writeOnly": true
          }
        },
        "required": [
          "email",
          "password"
        ]
      },
      "DomainOwnerRegistration": {
        "type": "object",
        "properties": {
          "email": {
            "type": "string",
            "format": "email",
            "description": "An available address on a public KeyKeeper signup domain, not the custom domain being added."
          },
          "password": {
            "type": "string",
            "minLength": 12,
            "writeOnly": true,
            "description": "At least 12 characters and at most 72 UTF-8 bytes. Send securely; never log."
          },
          "name": {
            "type": "string",
            "maxLength": 100
          }
        },
        "required": [
          "email",
          "password"
        ]
      },
      "DomainSession": {
        "type": "object",
        "properties": {
          "token": {
            "type": "string",
            "description": "Sensitive session JWT. Use as a Bearer token for owner APIs; not an agent API key."
          },
          "user": {
            "type": "object"
          }
        },
        "required": [
          "token",
          "user"
        ]
      },
      "DomainAdd": {
        "type": "object",
        "properties": {
          "domain": {
            "type": "string",
            "maxLength": 189,
            "example": "example.com",
            "description": "A domain you own. This attaches email hosting; it does not purchase a domain or change nameservers."
          },
          "sendOnly": {
            "type": "boolean",
            "default": false,
            "description": "Send-only (Pro and Team): KeyKeeper signs and sends for the domain while its inbox and MX stay at another provider. No MX record is required and no mailboxes can be created on it."
          }
        },
        "required": [
          "domain"
        ]
      },
      "DomainId": {
        "type": "object",
        "properties": {
          "domainId": {
            "type": "string",
            "format": "uuid"
          }
        },
        "required": [
          "domainId"
        ]
      },
      "DomainEnabled": {
        "type": "object",
        "properties": {
          "domainId": {
            "type": "string",
            "format": "uuid"
          },
          "enabled": {
            "type": "boolean"
          },
          "sendOnly": {
            "type": "boolean",
            "description": "Switch between hosted and send-only. Becoming send-only requires no separate mailboxes on the domain and a free send-only allowance; DNS is rechecked immediately."
          }
        },
        "required": [
          "domainId"
        ]
      },
      "DomainAliasCreate": {
        "type": "object",
        "properties": {
          "domainId": {
            "type": "string",
            "format": "uuid"
          },
          "local": {
            "type": "string",
            "pattern": "^[a-zA-Z0-9][a-zA-Z0-9._-]{0,63}$"
          },
          "destinationUserId": {
            "type": "string",
            "format": "uuid",
            "description": "Defaults to owner inbox. Otherwise an enabled mailbox on this same domain; no external forwarding."
          }
        },
        "required": [
          "domainId",
          "local"
        ]
      },
      "DomainAddressId": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          }
        },
        "required": [
          "id"
        ]
      },
      "DomainMailboxEnabled": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "enabled": {
            "type": "boolean"
          }
        },
        "required": [
          "id",
          "enabled"
        ]
      },
      "DomainMailboxCreate": {
        "oneOf": [
          {
            "type": "object",
            "properties": {
              "domainId": {
                "type": "string",
                "format": "uuid"
              },
              "local": {
                "type": "string",
                "pattern": "^[a-zA-Z0-9][a-zA-Z0-9._-]{0,63}$"
              },
              "name": {
                "type": "string",
                "maxLength": 100
              },
              "accountType": {
                "const": "agent"
              }
            },
            "required": [
              "domainId",
              "local",
              "accountType"
            ]
          },
          {
            "type": "object",
            "properties": {
              "domainId": {
                "type": "string",
                "format": "uuid"
              },
              "local": {
                "type": "string",
                "pattern": "^[a-zA-Z0-9][a-zA-Z0-9._-]{0,63}$"
              },
              "name": {
                "type": "string",
                "maxLength": 100
              },
              "accountType": {
                "const": "human"
              },
              "password": {
                "type": "string",
                "minLength": 12,
                "writeOnly": true,
                "description": "At least 12 characters and at most 72 UTF-8 bytes. Send securely; never log."
              }
            },
            "required": [
              "domainId",
              "local",
              "accountType",
              "password"
            ]
          }
        ]
      },
      "DomainDnsRecord": {
        "type": "object",
        "properties": {
          "check": {
            "enum": [
              "ownership",
              "mx",
              "spf",
              "dkim",
              "dmarc"
            ]
          },
          "type": {
            "enum": [
              "TXT",
              "MX"
            ]
          },
          "name": {
            "type": "string"
          },
          "value": {
            "type": "string"
          },
          "priority": {
            "type": "integer"
          },
          "purpose": {
            "type": "string"
          }
        },
        "required": [
          "check",
          "type",
          "name",
          "value",
          "purpose"
        ]
      },
      "DomainDnsDetail": {
        "type": "object",
        "properties": {
          "status": {
            "enum": [
              "verified",
              "waiting",
              "attention",
              "unavailable"
            ]
          },
          "message": {
            "type": "string"
          },
          "lookupName": {
            "type": "string"
          },
          "recordType": {
            "enum": [
              "TXT",
              "MX"
            ]
          },
          "source": {
            "enum": [
              "recursive_dns",
              "authoritative_dns"
            ]
          },
          "nameservers": {
            "type": "array",
            "minItems": 2,
            "maxItems": 2,
            "items": {
              "type": "string"
            },
            "description": "Present when both authoritative Cloudflare nameservers confirmed the record."
          },
          "checkedAt": {
            "type": "string",
            "format": "date-time"
          },
          "observed": {
            "type": "array",
            "maxItems": 5,
            "items": {
              "type": "string",
              "maxLength": 4096
            }
          }
        },
        "required": [
          "status",
          "message",
          "lookupName",
          "recordType",
          "source",
          "checkedAt",
          "observed"
        ]
      },
      "ExtraDomainHosting": {
        "type": "object",
        "properties": {
          "additional": {
            "type": "boolean"
          },
          "status": {
            "enum": [
              "included",
              "payment_required",
              "active",
              "grace",
              "expired"
            ]
          },
          "expiresAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "graceEndsAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "canCreateAddresses": {
            "type": "boolean"
          },
          "mailActive": {
            "type": "boolean"
          },
          "centsPerPeriod": {
            "const": 100
          },
          "daysPerPeriod": {
            "const": 30
          }
        },
        "required": [
          "additional",
          "status",
          "expiresAt",
          "graceEndsAt",
          "canCreateAddresses",
          "mailActive",
          "centsPerPeriod",
          "daysPerPeriod"
        ]
      },
      "Domain": {
        "type": "object",
        "properties": {
          "sendOnly": {
            "type": "boolean",
            "description": "Sending only; incoming mail stays at another provider."
          },
          "hosting": {
            "$ref": "#/components/schemas/ExtraDomainHosting"
          },
          "mailReady": {
            "type": "boolean",
            "description": "DNS and domain hosting permit mail; addresses must also exist and be enabled. This is not delivery evidence."
          },
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          },
          "enabled": {
            "type": "boolean"
          },
          "verified": {
            "type": "boolean",
            "description": "Enabled domain with all checks passed, signing ready and an unexpired DNS verification. This does not prove that an address exists or that mail reached a recipient."
          },
          "ownershipVerified": {
            "type": "boolean"
          },
          "signingReady": {
            "type": "boolean"
          },
          "dnsStatus": {
            "type": "object",
            "properties": {
              "ownership": {
                "type": "boolean"
              },
              "mx": {
                "type": "boolean"
              },
              "spf": {
                "type": "boolean"
              },
              "dkim": {
                "type": "boolean"
              },
              "dmarc": {
                "type": "boolean"
              }
            },
            "required": [
              "ownership",
              "mx",
              "spf",
              "dkim",
              "dmarc"
            ]
          },
          "dnsRecords": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DomainDnsRecord"
            },
            "description": "Exact recommended DNS values. DKIM appears after ownership verification and asynchronous signing-key preparation. Do not blindly replace existing SPF/DMARC or publish MX before addresses exist."
          },
          "dnsDetails": {
            "type": "object",
            "properties": {
              "ownership": {
                "$ref": "#/components/schemas/DomainDnsDetail"
              },
              "mx": {
                "$ref": "#/components/schemas/DomainDnsDetail"
              },
              "spf": {
                "$ref": "#/components/schemas/DomainDnsDetail"
              },
              "dkim": {
                "$ref": "#/components/schemas/DomainDnsDetail"
              },
              "dmarc": {
                "$ref": "#/components/schemas/DomainDnsDetail"
              }
            },
            "required": [
              "ownership",
              "mx",
              "spf",
              "dkim",
              "dmarc"
            ],
            "description": "Present on verify responses: current lookup evidence. A previously stored dnsStatus can remain true during a temporary resolver failure; read these details to distinguish retained status from a fresh verified lookup."
          },
          "checkedAt": {
            "type": [
              "string",
              "null"
            ]
          },
          "dnsError": {
            "type": [
              "string",
              "null"
            ]
          },
          "createdAt": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "name",
          "enabled",
          "verified",
          "hosting",
          "mailReady",
          "ownershipVerified",
          "signingReady",
          "dnsStatus",
          "dnsRecords"
        ]
      },
      "DomainResult": {
        "type": "object",
        "properties": {
          "domain": {
            "$ref": "#/components/schemas/Domain"
          },
          "success": {
            "const": true
          }
        },
        "required": [
          "domain"
        ]
      },
      "DomainInventory": {
        "type": "object",
        "properties": {
          "domains": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Domain"
            }
          },
          "aliases": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "format": "uuid"
                },
                "domainId": {
                  "type": "string",
                  "format": "uuid"
                },
                "address": {
                  "type": "string"
                },
                "destination": {
                  "type": "string"
                }
              },
              "required": [
                "id",
                "domainId",
                "address",
                "destination"
              ]
            }
          },
          "mailboxes": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "format": "uuid"
                },
                "domainId": {
                  "type": "string",
                  "format": "uuid"
                },
                "email": {
                  "type": "string"
                },
                "name": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "accountType": {
                  "enum": [
                    "human",
                    "agent"
                  ]
                },
                "enabled": {
                  "enum": [
                    0,
                    1
                  ]
                }
              },
              "required": [
                "id",
                "domainId",
                "email",
                "accountType",
                "enabled"
              ]
            }
          },
          "canCreateAddresses": {
            "type": "boolean",
            "description": "Paid entitlement is active. Ownership, domain status, address availability and limits are checked separately."
          },
          "limits": {
            "type": "object",
            "properties": {
              "domains": {
                "const": 20
              },
              "includedDomains": {
                "type": "integer"
              },
              "sendOnlyDomains": {
                "type": "integer"
              },
              "aliases": {
                "type": "integer",
                "description": "Per domain"
              },
              "mailboxes": {
                "type": "integer",
                "description": "Per domain"
              }
            },
            "required": [
              "domains",
              "aliases",
              "mailboxes"
            ],
            "description": "This account's plan limits. Included domains: 1 on Personal, 3 on Pro, 10 on Team. Aliases per domain: 10 on Personal, 25 on Pro, 50 on Team. Mailboxes per domain: 10 on Personal, 10 on Pro, 25 on Team. Send-only domains: 5 on Pro, 10 on Team."
          }
        },
        "required": [
          "domains",
          "aliases",
          "mailboxes",
          "canCreateAddresses",
          "limits"
        ]
      },
      "DomainSuccess": {
        "type": "object",
        "properties": {
          "success": {
            "const": true
          }
        },
        "required": [
          "success"
        ]
      },
      "DomainAliasResult": {
        "type": "object",
        "properties": {
          "success": {
            "const": true
          },
          "alias": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "format": "uuid"
              },
              "address": {
                "type": "string"
              }
            },
            "required": [
              "id",
              "address"
            ]
          }
        },
        "required": [
          "success",
          "alias"
        ]
      },
      "DomainMailboxResult": {
        "type": "object",
        "properties": {
          "success": {
            "const": true
          },
          "userId": {
            "type": "string",
            "format": "uuid"
          },
          "email": {
            "type": "string"
          },
          "mailboxReady": {
            "const": true
          },
          "apiKey": {
            "type": "string",
            "description": "Only returned for an agent mailbox. One-time secret; securely store it before closing the response."
          },
          "credits": {
            "const": 0
          },
          "message": {
            "type": "string"
          }
        },
        "required": [
          "success",
          "userId",
          "email",
          "mailboxReady"
        ]
      },
      "ProposalCreate": {
        "type": "object",
        "properties": {
          "clientKey": {
            "type": "string",
            "format": "uuid"
          },
          "message": {
            "type": "object",
            "properties": {
              "from": {
                "type": "string"
              },
              "to": {
                "type": "string"
              },
              "cc": {
                "type": "string"
              },
              "bcc": {
                "type": "string"
              },
              "subject": {
                "type": "string",
                "maxLength": 998
              },
              "body": {
                "type": "string",
                "description": "Plain text, at most 1 MiB. HTML and encrypted proposals are not supported."
              },
              "mode": {
                "enum": [
                  "new",
                  "reply",
                  "replyAll",
                  "forward"
                ]
              },
              "inReplyTo": {
                "type": "string"
              },
              "references": {
                "type": "array",
                "maxItems": 20,
                "items": {
                  "type": "string"
                }
              },
              "attachments": {
                "type": "array",
                "maxItems": 20,
                "description": "At most 8 MiB decoded total; inline bytes only.",
                "items": {
                  "type": "object",
                  "properties": {
                    "filename": {
                      "type": "string"
                    },
                    "encoding": {
                      "const": "base64"
                    },
                    "content": {
                      "type": "string"
                    },
                    "size": {
                      "type": "integer",
                      "readOnly": true
                    }
                  },
                  "required": [
                    "filename",
                    "encoding",
                    "content"
                  ],
                  "additionalProperties": false
                }
              }
            },
            "required": [
              "to",
              "subject",
              "body"
            ],
            "additionalProperties": false
          }
        },
        "required": [
          "clientKey",
          "message"
        ],
        "additionalProperties": false
      },
      "ProposalChange": {
        "type": "object",
        "properties": {
          "action": {
            "enum": [
              "edit",
              "withdraw"
            ]
          },
          "revision": {
            "type": "integer",
            "minimum": 1
          },
          "contentHash": {
            "type": "string",
            "pattern": "^[a-f0-9]{64}$"
          },
          "message": {
            "type": "object",
            "properties": {
              "from": {
                "type": "string"
              },
              "to": {
                "type": "string"
              },
              "cc": {
                "type": "string"
              },
              "bcc": {
                "type": "string"
              },
              "subject": {
                "type": "string",
                "maxLength": 998
              },
              "body": {
                "type": "string",
                "description": "Plain text, at most 1 MiB. HTML and encrypted proposals are not supported."
              },
              "mode": {
                "enum": [
                  "new",
                  "reply",
                  "replyAll",
                  "forward"
                ]
              },
              "inReplyTo": {
                "type": "string"
              },
              "references": {
                "type": "array",
                "maxItems": 20,
                "items": {
                  "type": "string"
                }
              },
              "attachments": {
                "type": "array",
                "maxItems": 20,
                "description": "At most 8 MiB decoded total; inline bytes only.",
                "items": {
                  "type": "object",
                  "properties": {
                    "filename": {
                      "type": "string"
                    },
                    "encoding": {
                      "const": "base64"
                    },
                    "content": {
                      "type": "string"
                    },
                    "size": {
                      "type": "integer",
                      "readOnly": true
                    }
                  },
                  "required": [
                    "filename",
                    "encoding",
                    "content"
                  ],
                  "additionalProperties": false
                }
              }
            },
            "required": [
              "to",
              "subject",
              "body"
            ],
            "additionalProperties": false
          }
        },
        "required": [
          "action",
          "revision",
          "contentHash"
        ],
        "additionalProperties": false
      },
      "Proposal": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "clientKey": {
            "type": "string",
            "format": "uuid"
          },
          "revision": {
            "type": "integer"
          },
          "contentHash": {
            "type": "string"
          },
          "state": {
            "enum": [
              "pending",
              "reviewing",
              "approved",
              "rejected",
              "withdrawn",
              "expired"
            ]
          },
          "agentName": {
            "type": "string"
          },
          "createdAt": {
            "type": "string"
          },
          "expiresAt": {
            "type": "string"
          },
          "message": {
            "type": "object",
            "properties": {
              "from": {
                "type": "string"
              },
              "to": {
                "type": "string"
              },
              "cc": {
                "type": "string"
              },
              "bcc": {
                "type": "string"
              },
              "subject": {
                "type": "string",
                "maxLength": 998
              },
              "body": {
                "type": "string",
                "description": "Plain text, at most 1 MiB. HTML and encrypted proposals are not supported."
              },
              "mode": {
                "enum": [
                  "new",
                  "reply",
                  "replyAll",
                  "forward"
                ]
              },
              "inReplyTo": {
                "type": "string"
              },
              "references": {
                "type": "array",
                "maxItems": 20,
                "items": {
                  "type": "string"
                }
              },
              "attachments": {
                "type": "array",
                "maxItems": 20,
                "description": "At most 8 MiB decoded total; inline bytes only.",
                "items": {
                  "type": "object",
                  "properties": {
                    "filename": {
                      "type": "string"
                    },
                    "encoding": {
                      "const": "base64"
                    },
                    "content": {
                      "type": "string"
                    },
                    "size": {
                      "type": "integer",
                      "readOnly": true
                    }
                  },
                  "required": [
                    "filename",
                    "encoding",
                    "content"
                  ],
                  "additionalProperties": false
                }
              }
            },
            "required": [
              "to",
              "subject",
              "body"
            ],
            "additionalProperties": false
          },
          "summary": {
            "type": "object"
          },
          "submission": {
            "type": "object",
            "properties": {
              "status": {
                "type": "string"
              },
              "id": {
                "type": "string",
                "format": "uuid"
              }
            }
          },
          "draft": {
            "type": "object"
          },
          "audit": {
            "type": "array",
            "items": {
              "type": "object"
            }
          }
        },
        "required": [
          "id",
          "revision",
          "contentHash",
          "state"
        ]
      },
      "ProposalList": {
        "type": "object",
        "properties": {
          "pendingCount": {
            "type": "integer"
          },
          "proposals": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Proposal"
            }
          }
        },
        "required": [
          "pendingCount",
          "proposals"
        ],
        "additionalProperties": false
      }
    }
  },
  "externalDocs": {
    "url": "https://keykeeper.world/docs/api"
  }
}
