{
  "openapi": "3.1.0",
  "info": {
    "title": "papers.fm API",
    "version": "0.6.0",
    "description": "Internal Papers.fm password/Google/Apple accounts issue secure browser cookies or independently revocable native bearer tokens. Browser mutations require matching Origin; cookie-free native JSON requests use x-papers-client=native. OAuth callbacks verify state/nonce and native handoff requires PKCE. Jobs use their own server secret. Provider connections require recent MFA. Identity headers do not authenticate. v0.5.0 adds license-checked PMC structured text, server-counted paper-completion spacing, Stripe-hosted recurring billing, account entitlements and audio-only sponsor choices while driving. Free policy defaults to 10 completed papers and paid policy to 5; administrators can configure either, including zero for no ads. Paid status requires verified Stripe reconciliation; returning from checkout does not grant a paid tier. Version 0.5.1 adds protected error diagnostics and a safe incident reference on captured failures; client reports accept fixed metadata only. Version 0.6.0 adds reviewed site design publication and explicit read-only Gmail account connections. The account email supplies a Google login hint only; matching email never links accounts or authorizes API use. Direct ChatGPT account connection remains unavailable pending approved provider registration; personal OpenAI API keys retain the existing speech contract."
  },
  "servers": [
    {
      "url": "/api/v1"
    }
  ],
  "paths": {
    "/health": {
      "get": {
        "summary": "Capabilities and release health",
        "x-authentication": "public",
        "responses": {
          "200": {
            "description": "Success"
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Not authorized"
          },
          "409": {
            "description": "Conflict or capability not configured"
          },
          "503": {
            "description": "Upstream or storage unavailable"
          }
        }
      }
    },
    "/search": {
      "get": {
        "summary": "Search PubMed with exact query and retrieval details",
        "x-authentication": "public",
        "responses": {
          "200": {
            "description": "Success"
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Not authorized"
          },
          "409": {
            "description": "Conflict or capability not configured"
          },
          "503": {
            "description": "Upstream or storage unavailable"
          }
        },
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "maxLength": 4000
            }
          },
          {
            "name": "offset",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 0,
              "maximum": 9999
            }
          },
          {
            "name": "sort",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "pub_date",
                "relevance"
              ]
            }
          }
        ]
      }
    },
    "/me": {
      "get": {
        "summary": "Current account",
        "x-authentication": "verified browser session; some operations additionally require recent MFA",
        "responses": {
          "200": {
            "description": "Success"
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Not authorized"
          },
          "409": {
            "description": "Conflict or capability not configured"
          },
          "503": {
            "description": "Upstream or storage unavailable"
          }
        }
      },
      "patch": {
        "summary": "Update listening preferences",
        "x-authentication": "verified browser session; some operations additionally require recent MFA",
        "responses": {
          "200": {
            "description": "Success"
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Not authorized"
          },
          "409": {
            "description": "Conflict or capability not configured"
          },
          "503": {
            "description": "Upstream or storage unavailable"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              },
              "examples": {
                "guide": {
                  "summary": "Use exact fields defined in docs/api.md and server Zod schema",
                  "value": {}
                }
              }
            }
          }
        },
        "description": "Merges validated device, provider, independent cloudVoices, language, startup and sponsoredBreaks preferences. Google default en-GB-Studio-B."
      }
    },
    "/collections": {
      "get": {
        "summary": "Authorized collections",
        "x-authentication": "verified browser session; some operations additionally require recent MFA",
        "responses": {
          "200": {
            "description": "Success"
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Not authorized"
          },
          "409": {
            "description": "Conflict or capability not configured"
          },
          "503": {
            "description": "Upstream or storage unavailable"
          }
        }
      },
      "post": {
        "summary": "Create private or shared collection",
        "x-authentication": "verified browser session; some operations additionally require recent MFA",
        "responses": {
          "200": {
            "description": "Success"
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Not authorized"
          },
          "409": {
            "description": "Conflict or capability not configured"
          },
          "503": {
            "description": "Upstream or storage unavailable"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              },
              "examples": {
                "guide": {
                  "summary": "Use exact fields defined in docs/api.md and server Zod schema",
                  "value": {}
                }
              }
            }
          }
        }
      }
    },
    "/collections/{id}": {
      "get": {
        "summary": "Authorized items, playlists and stream",
        "x-authentication": "verified browser session; some operations additionally require recent MFA",
        "responses": {
          "200": {
            "description": "Success"
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Not authorized"
          },
          "409": {
            "description": "Conflict or capability not configured"
          },
          "503": {
            "description": "Upstream or storage unavailable"
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      },
      "patch": {
        "summary": "Rename, reorder, archive or change visibility",
        "x-authentication": "verified browser session; some operations additionally require recent MFA",
        "responses": {
          "200": {
            "description": "Success"
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Not authorized"
          },
          "409": {
            "description": "Conflict or capability not configured"
          },
          "503": {
            "description": "Upstream or storage unavailable"
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              },
              "examples": {
                "guide": {
                  "summary": "Use exact fields defined in docs/api.md and server Zod schema",
                  "value": {}
                }
              }
            }
          }
        }
      },
      "delete": {
        "summary": "Soft-delete owned collection",
        "x-authentication": "verified browser session; some operations additionally require recent MFA",
        "responses": {
          "200": {
            "description": "Success"
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Not authorized"
          },
          "409": {
            "description": "Conflict or capability not configured"
          },
          "503": {
            "description": "Upstream or storage unavailable"
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      },
      "parameters": [
        {
          "name": "id",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          }
        }
      ]
    },
    "/collections/{id}/items": {
      "post": {
        "summary": "Append unique paper references",
        "x-authentication": "verified browser session; some operations additionally require recent MFA",
        "responses": {
          "200": {
            "description": "Success"
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Not authorized"
          },
          "409": {
            "description": "Conflict or capability not configured"
          },
          "503": {
            "description": "Upstream or storage unavailable"
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              },
              "examples": {
                "guide": {
                  "summary": "Use exact fields defined in docs/api.md and server Zod schema",
                  "value": {}
                }
              }
            }
          }
        }
      },
      "delete": {
        "summary": "Remove references",
        "x-authentication": "verified browser session; some operations additionally require recent MFA",
        "responses": {
          "200": {
            "description": "Success"
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Not authorized"
          },
          "409": {
            "description": "Conflict or capability not configured"
          },
          "503": {
            "description": "Upstream or storage unavailable"
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      },
      "parameters": [
        {
          "name": "id",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          }
        }
      ]
    },
    "/collections/{id}/playlists": {
      "post": {
        "summary": "Link owned playlist into channel",
        "x-authentication": "verified browser session; some operations additionally require recent MFA",
        "responses": {
          "200": {
            "description": "Success"
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Not authorized"
          },
          "409": {
            "description": "Conflict or capability not configured"
          },
          "503": {
            "description": "Upstream or storage unavailable"
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              },
              "examples": {
                "guide": {
                  "summary": "Use exact fields defined in docs/api.md and server Zod schema",
                  "value": {}
                }
              }
            }
          }
        }
      },
      "delete": {
        "summary": "Unlink playlist",
        "x-authentication": "verified browser session; some operations additionally require recent MFA",
        "responses": {
          "200": {
            "description": "Success"
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Not authorized"
          },
          "409": {
            "description": "Conflict or capability not configured"
          },
          "503": {
            "description": "Upstream or storage unavailable"
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      },
      "patch": {
        "summary": "Reorder all linked playlists; owner only",
        "x-authentication": "verified browser session; some operations additionally require recent MFA",
        "responses": {
          "200": {
            "description": "Success"
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Not authorized"
          },
          "409": {
            "description": "Conflict or capability not configured"
          },
          "503": {
            "description": "Upstream or storage unavailable"
          },
          "429": {
            "description": "Attempt or account quota exceeded"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "order"
                ],
                "properties": {
                  "order": {
                    "type": "array",
                    "maxItems": 500,
                    "uniqueItems": true,
                    "items": {
                      "type": "string",
                      "format": "uuid"
                    }
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ]
      },
      "parameters": [
        {
          "name": "id",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          }
        }
      ]
    },
    "/collections/{id}/duplicate": {
      "post": {
        "summary": "Create private copy",
        "x-authentication": "verified browser session; some operations additionally require recent MFA",
        "responses": {
          "200": {
            "description": "Success"
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Not authorized"
          },
          "409": {
            "description": "Conflict or capability not configured"
          },
          "503": {
            "description": "Upstream or storage unavailable"
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              },
              "examples": {
                "guide": {
                  "summary": "Use exact fields defined in docs/api.md and server Zod schema",
                  "value": {}
                }
              }
            }
          }
        }
      },
      "parameters": [
        {
          "name": "id",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          }
        }
      ]
    },
    "/collections/{id}/follow": {
      "post": {
        "summary": "Follow authorized collection",
        "x-authentication": "verified browser session; some operations additionally require recent MFA",
        "responses": {
          "200": {
            "description": "Success"
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Not authorized"
          },
          "409": {
            "description": "Conflict or capability not configured"
          },
          "503": {
            "description": "Upstream or storage unavailable"
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              },
              "examples": {
                "guide": {
                  "summary": "Use exact fields defined in docs/api.md and server Zod schema",
                  "value": {}
                }
              }
            }
          }
        }
      },
      "delete": {
        "summary": "Unfollow",
        "x-authentication": "verified browser session; some operations additionally require recent MFA",
        "responses": {
          "200": {
            "description": "Success"
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Not authorized"
          },
          "409": {
            "description": "Conflict or capability not configured"
          },
          "503": {
            "description": "Upstream or storage unavailable"
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      },
      "parameters": [
        {
          "name": "id",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          }
        }
      ]
    },
    "/collections/{id}/invite": {
      "post": {
        "summary": "Create email-bound collection invitation",
        "x-authentication": "verified browser session; some operations additionally require recent MFA",
        "responses": {
          "200": {
            "description": "Success"
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Not authorized"
          },
          "409": {
            "description": "Conflict or capability not configured"
          },
          "503": {
            "description": "Upstream or storage unavailable"
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              },
              "examples": {
                "guide": {
                  "summary": "Use exact fields defined in docs/api.md and server Zod schema",
                  "value": {}
                }
              }
            }
          }
        }
      },
      "parameters": [
        {
          "name": "id",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          }
        }
      ]
    },
    "/invites": {
      "post": {
        "summary": "Accept single-use verified-email invitation",
        "x-authentication": "verified browser session; some operations additionally require recent MFA",
        "responses": {
          "200": {
            "description": "Success"
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Not authorized"
          },
          "409": {
            "description": "Conflict or capability not configured"
          },
          "503": {
            "description": "Upstream or storage unavailable"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              },
              "examples": {
                "guide": {
                  "summary": "Use exact fields defined in docs/api.md and server Zod schema",
                  "value": {}
                }
              }
            }
          }
        }
      }
    },
    "/queries": {
      "get": {
        "summary": "Owned saved searches",
        "x-authentication": "verified browser session; some operations additionally require recent MFA",
        "responses": {
          "200": {
            "description": "Success"
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Not authorized"
          },
          "409": {
            "description": "Conflict or capability not configured"
          },
          "503": {
            "description": "Upstream or storage unavailable"
          }
        }
      },
      "post": {
        "summary": "Create saved search",
        "x-authentication": "verified browser session; some operations additionally require recent MFA",
        "responses": {
          "200": {
            "description": "Success"
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Not authorized"
          },
          "409": {
            "description": "Conflict or capability not configured"
          },
          "503": {
            "description": "Upstream or storage unavailable"
          },
          "201": {
            "description": "Created, with id"
          },
          "429": {
            "description": "100 saved or 20 scheduled search limit"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SavedSearchInput"
              }
            }
          }
        }
      }
    },
    "/queries/{id}": {
      "patch": {
        "summary": "Edit/version a saved search",
        "x-authentication": "verified browser session; some operations additionally require recent MFA",
        "responses": {
          "200": {
            "description": "Success"
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Not authorized"
          },
          "409": {
            "description": "Conflict or capability not configured"
          },
          "503": {
            "description": "Upstream or storage unavailable"
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "name",
                  "query",
                  "expectedVersion"
                ],
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 180
                  },
                  "query": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 4000
                  },
                  "groupName": {
                    "type": "string",
                    "maxLength": 80,
                    "default": ""
                  },
                  "collectionId": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "format": "uuid",
                    "default": null
                  },
                  "frequency": {
                    "type": "string",
                    "enum": [
                      "manual",
                      "daily",
                      "weekly",
                      "monthly"
                    ],
                    "default": "manual"
                  },
                  "timezone": {
                    "type": "string",
                    "default": "Europe/Berlin"
                  },
                  "expectedVersion": {
                    "type": "integer",
                    "minimum": 1,
                    "description": "Required on PATCH; match version from GET /queries."
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "summary": "Delete owned search",
        "x-authentication": "verified browser session; some operations additionally require recent MFA",
        "responses": {
          "200": {
            "description": "Success"
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Not authorized"
          },
          "409": {
            "description": "Conflict or capability not configured"
          },
          "503": {
            "description": "Upstream or storage unavailable"
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      },
      "parameters": [
        {
          "name": "id",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          }
        }
      ]
    },
    "/queries/{id}/run": {
      "post": {
        "summary": "Run a leased incremental refresh",
        "x-authentication": "verified browser session; some operations additionally require recent MFA",
        "responses": {
          "200": {
            "description": "Success"
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Not authorized"
          },
          "409": {
            "description": "Conflict or capability not configured"
          },
          "503": {
            "description": "Upstream or storage unavailable"
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              },
              "examples": {
                "guide": {
                  "summary": "Use exact fields defined in docs/api.md and server Zod schema",
                  "value": {}
                }
              }
            }
          }
        }
      },
      "parameters": [
        {
          "name": "id",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          }
        }
      ]
    },
    "/jobs": {
      "post": {
        "summary": "Run due server searches using dedicated bearer secret",
        "x-authentication": "server-secret",
        "responses": {
          "200": {
            "description": "Success"
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Not authorized"
          },
          "409": {
            "description": "Conflict or capability not configured"
          },
          "503": {
            "description": "Upstream or storage unavailable"
          }
        },
        "security": [
          {
            "jobSecret": []
          }
        ]
      }
    },
    "/progress": {
      "get": {
        "summary": "Source-linked listening history",
        "x-authentication": "verified browser session; some operations additionally require recent MFA",
        "responses": {
          "200": {
            "description": "Success"
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Not authorized"
          },
          "409": {
            "description": "Conflict or capability not configured"
          },
          "503": {
            "description": "Upstream or storage unavailable"
          }
        }
      },
      "post": {
        "summary": "Persist newer progress",
        "x-authentication": "verified browser session; some operations additionally require recent MFA",
        "responses": {
          "200": {
            "description": "Success"
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Not authorized"
          },
          "409": {
            "description": "Conflict or capability not configured"
          },
          "503": {
            "description": "Upstream or storage unavailable"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              },
              "examples": {
                "guide": {
                  "summary": "Use exact fields defined in docs/api.md and server Zod schema",
                  "value": {}
                }
              }
            }
          }
        }
      }
    },
    "/providers": {
      "get": {
        "summary": "Connected provider metadata without secrets",
        "x-authentication": "verified browser session; some operations additionally require recent MFA",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "providers"
                  ],
                  "properties": {
                    "providers": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/ProviderMetadata"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Not authorized"
          },
          "409": {
            "description": "Conflict or capability not configured"
          },
          "503": {
            "description": "Upstream or storage unavailable"
          }
        }
      }
    },
    "/providers/{provider}": {
      "post": {
        "summary": "Store encrypted user credential with recent MFA",
        "x-authentication": "verified browser session; some operations additionally require recent MFA",
        "responses": {
          "200": {
            "description": "Success"
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Not authorized"
          },
          "409": {
            "description": "Conflict or capability not configured"
          },
          "503": {
            "description": "Upstream or storage unavailable"
          }
        },
        "parameters": [
          {
            "name": "provider",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              },
              "examples": {
                "guide": {
                  "summary": "Use exact fields defined in docs/api.md and server Zod schema",
                  "value": {}
                }
              }
            }
          }
        }
      },
      "delete": {
        "summary": "Revoke credential with recent MFA",
        "x-authentication": "verified browser session; some operations additionally require recent MFA",
        "responses": {
          "200": {
            "description": "Success"
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Not authorized"
          },
          "409": {
            "description": "Conflict or capability not configured"
          },
          "503": {
            "description": "Upstream or storage unavailable"
          }
        },
        "parameters": [
          {
            "name": "provider",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      },
      "patch": {
        "summary": "Change your monthly character allowance without replacing the provider credential",
        "description": "Owner-scoped and recent-MFA protected. Updates only the limit; recorded usage and the encrypted credential are preserved. Limits apply per provider per UTC calendar month. A total below used characters blocks further generation until raised or the next month. Provider billing and the shared site test are unchanged.",
        "x-authentication": "Internal session and recent MFA; browser requests require the canonical same-origin header. Native sessions use x-papers-mfa.",
        "security": [
          {
            "CookieSession": []
          },
          {
            "NativeSession": []
          }
        ],
        "parameters": [
          {
            "name": "provider",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "openai",
                "google"
              ]
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "limitChars"
                ],
                "properties": {
                  "limitChars": {
                    "type": "integer",
                    "minimum": 100,
                    "maximum": 1000000
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Allowance saved; metadata for the current UTC month. No credential secret is returned.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "provider"
                  ],
                  "properties": {
                    "ok": {
                      "const": true
                    },
                    "provider": {
                      "$ref": "#/components/schemas/ProviderMetadata"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid limit, provider, or unknown body field"
          },
          "401": {
            "description": "Sign-in required"
          },
          "403": {
            "description": "Recent MFA or canonical browser origin required"
          },
          "409": {
            "description": "This provider is not connected for the signed-in user"
          },
          "503": {
            "description": "Storage unavailable"
          }
        }
      }
    },
    "/mfa/enroll": {
      "post": {
        "summary": "Stage TOTP setup for 15 minutes; preserve active factor until verification",
        "x-authentication": "verified browser session; some operations additionally require recent MFA",
        "responses": {
          "200": {
            "description": "Success"
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Not authorized"
          },
          "409": {
            "description": "Conflict or capability not configured"
          },
          "503": {
            "description": "Upstream or storage unavailable"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              },
              "examples": {
                "guide": {
                  "summary": "Use exact fields defined in docs/api.md and server Zod schema",
                  "value": {}
                }
              }
            }
          }
        }
      }
    },
    "/mfa/verify": {
      "post": {
        "summary": "Verify TOTP and issue short-lived HttpOnly cookie",
        "x-authentication": "verified browser session; some operations additionally require recent MFA",
        "responses": {
          "200": {
            "description": "Verified. Returns ok; recoveryCodes only upon enrollment.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RecoveryCodes"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Not authorized"
          },
          "409": {
            "description": "Conflict or capability not configured"
          },
          "503": {
            "description": "Upstream or storage unavailable"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "code"
                ],
                "properties": {
                  "code": {
                    "type": "string",
                    "pattern": "^\\d{6}$"
                  },
                  "enrollment": {
                    "type": "boolean",
                    "description": "Verify pending setup; defaults true if MFA inactive."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/audio": {
      "post": {
        "summary": "Generate private original-text narration or reuse scoped cache",
        "x-authentication": "verified browser session; some operations additionally require recent MFA",
        "responses": {
          "200": {
            "description": "Success"
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Not authorized"
          },
          "409": {
            "description": "Conflict or capability not configured"
          },
          "503": {
            "description": "Upstream or storage unavailable"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              },
              "examples": {
                "guide": {
                  "summary": "Use exact fields defined in docs/api.md and server Zod schema",
                  "value": {}
                }
              }
            }
          }
        }
      }
    },
    "/episodes/{id}": {
      "get": {
        "summary": "Owned episode provenance",
        "x-authentication": "verified browser session; some operations additionally require recent MFA",
        "responses": {
          "200": {
            "description": "Success"
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Not authorized"
          },
          "409": {
            "description": "Conflict or capability not configured"
          },
          "503": {
            "description": "Upstream or storage unavailable"
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      },
      "parameters": [
        {
          "name": "id",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          }
        }
      ]
    },
    "/episodes/{id}/audio/{chunk}": {
      "get": {
        "summary": "Authenticated private media with byte ranges",
        "x-authentication": "verified browser session; some operations additionally require recent MFA",
        "responses": {
          "200": {
            "description": "Success"
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Not authorized"
          },
          "409": {
            "description": "Conflict or capability not configured"
          },
          "503": {
            "description": "Upstream or storage unavailable"
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "chunk",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      },
      "parameters": [
        {
          "name": "id",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          }
        }
      ]
    },
    "/ask": {
      "post": {
        "summary": "Source-grounded abstract question with configured model",
        "x-authentication": "verified browser session; some operations additionally require recent MFA",
        "responses": {
          "200": {
            "description": "Success"
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Not authorized"
          },
          "409": {
            "description": "Conflict or capability not configured"
          },
          "503": {
            "description": "Upstream or storage unavailable"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              },
              "examples": {
                "guide": {
                  "summary": "Use exact fields defined in docs/api.md and server Zod schema",
                  "value": {}
                }
              }
            }
          }
        }
      }
    },
    "/organizations": {
      "get": {
        "summary": "Owned organizations",
        "x-authentication": "separate company account; owner-scoped access",
        "responses": {
          "200": {
            "description": "Success"
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Not authorized"
          },
          "409": {
            "description": "Conflict or capability not configured"
          },
          "503": {
            "description": "Upstream or storage unavailable"
          }
        }
      },
      "post": {
        "summary": "Submit company application",
        "x-authentication": "separate company account; owner-scoped access",
        "responses": {
          "200": {
            "description": "Success"
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Not authorized"
          },
          "409": {
            "description": "Conflict or capability not configured"
          },
          "503": {
            "description": "Upstream or storage unavailable"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              },
              "examples": {
                "guide": {
                  "summary": "Use exact fields defined in docs/api.md and server Zod schema",
                  "value": {}
                }
              }
            }
          }
        }
      }
    },
    "/assets": {
      "post": {
        "summary": "Validated private advertisement upload",
        "x-authentication": "separate company account; owner-scoped access",
        "responses": {
          "200": {
            "description": "Success"
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Not authorized"
          },
          "409": {
            "description": "Conflict or capability not configured"
          },
          "503": {
            "description": "Upstream or storage unavailable"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object"
              },
              "examples": {
                "guide": {
                  "summary": "Use exact fields defined in docs/api.md and server Zod schema",
                  "value": {}
                }
              }
            }
          }
        }
      }
    },
    "/assets/{id}": {
      "get": {
        "summary": "Read own uploaded asset",
        "x-authentication": "separate company account; owner-scoped access",
        "responses": {
          "200": {
            "description": "Success"
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Not authorized"
          },
          "409": {
            "description": "Conflict or capability not configured"
          },
          "503": {
            "description": "Upstream or storage unavailable"
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      },
      "parameters": [
        {
          "name": "id",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          }
        }
      ]
    },
    "/campaigns": {
      "get": {
        "summary": "Owned campaign statuses",
        "x-authentication": "Separate company owner scoped to its organizations, or owner/admin with recent MFA; browser mutations require matching Origin.",
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RadioCampaignList"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Authentication required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not authorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Conflict or capability not configured",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Upstream or storage unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "security": [
          {
            "CookieSession": []
          },
          {
            "NativeSession": []
          }
        ]
      },
      "post": {
        "summary": "Create draft/submitted campaign",
        "x-authentication": "Separate company owner scoped to its organizations, or owner/admin with recent MFA; browser mutations require matching Origin.",
        "responses": {
          "400": {
            "description": "Invalid input",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Authentication required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not authorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Conflict or capability not configured",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Upstream or storage unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "201": {
            "description": "Campaign created; review required before delivery.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RadioCampaignSavedResponse"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RadioCampaignInput"
              }
            }
          }
        },
        "security": [
          {
            "CookieSession": []
          },
          {
            "NativeSession": []
          }
        ]
      }
    },
    "/campaigns/{id}": {
      "patch": {
        "summary": "Apply validated partial traffic/creative changes; review is reset; pause/resume preserve unchanged approved creative",
        "x-authentication": "Separate company owner scoped to its organizations, or owner/admin with recent MFA; browser mutations require matching Origin.",
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RadioCampaignSavedResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Authentication required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not authorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Conflict or capability not configured",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Upstream or storage unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "anyOf": [
                  {
                    "$ref": "#/components/schemas/RadioCampaignPatch"
                  },
                  {
                    "$ref": "#/components/schemas/RadioCampaignAction"
                  }
                ]
              }
            }
          }
        },
        "security": [
          {
            "CookieSession": []
          },
          {
            "NativeSession": []
          }
        ]
      },
      "parameters": [
        {
          "name": "id",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string",
            "format": "uuid"
          }
        }
      ],
      "get": {
        "summary": "Get company-owned campaign or recent-MFA administrator campaign",
        "security": [
          {
            "CookieSession": []
          },
          {
            "NativeSession": []
          }
        ],
        "x-authentication": "Separate company owner scoped to its organizations, or owner/admin with recent MFA; browser mutations require matching Origin.",
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RadioCampaignDetail"
                }
              }
            }
          },
          "401": {
            "description": "Authentication required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Company permission or recent MFA required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Campaign unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/ads": {
      "get": {
        "summary": "Eligible approved contextual metadata; serving not enabled",
        "x-authentication": "public",
        "responses": {
          "200": {
            "description": "Success"
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Not authorized"
          },
          "409": {
            "description": "Conflict or capability not configured"
          },
          "503": {
            "description": "Upstream or storage unavailable"
          }
        }
      }
    },
    "/admin": {
      "get": {
        "summary": "MFA-gated operational dashboard",
        "x-authentication": "verified browser session; some operations additionally require recent MFA",
        "responses": {
          "200": {
            "description": "Success"
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Not authorized"
          },
          "409": {
            "description": "Conflict or capability not configured"
          },
          "503": {
            "description": "Upstream or storage unavailable"
          }
        }
      }
    },
    "/admin/invites": {
      "post": {
        "summary": "Owner-only co-admin invitation",
        "x-authentication": "verified browser session; some operations additionally require recent MFA",
        "responses": {
          "200": {
            "description": "Success"
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Not authorized"
          },
          "409": {
            "description": "Conflict or capability not configured"
          },
          "503": {
            "description": "Upstream or storage unavailable"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              },
              "examples": {
                "guide": {
                  "summary": "Use exact fields defined in docs/api.md and server Zod schema",
                  "value": {}
                }
              }
            }
          }
        }
      }
    },
    "/admin/users": {
      "patch": {
        "summary": "Suspend or reactivate non-owner account",
        "x-authentication": "verified browser session; some operations additionally require recent MFA",
        "responses": {
          "200": {
            "description": "Success"
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Not authorized"
          },
          "409": {
            "description": "Conflict or capability not configured"
          },
          "503": {
            "description": "Upstream or storage unavailable"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              },
              "examples": {
                "guide": {
                  "summary": "Use exact fields defined in docs/api.md and server Zod schema",
                  "value": {}
                }
              }
            }
          }
        }
      }
    },
    "/admin/organizations": {
      "patch": {
        "summary": "Review/suspend company",
        "x-authentication": "verified browser session; some operations additionally require recent MFA",
        "responses": {
          "200": {
            "description": "Success"
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Not authorized"
          },
          "409": {
            "description": "Conflict or capability not configured"
          },
          "503": {
            "description": "Upstream or storage unavailable"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              },
              "examples": {
                "guide": {
                  "summary": "Use exact fields defined in docs/api.md and server Zod schema",
                  "value": {}
                }
              }
            }
          }
        }
      }
    },
    "/admin/campaigns": {
      "patch": {
        "summary": "Review/pause campaign; rights gate enforced",
        "x-authentication": "Owner/admin with recent MFA; browser mutations require matching Origin.",
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OkResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Authentication required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not authorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Conflict or capability not configured",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Upstream or storage unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RadioCampaignReview"
              }
            }
          }
        },
        "security": [
          {
            "CookieSession": []
          },
          {
            "NativeSession": []
          }
        ]
      }
    },
    "/export": {
      "get": {
        "summary": "Personal data export excluding provider credentials",
        "x-authentication": "verified browser session; some operations additionally require recent MFA",
        "responses": {
          "200": {
            "description": "Success"
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Not authorized"
          },
          "409": {
            "description": "Conflict or capability not configured"
          },
          "503": {
            "description": "Upstream or storage unavailable"
          }
        }
      }
    },
    "/account": {
      "delete": {
        "summary": "MFA-gated account and owned-data deletion",
        "x-authentication": "verified browser session; some operations additionally require recent MFA",
        "responses": {
          "200": {
            "description": "Success"
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Not authorized"
          },
          "409": {
            "description": "Conflict or capability not configured"
          },
          "503": {
            "description": "Upstream or storage unavailable"
          }
        }
      }
    },
    "/queries/{id}/duplicate": {
      "post": {
        "summary": "Duplicate owned query with manual refresh and independent history",
        "x-authentication": "verified browser session; some operations additionally require recent MFA",
        "responses": {
          "200": {
            "description": "Success"
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Not authorized"
          },
          "409": {
            "description": "Conflict or capability not configured"
          },
          "503": {
            "description": "Upstream or storage unavailable"
          },
          "429": {
            "description": "Attempt or account quota exceeded"
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ]
      },
      "parameters": [
        {
          "name": "id",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          }
        }
      ]
    },
    "/queries/{id}/discoveries": {
      "get": {
        "summary": "Paged owner-only discoveries with source/query versions and review state",
        "x-authentication": "verified browser session; some operations additionally require recent MFA",
        "responses": {
          "200": {
            "description": "Success"
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Not authorized"
          },
          "409": {
            "description": "Conflict or capability not configured"
          },
          "503": {
            "description": "Upstream or storage unavailable"
          },
          "429": {
            "description": "Attempt or account quota exceeded"
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "offset",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 0,
              "default": 0
            }
          }
        ]
      },
      "patch": {
        "summary": "Update discovery review decisions",
        "x-authentication": "verified browser session; some operations additionally require recent MFA",
        "responses": {
          "200": {
            "description": "Success"
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Not authorized"
          },
          "409": {
            "description": "Conflict or capability not configured"
          },
          "503": {
            "description": "Upstream or storage unavailable"
          },
          "429": {
            "description": "Attempt or account quota exceeded"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "pmids",
                  "state"
                ],
                "properties": {
                  "pmids": {
                    "type": "array",
                    "minItems": 1,
                    "maxItems": 100,
                    "items": {
                      "type": "string",
                      "pattern": "^\\d{1,12}$"
                    }
                  },
                  "state": {
                    "type": "string",
                    "enum": [
                      "new",
                      "saved",
                      "dismissed"
                    ]
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ]
      },
      "parameters": [
        {
          "name": "id",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          }
        }
      ]
    },
    "/mfa/recovery-codes": {
      "post": {
        "summary": "Rotate one-time recovery set; recent MFA; renew verification cookie",
        "x-authentication": "verified browser session; some operations additionally require recent MFA",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RecoveryCodes"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Not authorized"
          },
          "409": {
            "description": "Conflict or capability not configured"
          },
          "503": {
            "description": "Upstream or storage unavailable"
          },
          "429": {
            "description": "Attempt or account quota exceeded"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false
              }
            }
          }
        }
      }
    },
    "/mfa/recover": {
      "post": {
        "summary": "Consume account-bound one-time code and renew verification cookie",
        "x-authentication": "verified browser session; some operations additionally require recent MFA",
        "responses": {
          "200": {
            "description": "Success"
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Not authorized"
          },
          "409": {
            "description": "Conflict or capability not configured"
          },
          "503": {
            "description": "Upstream or storage unavailable"
          },
          "429": {
            "description": "Attempt or account quota exceeded"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "code"
                ],
                "properties": {
                  "code": {
                    "type": "string",
                    "pattern": "^(?:[a-fA-F0-9]{4}-){9}[a-fA-F0-9]{4}$"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/auth/config": {
      "get": {
        "summary": "Available internal authentication methods",
        "x-authentication": "public",
        "responses": {
          "200": {
            "description": "Success"
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Authentication required or invalid credentials"
          },
          "403": {
            "description": "Access or verification denied"
          },
          "409": {
            "description": "Conflict"
          },
          "429": {
            "description": "Attempt/usage limit"
          },
          "503": {
            "description": "Configuration/provider unavailable"
          }
        }
      }
    },
    "/auth/register": {
      "post": {
        "summary": "Register a separate listener or company account",
        "x-authentication": "public",
        "responses": {
          "200": {
            "description": "Success"
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Authentication required or invalid credentials"
          },
          "403": {
            "description": "Access or verification denied"
          },
          "409": {
            "description": "Conflict"
          },
          "429": {
            "description": "Attempt/usage limit"
          },
          "503": {
            "description": "Configuration/provider unavailable"
          },
          "201": {
            "description": "Created; company registration grants no administrator role"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "username",
                  "password",
                  "name",
                  "email"
                ],
                "properties": {
                  "username": {
                    "type": "string",
                    "minLength": 3,
                    "maxLength": 32
                  },
                  "password": {
                    "type": "string",
                    "minLength": 15,
                    "maxLength": 128
                  },
                  "name": {
                    "type": "string"
                  },
                  "email": {
                    "type": "string",
                    "format": "email"
                  },
                  "accountType": {
                    "type": "string",
                    "enum": [
                      "listener",
                      "company"
                    ],
                    "default": "listener"
                  },
                  "returnTo": {
                    "type": "string"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/auth/login": {
      "post": {
        "summary": "Sign in; requires MFA completion when enabled",
        "x-authentication": "public",
        "responses": {
          "200": {
            "description": "Success"
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Authentication required or invalid credentials"
          },
          "403": {
            "description": "Access or verification denied"
          },
          "409": {
            "description": "Conflict"
          },
          "429": {
            "description": "Attempt/usage limit"
          },
          "503": {
            "description": "Configuration/provider unavailable"
          }
        }
      }
    },
    "/auth/mfa-login": {
      "post": {
        "summary": "Complete pending MFA login",
        "x-authentication": "pending challenge",
        "responses": {
          "200": {
            "description": "Success"
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Authentication required or invalid credentials"
          },
          "403": {
            "description": "Access or verification denied"
          },
          "409": {
            "description": "Conflict"
          },
          "429": {
            "description": "Attempt/usage limit"
          },
          "503": {
            "description": "Configuration/provider unavailable"
          }
        }
      }
    },
    "/auth/logout": {
      "post": {
        "summary": "Revoke this session",
        "x-authentication": "session",
        "responses": {
          "200": {
            "description": "Success"
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Authentication required or invalid credentials"
          },
          "403": {
            "description": "Access or verification denied"
          },
          "409": {
            "description": "Conflict"
          },
          "429": {
            "description": "Attempt/usage limit"
          },
          "503": {
            "description": "Configuration/provider unavailable"
          }
        }
      }
    },
    "/auth/logout-all": {
      "post": {
        "summary": "Revoke all account sessions",
        "x-authentication": "session",
        "responses": {
          "200": {
            "description": "Success"
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Authentication required or invalid credentials"
          },
          "403": {
            "description": "Access or verification denied"
          },
          "409": {
            "description": "Conflict"
          },
          "429": {
            "description": "Attempt/usage limit"
          },
          "503": {
            "description": "Configuration/provider unavailable"
          }
        }
      }
    },
    "/auth/password": {
      "post": {
        "summary": "Change or set own password and revoke older sessions",
        "x-authentication": "session",
        "responses": {
          "200": {
            "description": "Success"
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Authentication required or invalid credentials"
          },
          "403": {
            "description": "Access or verification denied"
          },
          "409": {
            "description": "Conflict"
          },
          "429": {
            "description": "Attempt/usage limit"
          },
          "503": {
            "description": "Configuration/provider unavailable"
          }
        }
      }
    },
    "/auth/forgot": {
      "post": {
        "summary": "Request recovery through verified email",
        "x-authentication": "public",
        "responses": {
          "200": {
            "description": "Success"
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Authentication required or invalid credentials"
          },
          "403": {
            "description": "Access or verification denied"
          },
          "409": {
            "description": "Conflict"
          },
          "429": {
            "description": "Attempt/usage limit"
          },
          "503": {
            "description": "Configuration/provider unavailable"
          }
        }
      }
    },
    "/auth/reset": {
      "post": {
        "summary": "Consume one-use reset token",
        "x-authentication": "token",
        "responses": {
          "200": {
            "description": "Success"
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Authentication required or invalid credentials"
          },
          "403": {
            "description": "Access or verification denied"
          },
          "409": {
            "description": "Conflict"
          },
          "429": {
            "description": "Attempt/usage limit"
          },
          "503": {
            "description": "Configuration/provider unavailable"
          }
        }
      }
    },
    "/auth/verify-email": {
      "post": {
        "summary": "Confirm one-use email verification token",
        "x-authentication": "token",
        "responses": {
          "200": {
            "description": "Success"
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Authentication required or invalid credentials"
          },
          "403": {
            "description": "Access or verification denied"
          },
          "409": {
            "description": "Conflict"
          },
          "429": {
            "description": "Attempt/usage limit"
          },
          "503": {
            "description": "Configuration/provider unavailable"
          }
        }
      }
    },
    "/auth/send-verification": {
      "post": {
        "summary": "Request own email verification link",
        "x-authentication": "session",
        "responses": {
          "200": {
            "description": "Success"
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Authentication required or invalid credentials"
          },
          "403": {
            "description": "Access or verification denied"
          },
          "409": {
            "description": "Conflict"
          },
          "429": {
            "description": "Attempt/usage limit"
          },
          "503": {
            "description": "Configuration/provider unavailable"
          }
        }
      }
    },
    "/auth/native-exchange": {
      "post": {
        "summary": "Exchange one-use code with S256 PKCE proof",
        "x-authentication": "PKCE",
        "responses": {
          "200": {
            "description": "Success"
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Authentication required or invalid credentials"
          },
          "403": {
            "description": "Access or verification denied"
          },
          "409": {
            "description": "Conflict"
          },
          "429": {
            "description": "Attempt/usage limit"
          },
          "503": {
            "description": "Configuration/provider unavailable"
          }
        }
      }
    },
    "/providers/openai/check": {
      "post": {
        "summary": "Check own key using non-generation models endpoint",
        "x-authentication": "session+MFA",
        "responses": {
          "200": {
            "description": "Success"
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Authentication required or invalid credentials"
          },
          "403": {
            "description": "Access or verification denied"
          },
          "409": {
            "description": "Conflict"
          },
          "429": {
            "description": "Attempt/usage limit"
          },
          "503": {
            "description": "Configuration/provider unavailable"
          }
        }
      }
    },
    "/auth/start/google": {
      "get": {
        "summary": "Start google web/native sign-in",
        "responses": {
          "303": {
            "description": "Redirect to configured identity provider"
          },
          "503": {
            "description": "Provider not configured"
          }
        }
      },
      "post": {
        "summary": "Link provider to authenticated, MFA-verified account",
        "responses": {
          "200": {
            "description": "Success"
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Authentication required or invalid credentials"
          },
          "403": {
            "description": "Access or verification denied"
          },
          "409": {
            "description": "Conflict"
          },
          "429": {
            "description": "Attempt/usage limit"
          },
          "503": {
            "description": "Configuration/provider unavailable"
          }
        }
      }
    },
    "/auth/callback/google": {
      "get": {
        "summary": "Verify provider code, signed ID token, state and nonce",
        "responses": {
          "303": {
            "description": "Internal session, MFA step or native code handoff"
          },
          "401": {
            "description": "Invalid identity token"
          },
          "403": {
            "description": "Expired/missing/replayed state"
          }
        }
      }
    },
    "/auth/start/apple": {
      "get": {
        "summary": "Start apple web/native sign-in",
        "responses": {
          "303": {
            "description": "Redirect to configured identity provider"
          },
          "503": {
            "description": "Provider not configured"
          }
        }
      },
      "post": {
        "summary": "Link provider to authenticated, MFA-verified account",
        "responses": {
          "200": {
            "description": "Success"
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Authentication required or invalid credentials"
          },
          "403": {
            "description": "Access or verification denied"
          },
          "409": {
            "description": "Conflict"
          },
          "429": {
            "description": "Attempt/usage limit"
          },
          "503": {
            "description": "Configuration/provider unavailable"
          }
        }
      }
    },
    "/auth/callback/apple": {
      "post": {
        "summary": "Verify provider code, signed ID token, state and nonce",
        "responses": {
          "303": {
            "description": "Internal session, MFA step or native code handoff"
          },
          "401": {
            "description": "Invalid identity token"
          },
          "403": {
            "description": "Expired/missing/replayed state"
          }
        }
      }
    },
    "/audio/stream": {
      "post": {
        "summary": "Quick OpenAI narration; ready private segments before full completion",
        "x-authentication": "internal browser or native session; browser mutations require Origin",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "pmid",
                  "provider",
                  "voice",
                  "mode"
                ],
                "properties": {
                  "pmid": {
                    "type": "string",
                    "pattern": "^\\d{1,12}$"
                  },
                  "provider": {
                    "type": "string",
                    "enum": [
                      "openai",
                      "openai-trial"
                    ]
                  },
                  "voice": {
                    "type": "string"
                  },
                  "mode": {
                    "type": "string",
                    "enum": [
                      "title",
                      "abstract"
                    ]
                  },
                  "requestId": {
                    "type": "string",
                    "format": "uuid"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "NDJSON started/chunk/complete events. Errors after headers are type:error events with status and safe providerError. Missing complete means interrupted. No automatic retries.",
            "content": {
              "application/x-ndjson": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "401": {
            "description": "Authentication required"
          }
        }
      }
    },
    "/audio/cancel": {
      "post": {
        "summary": "Stop an owner-scoped narration request, including before it starts",
        "x-authentication": "internal browser or native session",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "requestId"
                ],
                "properties": {
                  "requestId": {
                    "type": "string",
                    "format": "uuid"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Cancellation marker saved; submitted provider text may still be charged"
          },
          "401": {
            "description": "Authentication required"
          },
          "404": {
            "description": "Request belongs to another account"
          }
        }
      }
    },
    "/admin/assets/{id}": {
      "get": {
        "summary": "Review a submitted private advertisement file; unsubmitted uploads excluded",
        "x-authentication": "administrator plus recent MFA",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Private image or MP3 file"
          },
          "403": {
            "description": "Administrator/MFA required"
          },
          "404": {
            "description": "Submitted asset not found"
          }
        }
      },
      "parameters": [
        {
          "name": "id",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          }
        }
      ]
    },
    "/share/{id}": {
      "get": {
        "summary": "Safe original-source sharing; public and unlisted readable by guests; private membership required",
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SharedCollection"
                }
              }
            }
          },
          "400": {
            "description": "Invalid fields",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Sign in required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Origin, permission or MFA denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Object unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "security": [
          {},
          {
            "CookieSession": []
          },
          {
            "NativeSession": []
          }
        ]
      },
      "parameters": [
        {
          "name": "id",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string",
            "format": "uuid"
          }
        }
      ]
    },
    "/collections/{id}/sharing": {
      "get": {
        "summary": "Owner-only membership and pending invitation metadata",
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CollectionSharingManagement"
                }
              }
            }
          },
          "400": {
            "description": "Invalid fields",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Sign in required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Origin, permission or MFA denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Object unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "security": [
          {
            "CookieSession": []
          },
          {
            "NativeSession": []
          }
        ]
      },
      "parameters": [
        {
          "name": "id",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string",
            "format": "uuid"
          }
        }
      ]
    },
    "/collections/{id}/members/{userId}": {
      "patch": {
        "summary": "Owner changes member listener/editor role",
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OkResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid fields",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Sign in required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Origin, permission or MFA denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Object unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "security": [
          {
            "CookieSession": []
          },
          {
            "NativeSession": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CollectionMemberRolePatch"
              }
            }
          }
        }
      },
      "delete": {
        "summary": "Owner revokes member and pending invitations",
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OkResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid fields",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Sign in required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Origin, permission or MFA denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Object unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "security": [
          {
            "CookieSession": []
          },
          {
            "NativeSession": []
          }
        ]
      },
      "parameters": [
        {
          "name": "id",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string",
            "format": "uuid"
          }
        },
        {
          "name": "userId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          }
        }
      ]
    },
    "/collections/{id}/invitations/{hashedInviteId}": {
      "delete": {
        "summary": "Owner revokes a pending invitation",
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OkResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid fields",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Sign in required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Origin, permission or MFA denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Object unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "security": [
          {
            "CookieSession": []
          },
          {
            "NativeSession": []
          }
        ]
      },
      "parameters": [
        {
          "name": "id",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string",
            "format": "uuid"
          }
        },
        {
          "name": "hashedInviteId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string",
            "pattern": "^[a-f0-9]{64}$"
          }
        }
      ]
    },
    "/radio/status": {
      "get": {
        "summary": "Current sponsor-playout controls and reviewed-policy status",
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RadioStatus"
                }
              }
            }
          },
          "400": {
            "description": "Invalid fields",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Sign in required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Origin, permission or MFA denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Object unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "security": []
      }
    },
    "/radio/console": {
      "get": {
        "summary": "Company-scoped or recent-MFA administrator traffic console",
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RadioConsole"
                }
              }
            }
          },
          "400": {
            "description": "Invalid fields",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Sign in required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Origin, permission or MFA denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Object unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "security": [
          {
            "CookieSession": []
          },
          {
            "NativeSession": []
          }
        ],
        "parameters": [
          {
            "name": "from",
            "in": "query",
            "description": "Inclusive ISO datetime. Defaults to 30 days before to. Maximum range is 93 days.",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "to",
            "in": "query",
            "description": "Exclusive ISO datetime; defaults to current time. Must follow from.",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          }
        ]
      }
    },
    "/radio/controls": {
      "patch": {
        "summary": "Recent-MFA administrator changes sponsor-playout controls",
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RadioControlsSavedResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid fields",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Sign in required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Origin, permission or MFA denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Object unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Policy gate prevents enabling advertisements; controls remain unchanged.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "security": [
          {
            "CookieSession": []
          },
          {
            "NativeSession": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RadioControlsPatch"
              }
            }
          }
        }
      }
    },
    "/radio/decision": {
      "post": {
        "summary": "Atomic listener-specific between-paper creative decision; explicit sponsor consent",
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RadioDecision"
                }
              }
            }
          },
          "400": {
            "description": "Invalid fields",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Sign in required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Origin, permission or MFA denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Object unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "security": [
          {
            "CookieSession": []
          },
          {
            "NativeSession": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RadioDecisionInput"
              }
            }
          }
        },
        "description": "Requires authenticated listener and explicit sponsor consent. Disabled, ineligible, capped or unmatched breaks return 200 with ad:null and reasons. Company accounts receive no ad. Each delivery reserves per-listener capacity and expires after five minutes. The server counts deduplicated /radio/paper-complete observations and applies the current verified account entitlement. Free default is 10 completed papers, paid default is 5; administrator policy or a per-plan override can change this, including zero for no ads. everyNPapers can only increase spacing. driving:true restricts eligible and duplicate decisions to audio creatives. Paid entitlement is derived from verified Stripe state rather than client-supplied tier flags."
      }
    },
    "/radio/creative/{decisionId}": {
      "get": {
        "summary": "Private expiring delivery creative for its authenticated listener; supports ranges",
        "responses": {
          "200": {
            "description": "Full private creative",
            "content": {
              "image/png": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "image/jpeg": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "image/webp": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "audio/mpeg": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            },
            "headers": {
              "Cache-Control": {
                "schema": {
                  "type": "string"
                },
                "description": "private, no-store"
              },
              "Accept-Ranges": {
                "schema": {
                  "type": "string"
                },
                "description": "bytes"
              },
              "Content-Range": {
                "schema": {
                  "type": "string"
                },
                "description": "Present for partial content."
              }
            }
          },
          "400": {
            "description": "Invalid fields",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Sign in required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Origin, permission or MFA denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Object unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "206": {
            "description": "Partial private creative for an actual Range request",
            "content": {
              "image/png": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "image/jpeg": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "image/webp": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "audio/mpeg": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            },
            "headers": {
              "Cache-Control": {
                "schema": {
                  "type": "string"
                },
                "description": "private, no-store"
              },
              "Accept-Ranges": {
                "schema": {
                  "type": "string"
                },
                "description": "bytes"
              },
              "Content-Range": {
                "schema": {
                  "type": "string"
                },
                "description": "Present for partial content."
              }
            }
          }
        },
        "security": [
          {
            "CookieSession": []
          },
          {
            "NativeSession": []
          }
        ],
        "parameters": [
          {
            "name": "Range",
            "in": "header",
            "description": "Optional HTTP byte range, including suffix ranges.",
            "schema": {
              "type": "string",
              "example": "bytes=0-1023"
            }
          }
        ]
      },
      "parameters": [
        {
          "name": "decisionId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string",
            "format": "uuid"
          }
        }
      ]
    },
    "/radio/events": {
      "post": {
        "summary": "Deduplicated observed impression/start/complete/click for a delivered creative",
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RadioEventReceipt"
                }
              }
            }
          },
          "400": {
            "description": "Invalid fields",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Sign in required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Origin, permission or MFA denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Object unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Creative not fetched, event out of order, completion too early, event window expired, or campaign has no click URL.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "security": [
          {
            "CookieSession": []
          },
          {
            "NativeSession": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RadioEventInput"
              }
            }
          }
        },
        "description": "The listener must first fetch this delivery creative. Sequence is impression then start then complete; click requires impression. Completion requires at least 80% of declared duration, and new events must arrive within one hour of reservation. Duplicate receipts are idempotent."
      }
    },
    "/radio/reports": {
      "get": {
        "summary": "Company-scoped or recent-MFA administrator aggregate observations; optional CSV",
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RadioReport"
                }
              },
              "text/csv": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "headers": {
              "Content-Disposition": {
                "description": "attachment; filename=\"papers-fm-advertising-observations.csv\" for CSV export",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "Invalid fields",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Sign in required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Origin, permission or MFA denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Object unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "security": [
          {
            "CookieSession": []
          },
          {
            "NativeSession": []
          }
        ],
        "parameters": [
          {
            "name": "from",
            "in": "query",
            "description": "Inclusive ISO datetime. Defaults to 30 days before to. Maximum range is 93 days.",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "to",
            "in": "query",
            "description": "Exclusive ISO datetime; defaults to current time. Must follow from.",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "format",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "json",
                "csv"
              ],
              "default": "json"
            },
            "description": "csv exports aggregate per-campaign observations with formula-safe cells."
          }
        ]
      }
    },
    "/papers/{pmid}/fulltext": {
      "parameters": [
        {
          "name": "pmid",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string",
            "pattern": "^\\d{1,12}$"
          }
        }
      ],
      "get": {
        "summary": "Retrieve license-checked original PMC structured article text",
        "description": "Public read-only request; never invokes a paid speech or AI provider. Uses the current official PMC OAI-PMH GetRecord endpoint with metadataPrefix=pmc, verifies PMID/PMCID and pmc-open membership, and applies a canonical reuse-license gate. Older saved records missing a PMCID are refreshed through PubMed. Requests are serialized across replicas with at least 360 ms between completed upstream requests; an active competing request can return 503. Limits: 18-second request timeout, 2 MiB XML response, 500,000 text characters, 1,000 sections and 1 MiB serialized cache. Allowed results are cached for six hours and restricted/unavailable results for fifteen minutes. Oversize or incomplete responses fail explicitly; clients should retain the source link. Narration uses available browser/device voices only unless a separately approved cloud workflow is added.",
        "security": [],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PmcFullTextResult"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input or invalid webhook signature",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "405": {
            "description": "Method not allowed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Response or request exceeds safe size limits; no partial complete result is claimed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate or account limit reached; retry later",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "499": {
            "description": "Request cancelled before completion",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "Upstream returned invalid or unverifiable data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Service unavailable or request already processing; retry later",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/radio/paper-complete": {
      "post": {
        "summary": "Record an idempotent completed title, abstract or permitted full paper",
        "description": "Requires a personal listening account; company accounts are rejected. The paper must exist. Completion is deduplicated per account, session UUID, PMID and mode. New observations are rate limited. Counts enforce sponsor spacing but remain client-reported operational observations, not independently verified audience or billing measurements.",
        "security": [
          {
            "CookieSession": []
          },
          {
            "NativeSession": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RadioPaperCompletionReceipt"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input or invalid webhook signature",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Papers.fm authentication required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Origin, account permissions or recent MFA denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Object or endpoint unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate or account limit reached; retry later",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Service unavailable or request already processing; retry later",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RadioPaperCompletionInput"
              }
            }
          }
        }
      }
    },
    "/billing/plans": {
      "get": {
        "summary": "Public active plan and category catalogue",
        "description": "Returns active public plan metadata without Stripe secret keys or price IDs. A usable default free plan is returned when no active free plan is configured. Free and paid sponsor cadence are operator-configurable; zero means no advertising breaks.",
        "security": [],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BillingCatalogue"
                }
              }
            }
          },
          "503": {
            "description": "Service unavailable or request already processing; retry later",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/billing/me": {
      "get": {
        "summary": "Current verified listening entitlement and portal readiness",
        "description": "Authenticated account only. Paid entitlement is reconciled from current Stripe state in the configured mode and verified invoice payment. Pending checkout, redirects or client tier flags cannot grant paid status.",
        "security": [
          {
            "CookieSession": []
          },
          {
            "NativeSession": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BillingAccount"
                }
              }
            }
          },
          "401": {
            "description": "Papers.fm authentication required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Service unavailable or request already processing; retry later",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/billing/checkout": {
      "post": {
        "summary": "Create or reuse a Stripe-hosted recurring checkout",
        "description": "Requires authenticated account and normal Origin/native-session checks. Only active paid plans in active categories are purchasable. Stripe price amount, currency, recurring interval and test/live mode must match. A pending checkout is idempotently reused for the same plan; conflicting pending or existing subscriptions require portal management. No card details enter Papers.fm. Returning from checkout does not upgrade entitlement.",
        "security": [
          {
            "CookieSession": []
          },
          {
            "NativeSession": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BillingHostedUrl"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input or invalid webhook signature",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Papers.fm authentication required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Origin, account permissions or recent MFA denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Object or endpoint unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Configuration, protected history, payment mode or in-flight request conflict",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "Upstream returned invalid or unverifiable data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Service unavailable or request already processing; retry later",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BillingCheckoutInput"
              }
            }
          }
        }
      }
    },
    "/billing/portal": {
      "post": {
        "summary": "Create a Stripe-hosted billing portal session",
        "description": "Requires the current authenticated account and an existing linked Stripe customer in the configured payment mode. Submit the strict empty JSON object. Cancellation and payment management take place on Stripe; no client-supplied customer ID is accepted.",
        "security": [
          {
            "CookieSession": []
          },
          {
            "NativeSession": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BillingHostedUrl"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input or invalid webhook signature",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Papers.fm authentication required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Origin, account permissions or recent MFA denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Object or endpoint unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Configuration, protected history, payment mode or in-flight request conflict",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "Upstream returned invalid or unverifiable data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Service unavailable or request already processing; retry later",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BillingPortalInput"
              }
            }
          }
        }
      }
    },
    "/billing/admin": {
      "get": {
        "summary": "Recent-MFA administrator billing catalogue and credential status",
        "description": "Administrator or primary owner with recent MFA. Includes inactive plans/categories, privileged Stripe price IDs, credential status/suffixes and up to 30 recent webhook observations. Raw Stripe/webhook secrets and customer card details are never returned.",
        "security": [
          {
            "CookieSession": []
          },
          {
            "NativeSession": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BillingAdministration"
                }
              }
            }
          },
          "401": {
            "description": "Papers.fm authentication required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Origin, account permissions or recent MFA denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Service unavailable or request already processing; retry later",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/billing/admin/config": {
      "patch": {
        "summary": "Change billing configuration or account-tier sponsor cadence",
        "description": "All changes require administrator access and recent MFA. Credentials, enabling/disabling checkout, or changing test/live mode additionally require the primary owner. Cadence-only changes may be made by a recent-MFA administrator. Default free interval=10 and paid interval=5 completed papers; either may be set to 0 for no breaks.",
        "security": [
          {
            "CookieSession": []
          },
          {
            "NativeSession": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BillingConfigurationSaved"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input or invalid webhook signature",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Papers.fm authentication required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Origin, account permissions or recent MFA denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Configuration, protected history, payment mode or in-flight request conflict",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Response or request exceeds safe size limits; no partial complete result is claimed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Service unavailable or request already processing; retry later",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BillingConfigurationPatch"
              }
            }
          }
        }
      }
    },
    "/billing/admin/categories": {
      "post": {
        "summary": "Create a billing category; administrator and recent MFA",
        "description": "Administrator or primary owner with recent MFA. Active categories appear in the public catalogue; referenced plans must use an existing category.",
        "security": [
          {
            "CookieSession": []
          },
          {
            "NativeSession": []
          }
        ],
        "responses": {
          "201": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BillingSavedId"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input or invalid webhook signature",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Papers.fm authentication required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Origin, account permissions or recent MFA denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Object or endpoint unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Configuration, protected history, payment mode or in-flight request conflict",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Response or request exceeds safe size limits; no partial complete result is claimed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Service unavailable or request already processing; retry later",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BillingCategoryInput"
              }
            }
          }
        }
      }
    },
    "/billing/admin/categories/{id}": {
      "parameters": [
        {
          "name": "id",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100,
            "pattern": "^[A-Za-z0-9_-]+$"
          }
        }
      ],
      "patch": {
        "summary": "Update a billing category; administrator and recent MFA",
        "description": "Administrator or primary owner with recent MFA. Partial patch fields are merged with current values before validation. Deactivated categories no longer expose their plans for new checkout.",
        "security": [
          {
            "CookieSession": []
          },
          {
            "NativeSession": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BillingSavedId"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input or invalid webhook signature",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Papers.fm authentication required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Origin, account permissions or recent MFA denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Object or endpoint unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Configuration, protected history, payment mode or in-flight request conflict",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Response or request exceeds safe size limits; no partial complete result is claimed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Service unavailable or request already processing; retry later",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BillingCategoryPatch"
              }
            }
          }
        }
      }
    },
    "/billing/admin/plans": {
      "post": {
        "summary": "Create a billing plan; administrator and recent MFA",
        "description": "Administrator or primary owner with recent MFA. Free plans require amount=0, interval=free and an empty Stripe price; paid plans require a positive recurring amount, interval=month/year, and an active paid plan requires a Stripe price. Only one free plan can be active. Stripe price IDs cannot be shared across plans. Once checkout/subscription history exists, monetary terms and price IDs are protected; create a new plan for price changes. Server checkout also verifies the actual Stripe price amount, currency, mode and recurring interval.",
        "security": [
          {
            "CookieSession": []
          },
          {
            "NativeSession": []
          }
        ],
        "responses": {
          "201": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BillingSavedId"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input or invalid webhook signature",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Papers.fm authentication required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Origin, account permissions or recent MFA denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Object or endpoint unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Configuration, protected history, payment mode or in-flight request conflict",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Response or request exceeds safe size limits; no partial complete result is claimed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Service unavailable or request already processing; retry later",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BillingPlanInput"
              }
            }
          }
        }
      }
    },
    "/billing/admin/plans/{id}": {
      "parameters": [
        {
          "name": "id",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100,
            "pattern": "^[A-Za-z0-9_-]+$"
          }
        }
      ],
      "patch": {
        "summary": "Update a billing plan; administrator and recent MFA",
        "description": "Administrator or primary owner with recent MFA. Partial patch fields are merged with current values before validation. Free plans require amount=0, interval=free and an empty Stripe price; paid plans require a positive recurring amount, interval=month/year, and an active paid plan requires a Stripe price. Only one free plan can be active. Stripe price IDs cannot be shared across plans. Once checkout/subscription history exists, monetary terms and price IDs are protected; create a new plan for price changes. Server checkout also verifies the actual Stripe price amount, currency, mode and recurring interval.",
        "security": [
          {
            "CookieSession": []
          },
          {
            "NativeSession": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BillingSavedId"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input or invalid webhook signature",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Papers.fm authentication required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Origin, account permissions or recent MFA denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Object or endpoint unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Configuration, protected history, payment mode or in-flight request conflict",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Response or request exceeds safe size limits; no partial complete result is claimed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Service unavailable or request already processing; retry later",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BillingPlanPatch"
              }
            }
          }
        }
      }
    },
    "/billing/webhook": {
      "post": {
        "summary": "Verify signed raw Stripe event and reconcile subscription state",
        "description": "Server-to-server endpoint authenticated only by the Stripe-Signature HMAC over the exact raw request body. It uses neither browser cookies nor bearer-session authentication and is exempt from the browser Origin check. Requires one valid timestamp within five minutes and at least one valid v1 signature. Event mode must match configured test/live mode. Event IDs are idempotent; processing is leased and current Stripe API state supersedes payload ordering. A 503 means Stripe should retry. Only verified reconciliation can grant/revoke paid entitlement; unsupported events are acknowledged and ignored.",
        "security": [],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StripeWebhookReceipt"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input or invalid webhook signature",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Configuration, protected history, payment mode or in-flight request conflict",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Response or request exceeds safe size limits; no partial complete result is claimed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "Upstream returned invalid or unverifiable data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Service unavailable or request already processing; retry later",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/StripeWebhookEvent"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "Stripe-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "maxLength": 4096
            },
            "description": "Stripe t=<Unix seconds>,v1=<HMAC-SHA256> signature for the unchanged raw payload. A session token is not a substitute."
          }
        ]
      }
    },
    "/diagnostics/client": {
      "post": {
        "summary": "Record a bounded authenticated client error signal",
        "description": "Authenticated strict metadata only; no arbitrary error text, stack, paper content, URLs or client incident identifiers. At most 4 KiB, 10 occurrences per account per five minutes. Browser mutations require the configured origin.",
        "security": [
          {
            "CookieSession": []
          },
          {
            "NativeSession": []
          }
        ],
        "responses": {
          "400": {
            "description": "Invalid metadata or filters",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Authentication required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Permissions, recent MFA or origin denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Reporting budget exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Service unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "201": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DiagnosticReceipt"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ClientDiagnosticInput"
              }
            }
          }
        }
      }
    },
    "/diagnostics": {
      "get": {
        "summary": "List protected error incidents",
        "description": "Website owner or administrator with recent authenticator verification. Private no-store response.",
        "security": [
          {
            "CookieSession": []
          },
          {
            "NativeSession": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DiagnosticsList"
                }
              }
            }
          },
          "400": {
            "description": "Invalid metadata or filters",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Authentication required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Permissions, recent MFA or origin denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Reporting budget exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Service unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "open",
                "resolved",
                "all"
              ],
              "default": "open"
            }
          },
          {
            "name": "severity",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "error",
                "warning",
                "all"
              ],
              "default": "all"
            }
          },
          {
            "name": "code",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "SELECTION_EMPTY",
                "SELECTION_INVALID",
                "QUEUE_FAILED",
                "SPEECH_UNAVAILABLE",
                "SPEECH_FAILED",
                "SPEECH_TIMEOUT",
                "AUDIO_BLOCKED",
                "AUDIO_FAILED",
                "NETWORK_OFFLINE",
                "NETWORK_FAILED",
                "REQUEST_FAILED",
                "AUTH_REQUIRED",
                "MFA_REQUIRED",
                "ACCESS_DENIED",
                "RATE_LIMITED",
                "PROVIDER_FAILED",
                "ALLOWANCE_EXCEEDED",
                "RESPONSE_INVALID",
                "UNEXPECTED_ERROR",
                "RENDER_FAILED"
              ]
            }
          },
          {
            "name": "id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 250
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 50,
              "default": 25
            }
          }
        ]
      }
    },
    "/diagnostics/{id}": {
      "get": {
        "summary": "Inspect a protected incident",
        "description": "Website owner or administrator with recent authenticator verification. Private no-store response.",
        "security": [
          {
            "CookieSession": []
          },
          {
            "NativeSession": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DiagnosticDetailResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid metadata or filters",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Authentication required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Permissions, recent MFA or origin denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Reporting budget exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Service unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Incident not retained",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ]
      },
      "patch": {
        "summary": "Resolve or reopen an incident with an audit record",
        "description": "Website owner or administrator with recent authenticator verification. Private no-store response.",
        "security": [
          {
            "CookieSession": []
          },
          {
            "NativeSession": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DiagnosticStatusResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid metadata or filters",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Authentication required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Permissions, recent MFA or origin denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Reporting budget exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Service unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Incident not retained",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DiagnosticStatusInput"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ]
      }
    },
    "/design": {
      "get": {
        "summary": "Published safe site appearance",
        "description": "Public validated appearance only; returns application defaults before first publication. Does not expose administrator identities, previous settings, CSS or executable content.",
        "security": [],
        "x-authentication": "public",
        "responses": {
          "200": {
            "description": "Current appearance",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SiteDesignPublic"
                }
              }
            },
            "headers": {
              "Cache-Control": {
                "schema": {
                  "type": "string",
                  "const": "public, max-age=60, stale-while-revalidate=60"
                }
              }
            }
          },
          "500": {
            "description": "Unexpected service error; use the safe incident reference",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Service or required operator configuration is unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/design/manage": {
      "get": {
        "summary": "Read current design and restore availability",
        "security": [
          {
            "CookieSession": []
          },
          {
            "NativeSession": []
          }
        ],
        "x-authentication": "Administrator or primary owner and recent MFA. Browser mutations require matching Origin; native requests use the existing cookie-free bearer contract.",
        "responses": {
          "200": {
            "description": "Current design and safe management metadata",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SiteDesignManagement"
                }
              }
            },
            "headers": {
              "Cache-Control": {
                "schema": {
                  "type": "string",
                  "const": "private, no-store"
                }
              }
            }
          },
          "401": {
            "description": "Authentication required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Origin, account permissions or recent authenticator verification denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "Unexpected service error; use the safe incident reference",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Service or required operator configuration is unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "patch": {
        "summary": "Publish a reviewed design or restore the previous publication",
        "description": "Strict JSON <=4096 UTF-8 bytes. Complete settings use fixed enums and contrast/light-surface validation. expectedRevision prevents overwriting a concurrent administrator edit. Successful publication and audit run in one database batch; restore toggles the current/previous publications. This does not remove application features or modify user preferences.",
        "security": [
          {
            "CookieSession": []
          },
          {
            "NativeSession": []
          }
        ],
        "x-authentication": "Administrator or primary owner and recent MFA. Browser mutations require matching Origin; native requests use the existing cookie-free bearer contract.",
        "x-max-request-bytes": 4096,
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SiteDesignChange"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Published design and restore availability",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SiteDesignManagement"
                }
              }
            },
            "headers": {
              "Cache-Control": {
                "schema": {
                  "type": "string",
                  "const": "private, no-store"
                }
              }
            }
          },
          "400": {
            "description": "Invalid strict fields, bounds or values",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Authentication required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Origin, account permissions or recent authenticator verification denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Revision conflict, missing prior design or Gmail connection requires reconnection",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Request or provider response exceeds the documented byte limit",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "Unexpected service error; use the safe incident reference",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Service or required operator configuration is unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/connections": {
      "get": {
        "summary": "Read own account-connection readiness",
        "description": "Readiness and connection metadata for this authenticated internal account only. Recent MFA is required for Gmail actions, while this status route requires a valid session. Configured readiness does not prove Google restricted-scope approval. An email address alone never grants API access or merges accounts.",
        "security": [
          {
            "CookieSession": []
          },
          {
            "NativeSession": []
          }
        ],
        "responses": {
          "200": {
            "description": "Own connection status",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AccountConnectionsStatus"
                }
              }
            },
            "headers": {
              "Cache-Control": {
                "schema": {
                  "type": "string",
                  "const": "no-store"
                }
              },
              "Referrer-Policy": {
                "schema": {
                  "type": "string",
                  "const": "no-referrer"
                }
              }
            }
          },
          "401": {
            "description": "Authentication required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Origin, account permissions or recent authenticator verification denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "Unexpected service error; use the safe incident reference",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Service or required operator configuration is unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/connections/gmail/start": {
      "post": {
        "summary": "Explicitly start read-only Gmail authorization",
        "description": "Browser-only same-origin session plus recent MFA and consent:true. Operator must configure Gmail OAuth client/secrets and explicitly enable the reviewed audience. Requests openid, email and gmail.readonly using state, callback binding cookie and S256 PKCE. Six attempts per account per five minutes; independent IP budget applies. Gmail read-only scope can read the mailbox, not only the ten displayed messages. Authorization never substitutes Gmail/ChatGPT credentials for an OpenAI API key.",
        "security": [
          {
            "CookieSession": []
          }
        ],
        "x-authentication": "Browser session and recent MFA; exact public AUTH_ORIGIN",
        "x-max-request-bytes": 4096,
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/GmailConnectionStart"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Google authorization URL and ten-minute HttpOnly Secure SameSite=Lax callback cookie",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GmailAuthorization"
                }
              }
            },
            "headers": {
              "Cache-Control": {
                "schema": {
                  "type": "string",
                  "const": "no-store"
                }
              },
              "Referrer-Policy": {
                "schema": {
                  "type": "string",
                  "const": "no-referrer"
                }
              }
            }
          },
          "400": {
            "description": "Invalid strict fields, bounds or values",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Authentication required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Origin, account permissions or recent authenticator verification denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Request or provider response exceeds the documented byte limit",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Account/IP request budget or provider rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "Unexpected service error; use the safe incident reference",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Service or required operator configuration is unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/connections/gmail/callback": {
      "get": {
        "summary": "Complete the one-use Gmail authorization transaction",
        "description": "Browser redirect callback only. Requires configured public origin, the original session and matching ten-minute callback cookie/state. The transaction is claimed once and installation rechecks session/authentication/MFA versions and disconnection state. Provider consent denial returns cancelled; token/identity/scope failures return failed. Tokens and upstream errors are never returned to the browser. Query string is bounded to 16384 characters.",
        "security": [
          {
            "CookieSession": []
          }
        ],
        "parameters": [
          {
            "name": "state",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]{43}$",
              "minLength": 43,
              "maxLength": 43
            }
          },
          {
            "name": "code",
            "in": "query",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 4000
            },
            "description": "Authorization code on successful provider consent; omitted when Google supplies error."
          },
          {
            "name": "error",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Presence marks cancellation; provider text is not rendered or retained."
          }
        ],
        "responses": {
          "303": {
            "description": "Fixed redirect to /listen?view=settings&connection=connected|cancelled|failed#account-connections with cleared callback cookie",
            "headers": {
              "Location": {
                "required": true,
                "schema": {
                  "type": "string",
                  "format": "uri"
                },
                "description": "Configured AUTH_ORIGIN plus the fixed settings path and one of the three fixed outcomes."
              },
              "Cache-Control": {
                "schema": {
                  "type": "string",
                  "const": "no-store"
                }
              },
              "Referrer-Policy": {
                "schema": {
                  "type": "string",
                  "const": "no-referrer"
                }
              }
            }
          },
          "400": {
            "description": "Invalid strict fields, bounds or values",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Authentication required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Origin, account permissions or recent authenticator verification denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Request or provider response exceeds the documented byte limit",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "Unexpected service error; use the safe incident reference",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Service or required operator configuration is unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/connections/gmail/messages": {
      "post": {
        "summary": "Preview up to ten matching Gmail messages",
        "description": "Explicit read-only search of the connected account, excluding spam/trash. Returns id and sanitized subject/from/date headers only; no bodies. Strict request <=4096 UTF-8 bytes. Search and extraction share twenty attempts per account per five minutes, with an independent IP budget. Refresh/access grants stay server-side; queries, headers, bodies and tokens are not logged or persisted. Responses must not be publicly cached.",
        "security": [
          {
            "CookieSession": []
          },
          {
            "NativeSession": []
          }
        ],
        "x-authentication": "Own authenticated session and recent MFA. Browser mutations require matching Origin; native requests use the existing cookie-free bearer contract.",
        "x-max-request-bytes": 4096,
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/GmailMessageSearch"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Transient metadata previews for the requesting account",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GmailMessages"
                }
              }
            },
            "headers": {
              "Cache-Control": {
                "schema": {
                  "type": "string",
                  "const": "no-store"
                }
              },
              "Referrer-Policy": {
                "schema": {
                  "type": "string",
                  "const": "no-referrer"
                }
              }
            }
          },
          "400": {
            "description": "Invalid strict fields, bounds or values",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Authentication required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Origin, account permissions or recent authenticator verification denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "The selected Gmail message is unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Revision conflict, missing prior design or Gmail connection requires reconnection",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Request or provider response exceeds the documented byte limit",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Account/IP request budget or provider rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "Unexpected service error; use the safe incident reference",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "Google could not be reached or returned unreadable/unverifiable data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Service or required operator configuration is unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/connections/gmail/extract": {
      "post": {
        "summary": "Extract PubMed/DOI links from one explicitly chosen Gmail message",
        "description": "Reads one selected message transiently, extracts recognized identifiers and never fetches message links or attachments. Does not send, edit, label, archive or delete mail. Strict request <=4096 UTF-8 bytes. Search/extraction share twenty attempts per account per five minutes. A changed/revoked grant is rechecked before returning content. Identifiers are not automatically saved or played; the user reviews them first.",
        "security": [
          {
            "CookieSession": []
          },
          {
            "NativeSession": []
          }
        ],
        "x-authentication": "Own authenticated session and recent MFA. Browser mutations require matching Origin; native requests use the existing cookie-free bearer contract.",
        "x-max-request-bytes": 4096,
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/GmailMessageExtract"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Transient extracted identifiers, with no stored message content",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GmailExtraction"
                }
              }
            },
            "headers": {
              "Cache-Control": {
                "schema": {
                  "type": "string",
                  "const": "no-store"
                }
              },
              "Referrer-Policy": {
                "schema": {
                  "type": "string",
                  "const": "no-referrer"
                }
              }
            }
          },
          "400": {
            "description": "Invalid strict fields, bounds or values",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Authentication required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Origin, account permissions or recent authenticator verification denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "The selected Gmail message is unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Revision conflict, missing prior design or Gmail connection requires reconnection",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Request or provider response exceeds the documented byte limit",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Account/IP request budget or provider rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "Unexpected service error; use the safe incident reference",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "Google could not be reached or returned unreadable/unverifiable data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Service or required operator configuration is unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/connections/gmail": {
      "delete": {
        "summary": "Disconnect own Gmail grant and request Google revocation",
        "description": "Recent MFA. Deletes the local encrypted refresh token and pending OAuth transactions before the best-effort Google revocation request. Six attempts per account per five minutes, with an independent IP budget. If Google revocation fails, the response gives a fixed permissions URL for manual revocation. Uses no JSON body. Other users’ grants are inaccessible.",
        "security": [
          {
            "CookieSession": []
          },
          {
            "NativeSession": []
          }
        ],
        "x-authentication": "Own authenticated session and recent MFA. Browser mutations require matching Origin; native requests use the existing cookie-free bearer contract.",
        "responses": {
          "200": {
            "description": "Local disconnect result and provider revocation outcome",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GmailDisconnection"
                }
              }
            },
            "headers": {
              "Cache-Control": {
                "schema": {
                  "type": "string",
                  "const": "no-store"
                }
              },
              "Referrer-Policy": {
                "schema": {
                  "type": "string",
                  "const": "no-referrer"
                }
              }
            }
          },
          "401": {
            "description": "Authentication required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Origin, account permissions or recent authenticator verification denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Account/IP request budget or provider rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "Unexpected service error; use the safe incident reference",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Service or required operator configuration is unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "CookieSession": {
        "type": "apiKey",
        "in": "cookie",
        "name": "papers_session"
      },
      "NativeSession": {
        "type": "http",
        "scheme": "bearer",
        "description": "Opaque Papers.fm session token, not a hosting token"
      },
      "jobSecret": {
        "type": "http",
        "scheme": "bearer",
        "description": "Dedicated server jobs secret"
      }
    },
    "schemas": {
      "Paper": {
        "type": "object",
        "required": [
          "pmid",
          "title",
          "abstract",
          "sourceVersion",
          "retrievedAt"
        ],
        "properties": {
          "pmid": {
            "type": "string",
            "pattern": "^\\d+$"
          },
          "doi": {
            "type": [
              "string",
              "null"
            ]
          },
          "title": {
            "type": "string"
          },
          "abstract": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "label": {
                  "type": "string"
                },
                "text": {
                  "type": "string"
                }
              }
            }
          },
          "authors": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "journal": {
            "type": "string"
          },
          "date": {
            "type": "string"
          },
          "types": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "languages": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "relations": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "type": {
                  "type": "string"
                },
                "pmid": {
                  "type": "string"
                }
              }
            }
          },
          "copyright": {
            "type": [
              "string",
              "null"
            ]
          },
          "sourceVersion": {
            "type": "string"
          },
          "retrievedAt": {
            "type": "string",
            "format": "date-time"
          },
          "pmcId": {
            "type": "string",
            "pattern": "^PMC\\d{1,12}$",
            "description": "Optional verified PMC identifier from the PubMed ArticleId metadata. PMC presence alone is not reuse permission."
          },
          "pmcReading": {
            "type": "string",
            "enum": [
              "check-required",
              "available",
              "restricted",
              "unavailable"
            ],
            "description": "Optional derived availability. Full-paper reading requires a separate current license-checked fulltext response; no body is embedded in Paper or shared collections."
          }
        }
      },
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "string"
          },
          "code": {
            "type": "string",
            "enum": [
              "SELECTION_EMPTY",
              "SELECTION_INVALID",
              "QUEUE_FAILED",
              "SPEECH_UNAVAILABLE",
              "SPEECH_FAILED",
              "SPEECH_TIMEOUT",
              "AUDIO_BLOCKED",
              "AUDIO_FAILED",
              "NETWORK_OFFLINE",
              "NETWORK_FAILED",
              "REQUEST_FAILED",
              "AUTH_REQUIRED",
              "MFA_REQUIRED",
              "ACCESS_DENIED",
              "RATE_LIMITED",
              "PROVIDER_FAILED",
              "ALLOWANCE_EXCEEDED",
              "RESPONSE_INVALID",
              "UNEXPECTED_ERROR",
              "RENDER_FAILED"
            ]
          },
          "incidentId": {
            "type": "string",
            "format": "uuid"
          },
          "retryable": {
            "type": "boolean"
          },
          "providerError": {
            "type": "object",
            "properties": {
              "provider": {
                "type": "string",
                "enum": [
                  "openai"
                ]
              },
              "status": {
                "type": "integer"
              },
              "code": {
                "type": "string"
              },
              "requestId": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "retryAfterSeconds": {
                "type": [
                  "integer",
                  "null"
                ]
              }
            }
          }
        }
      },
      "SavedSearchInput": {
        "type": "object",
        "required": [
          "name",
          "query"
        ],
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 180
          },
          "query": {
            "type": "string",
            "minLength": 1,
            "maxLength": 4000
          },
          "groupName": {
            "type": "string",
            "maxLength": 80,
            "default": ""
          },
          "collectionId": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid",
            "default": null
          },
          "frequency": {
            "type": "string",
            "enum": [
              "manual",
              "daily",
              "weekly",
              "monthly"
            ],
            "default": "manual"
          },
          "timezone": {
            "type": "string",
            "default": "Europe/Berlin"
          },
          "expectedVersion": {
            "type": "integer",
            "minimum": 1,
            "description": "Required on PATCH; match version from GET /queries."
          }
        }
      },
      "RecoveryCodes": {
        "type": "object",
        "properties": {
          "recoveryCodes": {
            "type": "array",
            "minItems": 10,
            "maxItems": 10,
            "items": {
              "type": "string",
              "pattern": "^(?:[a-f0-9]{4}-){9}[a-f0-9]{4}$"
            }
          }
        }
      },
      "OkResponse": {
        "type": "object",
        "properties": {
          "ok": {
            "type": "boolean",
            "const": true
          }
        },
        "required": [
          "ok"
        ]
      },
      "RadioDaypart": {
        "type": "object",
        "properties": {
          "start": {
            "type": "string",
            "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
          },
          "end": {
            "type": "string",
            "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
          }
        },
        "description": "Local time window in the campaign IANA timezone. Start and end must differ. End is exclusive; an overnight window belongs to the weekday on which it starts.",
        "required": [
          "start",
          "end"
        ]
      },
      "RadioControls": {
        "type": "object",
        "properties": {
          "onAir": {
            "type": "boolean"
          },
          "adsEnabled": {
            "type": "boolean"
          },
          "minSeparationSeconds": {
            "type": "integer",
            "minimum": 60,
            "maximum": 86400
          }
        },
        "description": "Controls sponsor placements; an off-air hold does not remotely stop an already playing paper or revoke already fetched bytes.",
        "required": [
          "onAir",
          "adsEnabled",
          "minSeparationSeconds"
        ]
      },
      "RadioControlsPatch": {
        "type": "object",
        "properties": {
          "onAir": {
            "type": "boolean"
          },
          "adsEnabled": {
            "type": "boolean"
          },
          "minSeparationSeconds": {
            "type": "integer",
            "minimum": 60,
            "maximum": 86400
          }
        },
        "minProperties": 1,
        "additionalProperties": false
      },
      "RadioStatus": {
        "type": "object",
        "properties": {
          "controls": {
            "$ref": "#/components/schemas/RadioControls"
          },
          "rightsReviewed": {
            "type": "boolean"
          }
        },
        "required": [
          "controls",
          "rightsReviewed"
        ]
      },
      "RadioControlsSavedResponse": {
        "type": "object",
        "properties": {
          "ok": {
            "type": "boolean",
            "const": true
          },
          "controls": {
            "$ref": "#/components/schemas/RadioControls"
          }
        },
        "required": [
          "ok",
          "controls"
        ]
      },
      "RadioCampaignInput": {
        "type": "object",
        "properties": {
          "organizationId": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 180
          },
          "kind": {
            "type": "string",
            "enum": [
              "image",
              "audio"
            ]
          },
          "assetId": {
            "type": "string",
            "format": "uuid"
          },
          "description": {
            "type": "string",
            "minLength": 1,
            "maxLength": 4000
          },
          "starts": {
            "type": "string",
            "format": "date-time"
          },
          "ends": {
            "type": "string",
            "format": "date-time",
            "description": "Must be later than starts."
          },
          "frequencyCap": {
            "type": "integer",
            "minimum": 1,
            "maximum": 20,
            "default": 2
          },
          "context": {
            "type": "string",
            "maxLength": 120,
            "default": ""
          },
          "state": {
            "type": "string",
            "enum": [
              "draft",
              "submitted",
              "paused"
            ],
            "default": "draft"
          },
          "timezone": {
            "type": "string",
            "maxLength": 100,
            "default": "Europe/London",
            "description": "Valid IANA timezone, used for weekdays, dayparts and daily listener caps."
          },
          "weekdays": {
            "type": "array",
            "items": {
              "type": "integer",
              "minimum": 0,
              "maximum": 6
            },
            "minItems": 1,
            "maxItems": 7,
            "default": [
              0,
              1,
              2,
              3,
              4,
              5,
              6
            ],
            "description": "0 Sunday through 6 Saturday; duplicate days are deduplicated when stored."
          },
          "dayparts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/RadioDaypart"
            },
            "maxItems": 12,
            "default": []
          },
          "targetCollectionIds": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "uuid"
            },
            "maxItems": 100,
            "default": [],
            "description": "Targets must be active public playlists or channels."
          },
          "priority": {
            "type": "integer",
            "minimum": 0,
            "maximum": 10,
            "default": 5
          },
          "weight": {
            "type": "integer",
            "minimum": 1,
            "maximum": 100,
            "default": 1
          },
          "minimumSeparationSeconds": {
            "type": "integer",
            "minimum": 60,
            "maximum": 86400,
            "default": 900
          },
          "clickUrl": {
            "anyOf": [
              {
                "const": ""
              },
              {
                "type": "string",
                "format": "uri",
                "pattern": "^https://",
                "maxLength": 1000
              }
            ],
            "default": ""
          },
          "durationSeconds": {
            "type": "number",
            "minimum": 0,
            "maximum": 180,
            "default": 0,
            "description": "Audio requires a positive previewed duration. A zero image duration is stored as a 10-second display."
          }
        },
        "description": "Creative must belong to the selected company and match kind. Administrators require recent MFA. Creation or material changes invalidate previous approval.",
        "required": [
          "organizationId",
          "name",
          "kind",
          "assetId",
          "description",
          "starts",
          "ends"
        ],
        "additionalProperties": false
      },
      "RadioCampaignPatch": {
        "type": "object",
        "properties": {
          "organizationId": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 180
          },
          "kind": {
            "type": "string",
            "enum": [
              "image",
              "audio"
            ]
          },
          "assetId": {
            "type": "string",
            "format": "uuid"
          },
          "description": {
            "type": "string",
            "minLength": 1,
            "maxLength": 4000
          },
          "starts": {
            "type": "string",
            "format": "date-time"
          },
          "ends": {
            "type": "string",
            "format": "date-time",
            "description": "Must be later than starts."
          },
          "frequencyCap": {
            "type": "integer",
            "minimum": 1,
            "maximum": 20
          },
          "context": {
            "type": "string",
            "maxLength": 120
          },
          "state": {
            "type": "string",
            "enum": [
              "draft",
              "submitted",
              "paused"
            ]
          },
          "timezone": {
            "type": "string",
            "maxLength": 100,
            "description": "Valid IANA timezone, used for weekdays, dayparts and daily listener caps."
          },
          "weekdays": {
            "type": "array",
            "items": {
              "type": "integer",
              "minimum": 0,
              "maximum": 6
            },
            "minItems": 1,
            "maxItems": 7,
            "description": "0 Sunday through 6 Saturday; duplicate days are deduplicated when stored."
          },
          "dayparts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/RadioDaypart"
            },
            "maxItems": 12
          },
          "targetCollectionIds": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "uuid"
            },
            "maxItems": 100,
            "description": "Targets must be active public playlists or channels."
          },
          "priority": {
            "type": "integer",
            "minimum": 0,
            "maximum": 10
          },
          "weight": {
            "type": "integer",
            "minimum": 1,
            "maximum": 100
          },
          "minimumSeparationSeconds": {
            "type": "integer",
            "minimum": 60,
            "maximum": 86400
          },
          "clickUrl": {
            "anyOf": [
              {
                "const": ""
              },
              {
                "type": "string",
                "format": "uri",
                "pattern": "^https://",
                "maxLength": 1000
              }
            ]
          },
          "durationSeconds": {
            "type": "number",
            "minimum": 0,
            "maximum": 180,
            "description": "Audio requires a positive previewed duration. A zero image duration is stored as a 10-second display."
          }
        },
        "description": "Validated partial traffic or creative edit. Existing values are retained for omitted fields. Company cannot be changed; material changes reset creative review. State defaults to submitted only if it was already submitted, otherwise draft.",
        "additionalProperties": false
      },
      "RadioCampaignAction": {
        "type": "object",
        "properties": {
          "action": {
            "type": "string",
            "enum": [
              "pause",
              "resume"
            ]
          },
          "state": {
            "type": "string",
            "enum": [
              "draft",
              "submitted",
              "paused",
              "completed"
            ]
          }
        },
        "anyOf": [
          {
            "required": [
              "action"
            ]
          },
          {
            "required": [
              "state"
            ]
          }
        ],
        "description": "Pause/resume preserves unchanged approved creative. Resume requires prior current approval, approved company, active dates and policy eligibility; rejection/completion cannot be bypassed. If action is present it takes precedence over state.",
        "additionalProperties": false
      },
      "RadioCampaign": {
        "type": "object",
        "properties": {
          "organizationId": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 180
          },
          "kind": {
            "type": "string",
            "enum": [
              "image",
              "audio"
            ]
          },
          "assetId": {
            "type": "string",
            "format": "uuid"
          },
          "description": {
            "type": "string",
            "minLength": 1,
            "maxLength": 4000
          },
          "starts": {
            "type": "string",
            "format": "date-time"
          },
          "ends": {
            "type": "string",
            "format": "date-time",
            "description": "Must be later than starts."
          },
          "frequencyCap": {
            "type": "integer",
            "minimum": 1,
            "maximum": 20
          },
          "context": {
            "type": "string",
            "maxLength": 120
          },
          "state": {
            "type": "string",
            "enum": [
              "draft",
              "submitted",
              "approved",
              "paused",
              "rejected",
              "completed"
            ]
          },
          "timezone": {
            "type": "string",
            "maxLength": 100,
            "description": "Valid IANA timezone, used for weekdays, dayparts and daily listener caps."
          },
          "weekdays": {
            "type": "array",
            "items": {
              "type": "integer",
              "minimum": 0,
              "maximum": 6
            },
            "minItems": 1,
            "maxItems": 7,
            "description": "0 Sunday through 6 Saturday; duplicate days are deduplicated when stored."
          },
          "dayparts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/RadioDaypart"
            },
            "maxItems": 12
          },
          "targetCollectionIds": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "uuid"
            },
            "maxItems": 100,
            "description": "Targets must be active public playlists or channels."
          },
          "priority": {
            "type": "integer",
            "minimum": 0,
            "maximum": 10
          },
          "weight": {
            "type": "integer",
            "minimum": 1,
            "maximum": 100
          },
          "minimumSeparationSeconds": {
            "type": "integer",
            "minimum": 60,
            "maximum": 86400
          },
          "clickUrl": {
            "anyOf": [
              {
                "const": ""
              },
              {
                "type": "string",
                "format": "uri",
                "pattern": "^https://",
                "maxLength": 1000
              }
            ]
          },
          "durationSeconds": {
            "type": "number",
            "minimum": 0,
            "maximum": 180,
            "description": "Audio requires a positive previewed duration. A zero image duration is stored as a 10-second display."
          },
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "organization": {
            "type": "string"
          },
          "creativeReviewed": {
            "type": "boolean"
          },
          "reviewReason": {
            "type": "string"
          },
          "eligibilityReasons": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "previewUrl": {
            "type": "string"
          },
          "mime": {
            "type": "string"
          },
          "size": {
            "type": "integer",
            "minimum": 0
          }
        },
        "description": "Normalized campaign fields. Current implementation may additionally return owner-scoped internal SQL metadata; no provider secrets are included.",
        "required": [
          "organizationId",
          "name",
          "kind",
          "assetId",
          "description",
          "starts",
          "ends",
          "frequencyCap",
          "context",
          "state",
          "timezone",
          "weekdays",
          "dayparts",
          "targetCollectionIds",
          "priority",
          "weight",
          "minimumSeparationSeconds",
          "clickUrl",
          "durationSeconds",
          "id",
          "organization",
          "creativeReviewed",
          "reviewReason",
          "eligibilityReasons",
          "previewUrl",
          "mime",
          "size"
        ]
      },
      "RadioCampaignSavedResponse": {
        "type": "object",
        "properties": {
          "ok": {
            "type": "boolean",
            "const": true
          },
          "id": {
            "type": "string",
            "format": "uuid"
          }
        },
        "required": [
          "ok",
          "id"
        ]
      },
      "RadioCampaignList": {
        "type": "object",
        "properties": {
          "campaigns": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/RadioCampaign"
            }
          }
        },
        "required": [
          "campaigns"
        ]
      },
      "RadioCampaignDetail": {
        "type": "object",
        "properties": {
          "campaign": {
            "$ref": "#/components/schemas/RadioCampaign"
          }
        },
        "required": [
          "campaign"
        ]
      },
      "RadioCampaignReview": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "state": {
            "type": "string",
            "enum": [
              "approved",
              "rejected",
              "paused",
              "completed",
              "expired"
            ]
          },
          "reason": {
            "type": "string",
            "maxLength": 500,
            "default": ""
          }
        },
        "description": "Recent-MFA administrator only. Approval requires reviewed policy, approved company, valid matching creative and submitted/paused state. expired is accepted as a legacy alias for completed.",
        "required": [
          "id",
          "state"
        ],
        "additionalProperties": false
      },
      "RadioCounts": {
        "type": "object",
        "properties": {
          "impression": {
            "type": "integer",
            "minimum": 0
          },
          "start": {
            "type": "integer",
            "minimum": 0
          },
          "complete": {
            "type": "integer",
            "minimum": 0
          },
          "click": {
            "type": "integer",
            "minimum": 0
          }
        },
        "required": [
          "impression",
          "start",
          "complete",
          "click"
        ]
      },
      "RadioCampaignCounts": {
        "allOf": [
          {
            "$ref": "#/components/schemas/RadioCounts"
          },
          {
            "type": "object",
            "properties": {
              "campaignId": {
                "type": "string",
                "format": "uuid"
              },
              "name": {
                "type": "string"
              }
            },
            "required": [
              "campaignId",
              "name"
            ]
          }
        ]
      },
      "RadioDailyCounts": {
        "allOf": [
          {
            "$ref": "#/components/schemas/RadioCounts"
          },
          {
            "type": "object",
            "properties": {
              "day": {
                "type": "string",
                "format": "date",
                "description": "UTC day of event receipt; separate from timezone-based campaign caps."
              }
            },
            "required": [
              "day"
            ]
          }
        ]
      },
      "RadioReport": {
        "type": "object",
        "properties": {
          "from": {
            "type": "string",
            "format": "date-time"
          },
          "to": {
            "type": "string",
            "format": "date-time"
          },
          "totals": {
            "$ref": "#/components/schemas/RadioCounts"
          },
          "byCampaign": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/RadioCampaignCounts"
            }
          },
          "daily": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/RadioDailyCounts"
            }
          },
          "measurement": {
            "type": "string"
          }
        },
        "description": "Company-owned or administrator-wide operational client observations, not independently audited listening, audience reach or billable impressions. No listener identities are returned.",
        "required": [
          "from",
          "to",
          "totals",
          "byCampaign",
          "daily",
          "measurement"
        ]
      },
      "RadioConsole": {
        "type": "object",
        "properties": {
          "isAdmin": {
            "type": "boolean"
          },
          "canManageCampaigns": {
            "type": "boolean"
          },
          "controls": {
            "$ref": "#/components/schemas/RadioControls"
          },
          "rightsReviewed": {
            "type": "boolean"
          },
          "campaigns": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/RadioCampaign"
            }
          },
          "organizations": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "format": "uuid"
                },
                "name": {
                  "type": "string"
                },
                "status": {
                  "type": "string"
                },
                "ownerId": {
                  "type": "string"
                }
              },
              "required": [
                "id",
                "name",
                "status",
                "ownerId"
              ]
            }
          },
          "collections": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "format": "uuid"
                },
                "name": {
                  "type": "string"
                },
                "kind": {
                  "type": "string",
                  "enum": [
                    "playlist",
                    "channel"
                  ]
                }
              },
              "required": [
                "id",
                "name",
                "kind"
              ]
            }
          },
          "assets": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "format": "uuid"
                },
                "mime": {
                  "type": "string"
                },
                "size": {
                  "type": "integer",
                  "minimum": 0
                },
                "ownerId": {
                  "type": "string"
                },
                "previewUrl": {
                  "type": "string"
                }
              },
              "required": [
                "id",
                "mime",
                "size",
                "ownerId",
                "previewUrl"
              ]
            }
          },
          "recentAudit": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "format": "uuid"
                },
                "action": {
                  "type": "string"
                },
                "target": {
                  "type": "string"
                },
                "createdAt": {
                  "type": "string",
                  "format": "date-time"
                }
              },
              "required": [
                "id",
                "action",
                "target",
                "createdAt"
              ]
            }
          },
          "report": {
            "$ref": "#/components/schemas/RadioReport"
          }
        },
        "required": [
          "isAdmin",
          "canManageCampaigns",
          "controls",
          "rightsReviewed",
          "campaigns",
          "organizations",
          "collections",
          "assets",
          "recentAudit",
          "report"
        ]
      },
      "RadioDecisionInput": {
        "type": "object",
        "properties": {
          "playbackId": {
            "type": "string",
            "format": "uuid",
            "description": "Fresh UUID for each between-paper break. Retry the same UUID for an idempotent decision."
          },
          "consentAds": {
            "type": "boolean",
            "const": true
          },
          "provider": {
            "type": "string",
            "enum": [
              "device",
              "openai",
              "openai-trial",
              "google"
            ]
          },
          "placement": {
            "type": "string",
            "const": "between-papers"
          },
          "collectionId": {
            "type": "string",
            "format": "uuid"
          },
          "context": {
            "type": "string",
            "maxLength": 120,
            "default": ""
          },
          "everyNPapers": {
            "type": "integer",
            "minimum": 1,
            "maximum": 100,
            "description": "Optional user-requested spacing. The server uses max(account entitlement cadence, requested spacing); a client cannot increase ad frequency beyond its plan policy. A zero entitlement disables breaks."
          },
          "driving": {
            "type": "boolean",
            "default": false,
            "description": "When true only audio creatives are eligible; image advertisements are excluded, including replay of an earlier incompatible decision."
          }
        },
        "required": [
          "playbackId",
          "consentAds",
          "provider",
          "placement"
        ],
        "additionalProperties": false
      },
      "RadioPlacement": {
        "type": "object",
        "properties": {
          "decisionId": {
            "type": "string",
            "format": "uuid"
          },
          "campaignId": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          },
          "sponsor": {
            "type": "string"
          },
          "kind": {
            "type": "string",
            "enum": [
              "image",
              "audio"
            ]
          },
          "description": {
            "type": "string"
          },
          "assetUrl": {
            "type": "string",
            "description": "Relative API URL; only the listener who owns this expiring delivery may fetch it."
          },
          "mime": {
            "type": "string"
          },
          "durationSeconds": {
            "type": "number",
            "minimum": 0,
            "maximum": 180
          },
          "clickUrl": {
            "type": "string"
          },
          "expiresAt": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "decisionId",
          "campaignId",
          "name",
          "sponsor",
          "kind",
          "description",
          "assetUrl",
          "mime",
          "durationSeconds",
          "clickUrl",
          "expiresAt"
        ]
      },
      "RadioDecision": {
        "type": "object",
        "properties": {
          "ad": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/RadioPlacement"
              },
              {
                "type": "null"
              }
            ]
          },
          "reasons": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        },
        "required": [
          "ad",
          "reasons"
        ]
      },
      "RadioEventInput": {
        "type": "object",
        "properties": {
          "decisionId": {
            "type": "string",
            "format": "uuid"
          },
          "eventType": {
            "type": "string",
            "enum": [
              "impression",
              "start",
              "complete",
              "click"
            ]
          },
          "key": {
            "type": "string",
            "format": "uuid",
            "description": "Unique client-event UUID. Event keys and each delivery/event-type pair are deduplicated."
          }
        },
        "required": [
          "decisionId",
          "eventType",
          "key"
        ],
        "additionalProperties": false
      },
      "RadioEventReceipt": {
        "type": "object",
        "properties": {
          "ok": {
            "type": "boolean",
            "const": true
          },
          "duplicate": {
            "type": "boolean"
          }
        },
        "required": [
          "ok",
          "duplicate"
        ]
      },
      "SharedCollection": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          },
          "kind": {
            "type": "string",
            "enum": [
              "playlist",
              "channel"
            ]
          },
          "description": {
            "type": "string"
          },
          "visibility": {
            "type": "string",
            "enum": [
              "private",
              "invite-only",
              "unlisted",
              "public"
            ]
          },
          "sharePath": {
            "type": "string"
          },
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Paper"
            }
          },
          "playlists": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "format": "uuid"
                },
                "name": {
                  "type": "string"
                },
                "description": {
                  "type": "string"
                },
                "sharePath": {
                  "type": "string"
                }
              },
              "required": [
                "id",
                "name",
                "description",
                "sharePath"
              ],
              "additionalProperties": false
            }
          },
          "audio": {
            "type": "string",
            "const": "device-only"
          }
        },
        "description": "Allowlisted original-source references, without owner identity, private media URLs, credentials or invitations. Inaccessible linked playlists are omitted.",
        "required": [
          "id",
          "name",
          "kind",
          "description",
          "visibility",
          "sharePath",
          "items",
          "playlists",
          "audio"
        ],
        "additionalProperties": false
      },
      "CollectionSharingManagement": {
        "type": "object",
        "properties": {
          "sharePath": {
            "type": "string"
          },
          "visibility": {
            "type": "string",
            "enum": [
              "private",
              "invite-only",
              "unlisted",
              "public"
            ]
          },
          "members": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string"
                },
                "name": {
                  "type": "string"
                },
                "email": {
                  "type": "string",
                  "format": "email"
                },
                "role": {
                  "type": "string",
                  "enum": [
                    "listener",
                    "editor"
                  ]
                }
              },
              "required": [
                "id",
                "name",
                "email",
                "role"
              ]
            }
          },
          "invitations": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "pattern": "^[a-f0-9]{64}$"
                },
                "email": {
                  "type": "string",
                  "format": "email"
                },
                "role": {
                  "type": "string",
                  "enum": [
                    "listener",
                    "editor"
                  ]
                },
                "expires": {
                  "type": "string",
                  "format": "date-time"
                }
              },
              "required": [
                "id",
                "email",
                "role",
                "expires"
              ]
            }
          }
        },
        "required": [
          "sharePath",
          "visibility",
          "members",
          "invitations"
        ]
      },
      "CollectionMemberRolePatch": {
        "type": "object",
        "properties": {
          "role": {
            "type": "string",
            "enum": [
              "listener",
              "editor"
            ]
          }
        },
        "required": [
          "role"
        ]
      },
      "ProviderMetadata": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "provider",
          "last4",
          "limit_chars",
          "spent_chars",
          "month"
        ],
        "properties": {
          "provider": {
            "type": "string",
            "enum": [
              "openai",
              "google"
            ]
          },
          "last4": {
            "type": "string"
          },
          "limit_chars": {
            "type": "integer",
            "minimum": 100,
            "maximum": 1000000
          },
          "spent_chars": {
            "type": "integer",
            "minimum": 0
          },
          "month": {
            "type": "string",
            "pattern": "^\\d{4}-\\d{2}$",
            "description": "Current UTC calendar month; spent_chars is zero if no usage has been reserved in this month."
          }
        }
      },
      "PmcSection": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "level": {
            "type": "integer",
            "minimum": 1,
            "maximum": 6
          },
          "kind": {
            "type": "string",
            "enum": [
              "abstract",
              "body",
              "table",
              "figure",
              "references",
              "supplement",
              "other"
            ]
          },
          "text": {
            "type": "string",
            "description": "Original supplied wording rendered as plain text; never provider HTML or generated interpretation."
          }
        },
        "additionalProperties": false,
        "required": [
          "id",
          "title",
          "level",
          "kind",
          "text"
        ]
      },
      "PmcLicense": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "url": {
            "type": "string",
            "format": "uri"
          },
          "text": {
            "type": "string"
          },
          "commercialUseAllowed": {
            "type": "boolean"
          },
          "adaptationAllowed": {
            "type": "boolean"
          },
          "shareAlike": {
            "type": "boolean"
          }
        },
        "additionalProperties": false,
        "required": [
          "name",
          "url",
          "text",
          "commercialUseAllowed",
          "adaptationAllowed",
          "shareAlike"
        ]
      },
      "PmcProvenance": {
        "type": "object",
        "properties": {
          "provider": {
            "type": "string",
            "const": "PMC OAI-PMH"
          },
          "url": {
            "type": "string",
            "format": "uri"
          },
          "retrievedAt": {
            "type": "string",
            "format": "date-time"
          },
          "contentHash": {
            "type": "string",
            "pattern": "^[a-f0-9]{64}$",
            "description": "SHA-256 of extracted sections, attribution, license and explicit omissions, independent of retrieval timestamp."
          },
          "pmcVersion": {
            "type": "string"
          }
        },
        "additionalProperties": false,
        "required": [
          "provider",
          "url",
          "retrievedAt",
          "contentHash"
        ]
      },
      "PmcDocument": {
        "type": "object",
        "properties": {
          "title": {
            "type": "string"
          },
          "sections": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PmcSection"
            },
            "maxItems": 1000
          },
          "license": {
            "$ref": "#/components/schemas/PmcLicense"
          },
          "attribution": {
            "type": "string",
            "description": "Retained title, creators, copyright, source link, license and extraction/narration change notice."
          },
          "provenance": {
            "$ref": "#/components/schemas/PmcProvenance"
          },
          "complete": {
            "type": "boolean",
            "const": true,
            "description": "Complete permitted structured text supplied by the API, not a claim to include non-text media or linked supplement files. No silent truncation."
          },
          "omissions": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Explicitly describes simplified layout/math, images, linked supplemental media and any separately licensed items excluded from reading."
          }
        },
        "additionalProperties": false,
        "required": [
          "title",
          "sections",
          "license",
          "attribution",
          "provenance",
          "complete",
          "omissions"
        ]
      },
      "PmcFullTextResult": {
        "type": "object",
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "available",
              "unavailable",
              "restricted"
            ]
          },
          "pmid": {
            "type": "string",
            "pattern": "^\\d{1,12}$"
          },
          "pmcId": {
            "type": "string",
            "pattern": "^PMC\\d{1,12}$"
          },
          "sourceUrl": {
            "type": "string",
            "format": "uri"
          },
          "message": {
            "type": "string"
          },
          "document": {
            "$ref": "#/components/schemas/PmcDocument"
          }
        },
        "additionalProperties": false,
        "description": "Unavailable or restricted responses contain no document; an abstract is never substituted for full text. A machine-readable commercial/adaptation-compatible CC0, CC BY or CC BY-SA license is required. NC, ND, custom or unverifiable licenses are restricted in this implementation.",
        "allOf": [
          {
            "if": {
              "properties": {
                "status": {
                  "const": "available"
                }
              },
              "required": [
                "status"
              ]
            },
            "then": {
              "required": [
                "document",
                "pmcId"
              ]
            },
            "else": {
              "not": {
                "required": [
                  "document"
                ]
              }
            }
          }
        ],
        "required": [
          "status",
          "pmid",
          "sourceUrl"
        ]
      },
      "RadioPaperCompletionInput": {
        "type": "object",
        "properties": {
          "sessionId": {
            "type": "string",
            "format": "uuid"
          },
          "pmid": {
            "type": "string",
            "pattern": "^\\d{1,12}$"
          },
          "mode": {
            "type": "string",
            "enum": [
              "title",
              "abstract",
              "fulltext"
            ]
          }
        },
        "additionalProperties": false,
        "required": [
          "sessionId",
          "pmid",
          "mode"
        ]
      },
      "RadioPaperCompletionReceipt": {
        "type": "object",
        "properties": {
          "ok": {
            "type": "boolean",
            "const": true
          },
          "duplicate": {
            "type": "boolean"
          },
          "completedPapers": {
            "type": "integer",
            "minimum": 0,
            "description": "Completed papers since the last reserved sponsor break, not verified listening duration."
          },
          "adEveryNPapers": {
            "type": "integer",
            "minimum": 0,
            "maximum": 100,
            "description": "Completed papers between eligible sponsor breaks. Zero disables sponsor breaks for this policy or plan."
          },
          "measurement": {
            "type": "string",
            "const": "Client-reported paper completions for ad spacing; not verified audience or billing measurements."
          }
        },
        "additionalProperties": false,
        "required": [
          "ok",
          "duplicate",
          "completedPapers",
          "adEveryNPapers",
          "measurement"
        ]
      },
      "BillingMode": {
        "type": "string",
        "enum": [
          "test",
          "live"
        ]
      },
      "BillingCategory": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100,
            "pattern": "^[A-Za-z0-9_-]+$"
          },
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 120
          },
          "description": {
            "type": "string",
            "maxLength": 1000
          },
          "active": {
            "type": "boolean"
          },
          "sortOrder": {
            "type": "integer",
            "minimum": 0,
            "maximum": 1000
          }
        },
        "additionalProperties": false,
        "required": [
          "id",
          "name",
          "description",
          "active",
          "sortOrder"
        ]
      },
      "BillingPublicPlan": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100,
            "pattern": "^[A-Za-z0-9_-]+$"
          },
          "categoryId": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100,
            "pattern": "^[A-Za-z0-9_-]+$"
          },
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 120
          },
          "description": {
            "type": "string",
            "maxLength": 2000
          },
          "tier": {
            "type": "string",
            "enum": [
              "free",
              "paid"
            ]
          },
          "amount": {
            "type": "integer",
            "minimum": 0,
            "maximum": 100000000,
            "description": "Amount in Stripe minor currency units; no card details are handled by Papers.fm."
          },
          "currency": {
            "type": "string",
            "pattern": "^[a-z]{3}$"
          },
          "interval": {
            "type": "string",
            "enum": [
              "free",
              "month",
              "year"
            ]
          },
          "adEveryNPapers": {
            "type": "integer",
            "minimum": 0,
            "maximum": 100,
            "description": "Completed papers between eligible sponsor breaks. Zero disables sponsor breaks for this policy or plan."
          },
          "active": {
            "type": "boolean"
          },
          "sortOrder": {
            "type": "integer",
            "minimum": 0,
            "maximum": 1000
          }
        },
        "additionalProperties": false,
        "required": [
          "id",
          "categoryId",
          "name",
          "description",
          "tier",
          "amount",
          "currency",
          "interval",
          "adEveryNPapers",
          "active",
          "sortOrder"
        ]
      },
      "BillingPlan": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100,
            "pattern": "^[A-Za-z0-9_-]+$"
          },
          "categoryId": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100,
            "pattern": "^[A-Za-z0-9_-]+$"
          },
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 120
          },
          "description": {
            "type": "string",
            "maxLength": 2000
          },
          "tier": {
            "type": "string",
            "enum": [
              "free",
              "paid"
            ]
          },
          "amount": {
            "type": "integer",
            "minimum": 0,
            "maximum": 100000000,
            "description": "Amount in Stripe minor currency units; no card details are handled by Papers.fm."
          },
          "currency": {
            "type": "string",
            "pattern": "^[a-z]{3}$"
          },
          "interval": {
            "type": "string",
            "enum": [
              "free",
              "month",
              "year"
            ]
          },
          "adEveryNPapers": {
            "type": "integer",
            "minimum": 0,
            "maximum": 100,
            "description": "Completed papers between eligible sponsor breaks. Zero disables sponsor breaks for this policy or plan."
          },
          "active": {
            "type": "boolean"
          },
          "sortOrder": {
            "type": "integer",
            "minimum": 0,
            "maximum": 1000
          },
          "stripePriceId": {
            "type": "string",
            "pattern": "^$|^price_[A-Za-z0-9]+$",
            "description": "Returned only to recent-MFA administrators. Public catalogue and account responses omit Stripe price IDs."
          }
        },
        "additionalProperties": false,
        "description": "Administrative plan view. The Stripe price ID is optional in the shared TypeScript contract and supplied in the privileged admin listing.",
        "required": [
          "id",
          "categoryId",
          "name",
          "description",
          "tier",
          "amount",
          "currency",
          "interval",
          "adEveryNPapers",
          "active",
          "sortOrder"
        ]
      },
      "BillingConfiguration": {
        "type": "object",
        "properties": {
          "enabled": {
            "type": "boolean"
          },
          "mode": {
            "$ref": "#/components/schemas/BillingMode"
          },
          "freeAdEveryNPapers": {
            "type": "integer",
            "minimum": 0,
            "maximum": 100,
            "description": "Completed papers between eligible sponsor breaks. Zero disables sponsor breaks for this policy or plan.",
            "default": 10
          },
          "paidAdEveryNPapers": {
            "type": "integer",
            "minimum": 0,
            "maximum": 100,
            "description": "Completed papers between eligible sponsor breaks. Zero disables sponsor breaks for this policy or plan.",
            "default": 5
          },
          "stripeKeyConfigured": {
            "type": "boolean"
          },
          "webhookConfigured": {
            "type": "boolean"
          },
          "stripeKeyLast4": {
            "type": "string"
          },
          "webhookLast4": {
            "type": "string"
          },
          "updatedAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          }
        },
        "additionalProperties": false,
        "description": "Only configuration status and credential suffixes are returned; raw secrets are encrypted at rest and are never returned.",
        "required": [
          "enabled",
          "mode",
          "freeAdEveryNPapers",
          "paidAdEveryNPapers",
          "stripeKeyConfigured",
          "webhookConfigured",
          "stripeKeyLast4",
          "webhookLast4",
          "updatedAt"
        ]
      },
      "ListeningEntitlement": {
        "type": "object",
        "properties": {
          "tier": {
            "type": "string",
            "enum": [
              "free",
              "paid"
            ]
          },
          "planId": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100,
            "pattern": "^[A-Za-z0-9_-]+$"
          },
          "planName": {
            "type": "string"
          },
          "adEveryNPapers": {
            "type": "integer",
            "minimum": 0,
            "maximum": 100,
            "description": "Completed papers between eligible sponsor breaks. Zero disables sponsor breaks for this policy or plan."
          },
          "subscriptionStatus": {
            "type": "string"
          },
          "currentPeriodEnd": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "source": {
            "type": "string",
            "enum": [
              "free-default",
              "stripe-webhook"
            ]
          },
          "mode": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/BillingMode"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "additionalProperties": false,
        "description": "Paid status requires current server-reconciled Stripe subscription state, matching test/live mode, and payment verification. Checkout return URLs cannot set this object.",
        "required": [
          "tier",
          "planId",
          "planName",
          "adEveryNPapers",
          "subscriptionStatus",
          "currentPeriodEnd",
          "source",
          "mode"
        ]
      },
      "BillingCatalogue": {
        "type": "object",
        "properties": {
          "enabled": {
            "type": "boolean",
            "description": "True only when checkout is enabled and both Stripe and webhook secrets are configured."
          },
          "mode": {
            "$ref": "#/components/schemas/BillingMode"
          },
          "categories": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BillingCategory"
            }
          },
          "plans": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BillingPublicPlan"
            }
          }
        },
        "additionalProperties": false,
        "required": [
          "enabled",
          "mode",
          "categories",
          "plans"
        ]
      },
      "BillingAccount": {
        "type": "object",
        "properties": {
          "entitlement": {
            "$ref": "#/components/schemas/ListeningEntitlement"
          },
          "hasCustomer": {
            "type": "boolean"
          },
          "paymentsEnabled": {
            "type": "boolean"
          },
          "portalReady": {
            "type": "boolean"
          },
          "mode": {
            "$ref": "#/components/schemas/BillingMode"
          }
        },
        "additionalProperties": false,
        "required": [
          "entitlement",
          "hasCustomer",
          "paymentsEnabled",
          "portalReady",
          "mode"
        ]
      },
      "BillingEventObservation": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^evt_[A-Za-z0-9]+$"
          },
          "type": {
            "type": "string"
          },
          "state": {
            "type": "string",
            "enum": [
              "pending",
              "processing",
              "processed",
              "ignored",
              "failed"
            ]
          },
          "receivedAt": {
            "type": "string",
            "format": "date-time"
          },
          "error": {
            "type": [
              "string",
              "null"
            ]
          }
        },
        "additionalProperties": false,
        "required": [
          "id",
          "type",
          "state",
          "receivedAt",
          "error"
        ]
      },
      "BillingAdministration": {
        "type": "object",
        "properties": {
          "config": {
            "$ref": "#/components/schemas/BillingConfiguration"
          },
          "categories": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BillingCategory"
            }
          },
          "plans": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BillingPlan"
            }
          },
          "recentEvents": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BillingEventObservation"
            },
            "maxItems": 30
          }
        },
        "additionalProperties": false,
        "required": [
          "config",
          "categories",
          "plans",
          "recentEvents"
        ]
      },
      "BillingCheckoutInput": {
        "type": "object",
        "properties": {
          "planId": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100,
            "pattern": "^[A-Za-z0-9_-]+$"
          }
        },
        "additionalProperties": false,
        "required": [
          "planId"
        ]
      },
      "BillingPortalInput": {
        "type": "object",
        "properties": {},
        "additionalProperties": false,
        "required": []
      },
      "BillingHostedUrl": {
        "type": "object",
        "properties": {
          "url": {
            "type": "string",
            "format": "uri",
            "pattern": "^https://(?:checkout|billing)\\.stripe\\.com/",
            "description": "Validated Stripe-hosted checkout or billing portal URL; card entry remains on Stripe."
          }
        },
        "additionalProperties": false,
        "required": [
          "url"
        ]
      },
      "BillingConfigurationPatch": {
        "type": "object",
        "properties": {
          "enabled": {
            "type": "boolean",
            "description": "Primary owner plus recent MFA required."
          },
          "mode": {
            "$ref": "#/components/schemas/BillingMode"
          },
          "stripeSecretKey": {
            "type": "string",
            "minLength": 12,
            "maxLength": 500,
            "pattern": "^sk_(test|live)_[A-Za-z0-9]+$",
            "writeOnly": true
          },
          "webhookSecret": {
            "type": "string",
            "minLength": 12,
            "maxLength": 500,
            "pattern": "^whsec_[A-Za-z0-9]+$",
            "writeOnly": true
          },
          "freeAdEveryNPapers": {
            "type": "integer",
            "minimum": 0,
            "maximum": 100,
            "description": "Completed papers between eligible sponsor breaks. Zero disables sponsor breaks for this policy or plan."
          },
          "paidAdEveryNPapers": {
            "type": "integer",
            "minimum": 0,
            "maximum": 100,
            "description": "Completed papers between eligible sponsor breaks. Zero disables sponsor breaks for this policy or plan."
          }
        },
        "additionalProperties": false,
        "minProperties": 1,
        "description": "Any credential, enabled or mode field requires the primary owner and recent MFA. Cadence-only changes require an administrator and recent MFA. Changing test/live mode requires a matching new Stripe secret key and webhook signing secret in the same request; a live deployment with linked customers cannot be switched back to test. Enabling checkout requires both secrets."
      },
      "BillingConfigurationSaved": {
        "type": "object",
        "properties": {
          "config": {
            "$ref": "#/components/schemas/BillingConfiguration"
          }
        },
        "additionalProperties": false,
        "required": [
          "config"
        ]
      },
      "BillingCategoryInput": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 120
          },
          "description": {
            "type": "string",
            "maxLength": 1000,
            "default": ""
          },
          "active": {
            "type": "boolean",
            "default": true
          },
          "sortOrder": {
            "type": "integer",
            "minimum": 0,
            "maximum": 1000,
            "default": 0
          }
        },
        "additionalProperties": false,
        "required": [
          "name"
        ]
      },
      "BillingCategoryPatch": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 120
          },
          "description": {
            "type": "string",
            "maxLength": 1000
          },
          "active": {
            "type": "boolean"
          },
          "sortOrder": {
            "type": "integer",
            "minimum": 0,
            "maximum": 1000
          }
        },
        "additionalProperties": false
      },
      "BillingPlanInput": {
        "type": "object",
        "properties": {
          "categoryId": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100,
            "pattern": "^[A-Za-z0-9_-]+$"
          },
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 120
          },
          "description": {
            "type": "string",
            "maxLength": 2000,
            "default": ""
          },
          "tier": {
            "type": "string",
            "enum": [
              "free",
              "paid"
            ]
          },
          "amount": {
            "type": "integer",
            "minimum": 0,
            "maximum": 100000000,
            "description": "Amount in Stripe minor currency units; no card details are handled by Papers.fm."
          },
          "currency": {
            "type": "string",
            "pattern": "^[a-z]{3}$",
            "default": "eur"
          },
          "interval": {
            "type": "string",
            "enum": [
              "free",
              "month",
              "year"
            ]
          },
          "active": {
            "type": "boolean",
            "default": false
          },
          "sortOrder": {
            "type": "integer",
            "minimum": 0,
            "maximum": 1000,
            "default": 0
          },
          "stripePriceId": {
            "type": "string",
            "pattern": "^$|^price_[A-Za-z0-9]+$",
            "default": ""
          },
          "adEveryNPapers": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 0,
            "maximum": 100,
            "description": "Null or omitted inherits the configured cadence for this tier. Zero disables breaks for this plan."
          }
        },
        "additionalProperties": false,
        "description": "Free plans require amount=0, interval=free and an empty Stripe price; paid plans require a positive recurring amount, interval=month/year, and an active paid plan requires a Stripe price. Only one free plan can be active. Stripe price IDs cannot be shared across plans. Once checkout/subscription history exists, monetary terms and price IDs are protected; create a new plan for price changes. Server checkout also verifies the actual Stripe price amount, currency, mode and recurring interval.",
        "required": [
          "categoryId",
          "name",
          "tier",
          "amount",
          "interval"
        ]
      },
      "BillingPlanPatch": {
        "type": "object",
        "properties": {
          "categoryId": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100,
            "pattern": "^[A-Za-z0-9_-]+$"
          },
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 120
          },
          "description": {
            "type": "string",
            "maxLength": 2000
          },
          "tier": {
            "type": "string",
            "enum": [
              "free",
              "paid"
            ]
          },
          "amount": {
            "type": "integer",
            "minimum": 0,
            "maximum": 100000000,
            "description": "Amount in Stripe minor currency units; no card details are handled by Papers.fm."
          },
          "currency": {
            "type": "string",
            "pattern": "^[a-z]{3}$"
          },
          "interval": {
            "type": "string",
            "enum": [
              "free",
              "month",
              "year"
            ]
          },
          "active": {
            "type": "boolean"
          },
          "sortOrder": {
            "type": "integer",
            "minimum": 0,
            "maximum": 1000
          },
          "stripePriceId": {
            "type": "string",
            "pattern": "^$|^price_[A-Za-z0-9]+$"
          },
          "adEveryNPapers": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 0,
            "maximum": 100,
            "description": "Null or omitted inherits the configured cadence for this tier. Zero disables breaks for this plan."
          }
        },
        "additionalProperties": false,
        "description": "Partial update merged into the existing plan before the same complete validation. Free plans require amount=0, interval=free and an empty Stripe price; paid plans require a positive recurring amount, interval=month/year, and an active paid plan requires a Stripe price. Only one free plan can be active. Stripe price IDs cannot be shared across plans. Once checkout/subscription history exists, monetary terms and price IDs are protected; create a new plan for price changes. Server checkout also verifies the actual Stripe price amount, currency, mode and recurring interval."
      },
      "BillingSavedId": {
        "type": "object",
        "properties": {
          "ok": {
            "type": "boolean",
            "const": true
          },
          "id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100,
            "pattern": "^[A-Za-z0-9_-]+$"
          }
        },
        "additionalProperties": false,
        "required": [
          "ok",
          "id"
        ]
      },
      "StripeWebhookEvent": {
        "type": "object",
        "required": [
          "id",
          "type",
          "livemode",
          "data"
        ],
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^evt_[A-Za-z0-9]+$"
          },
          "type": {
            "type": "string",
            "maxLength": 120
          },
          "livemode": {
            "type": "boolean"
          },
          "data": {
            "type": "object",
            "required": [
              "object"
            ],
            "properties": {
              "object": {
                "type": "object",
                "additionalProperties": true,
                "description": "Stripe event object; reconciled against current Stripe API state rather than trusted as an entitlement assertion."
              }
            },
            "additionalProperties": true
          }
        },
        "additionalProperties": true,
        "description": "Signed Stripe event envelope. The exact raw request bytes must be retained for signature verification; do not reserialize JSON before checking the signature."
      },
      "StripeWebhookReceipt": {
        "type": "object",
        "properties": {
          "received": {
            "type": "boolean",
            "const": true
          },
          "duplicate": {
            "type": "boolean",
            "const": true,
            "description": "Present for an already processed or ignored event ID."
          }
        },
        "additionalProperties": false,
        "required": [
          "received"
        ]
      },
      "DiagnosticContext": {
        "type": "object",
        "properties": {
          "state": {
            "type": "string",
            "enum": [
              "idle",
              "selecting",
              "loading",
              "starting",
              "playing",
              "paused",
              "blocked",
              "failed"
            ]
          },
          "queueCount": {
            "type": "integer",
            "minimum": 0,
            "maximum": 50
          },
          "queueIndex": {
            "type": "integer",
            "minimum": 0,
            "maximum": 50
          },
          "selectedCount": {
            "type": "integer",
            "minimum": 0,
            "maximum": 500
          },
          "autoplay": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "ClientDiagnosticInput": {
        "type": "object",
        "properties": {
          "state": {
            "type": "string",
            "enum": [
              "idle",
              "selecting",
              "loading",
              "starting",
              "playing",
              "paused",
              "blocked",
              "failed"
            ]
          },
          "queueCount": {
            "type": "integer",
            "minimum": 0,
            "maximum": 50
          },
          "queueIndex": {
            "type": "integer",
            "minimum": 0,
            "maximum": 50
          },
          "selectedCount": {
            "type": "integer",
            "minimum": 0,
            "maximum": 500
          },
          "autoplay": {
            "type": "boolean"
          },
          "operation": {
            "type": "string",
            "enum": [
              "selection",
              "playback",
              "speech",
              "audio",
              "search",
              "fulltext",
              "request",
              "initialization",
              "authentication",
              "settings",
              "sharing",
              "billing",
              "advertising",
              "rendering"
            ]
          },
          "code": {
            "type": "string",
            "enum": [
              "SELECTION_EMPTY",
              "SELECTION_INVALID",
              "QUEUE_FAILED",
              "SPEECH_UNAVAILABLE",
              "SPEECH_FAILED",
              "SPEECH_TIMEOUT",
              "AUDIO_BLOCKED",
              "AUDIO_FAILED",
              "NETWORK_OFFLINE",
              "NETWORK_FAILED",
              "REQUEST_FAILED",
              "AUTH_REQUIRED",
              "MFA_REQUIRED",
              "ACCESS_DENIED",
              "RATE_LIMITED",
              "PROVIDER_FAILED",
              "ALLOWANCE_EXCEEDED",
              "RESPONSE_INVALID",
              "UNEXPECTED_ERROR",
              "RENDER_FAILED"
            ]
          },
          "provider": {
            "type": "string",
            "enum": [
              "device",
              "openai",
              "openai-trial",
              "google",
              "pubmed",
              "pmc",
              "stripe"
            ]
          }
        },
        "required": [
          "operation",
          "code"
        ],
        "additionalProperties": false
      },
      "DiagnosticReceipt": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "incidentId": {
            "type": "string",
            "format": "uuid"
          }
        },
        "required": [
          "id",
          "incidentId"
        ]
      },
      "DiagnosticIncident": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "source": {
            "type": "string",
            "enum": [
              "server",
              "client"
            ]
          },
          "severity": {
            "type": "string",
            "enum": [
              "warning",
              "error"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "open",
              "resolved"
            ]
          },
          "code": {
            "type": "string",
            "enum": [
              "SELECTION_EMPTY",
              "SELECTION_INVALID",
              "QUEUE_FAILED",
              "SPEECH_UNAVAILABLE",
              "SPEECH_FAILED",
              "SPEECH_TIMEOUT",
              "AUDIO_BLOCKED",
              "AUDIO_FAILED",
              "NETWORK_OFFLINE",
              "NETWORK_FAILED",
              "REQUEST_FAILED",
              "AUTH_REQUIRED",
              "MFA_REQUIRED",
              "ACCESS_DENIED",
              "RATE_LIMITED",
              "PROVIDER_FAILED",
              "ALLOWANCE_EXCEEDED",
              "RESPONSE_INVALID",
              "UNEXPECTED_ERROR",
              "RENDER_FAILED"
            ]
          },
          "operation": {
            "type": "string",
            "enum": [
              "selection",
              "playback",
              "speech",
              "audio",
              "search",
              "fulltext",
              "request",
              "initialization",
              "authentication",
              "settings",
              "sharing",
              "billing",
              "advertising",
              "rendering"
            ]
          },
          "summary": {
            "type": "string"
          },
          "recovery": {
            "type": "string"
          },
          "provider": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "device",
              "openai",
              "openai-trial",
              "google",
              "pubmed",
              "pmc",
              "stripe",
              null
            ]
          },
          "ownerId": {
            "type": [
              "string",
              "null"
            ]
          },
          "method": {
            "type": [
              "string",
              "null"
            ]
          },
          "route": {
            "type": [
              "string",
              "null"
            ],
            "description": "Template without query strings or dynamic identifiers."
          },
          "httpStatus": {
            "type": [
              "integer",
              "null"
            ]
          },
          "version": {
            "type": "string"
          },
          "occurrences": {
            "type": "integer",
            "minimum": 1
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "lastSeenAt": {
            "type": "string",
            "format": "date-time"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time"
          },
          "resolvedAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          }
        },
        "required": [
          "id",
          "source",
          "severity",
          "status",
          "code",
          "operation",
          "summary",
          "recovery",
          "provider",
          "ownerId",
          "method",
          "route",
          "httpStatus",
          "version",
          "occurrences",
          "createdAt",
          "lastSeenAt",
          "updatedAt",
          "resolvedAt"
        ]
      },
      "DiagnosticTechnical": {
        "type": "object",
        "properties": {
          "kind": {
            "type": "string"
          },
          "frames": {
            "type": "array",
            "maxItems": 6,
            "items": {
              "type": "string"
            }
          },
          "upstreamStatus": {
            "type": "integer",
            "minimum": 100,
            "maximum": 599
          },
          "upstreamCode": {
            "type": "string"
          },
          "retryAfterSeconds": {
            "type": "number",
            "minimum": 0,
            "maximum": 86400
          }
        },
        "required": [
          "kind",
          "frames"
        ],
        "additionalProperties": false
      },
      "DiagnosticIncidentDetail": {
        "allOf": [
          {
            "$ref": "#/components/schemas/DiagnosticIncident"
          },
          {
            "type": "object",
            "properties": {
              "context": {
                "$ref": "#/components/schemas/DiagnosticContext"
              },
              "technical": {
                "$ref": "#/components/schemas/DiagnosticTechnical"
              }
            },
            "required": [
              "context",
              "technical"
            ]
          }
        ]
      },
      "DiagnosticDetailResponse": {
        "type": "object",
        "properties": {
          "incident": {
            "$ref": "#/components/schemas/DiagnosticIncidentDetail"
          }
        },
        "required": [
          "incident"
        ]
      },
      "DiagnosticsList": {
        "type": "object",
        "properties": {
          "incidents": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DiagnosticIncident"
            },
            "maxItems": 50
          },
          "nextCursor": {
            "type": [
              "string",
              "null"
            ]
          },
          "counts": {
            "type": "object",
            "properties": {
              "open": {
                "type": "integer",
                "minimum": 0
              },
              "resolved": {
                "type": "integer",
                "minimum": 0
              }
            },
            "required": [
              "open",
              "resolved"
            ]
          },
          "retention": {
            "type": "object",
            "properties": {
              "days": {
                "const": 14
              },
              "maxRecords": {
                "const": 2000
              }
            },
            "required": [
              "days",
              "maxRecords"
            ]
          }
        },
        "required": [
          "incidents",
          "nextCursor",
          "counts",
          "retention"
        ]
      },
      "DiagnosticStatusInput": {
        "type": "object",
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "open",
              "resolved"
            ]
          }
        },
        "required": [
          "status"
        ],
        "additionalProperties": false
      },
      "DiagnosticStatusResponse": {
        "type": "object",
        "properties": {
          "ok": {
            "const": true
          }
        },
        "required": [
          "ok"
        ]
      },
      "SiteDesign": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "accent",
          "canvas",
          "surface",
          "text",
          "mutedText",
          "font",
          "density",
          "corners",
          "contentWidth"
        ],
        "properties": {
          "accent": {
            "type": "string",
            "pattern": "^#[0-9a-fA-F]{6}$",
            "description": "Six-digit hexadecimal colour; publication normalizes to lowercase."
          },
          "canvas": {
            "type": "string",
            "pattern": "^#[0-9a-fA-F]{6}$",
            "description": "Six-digit hexadecimal colour; publication normalizes to lowercase."
          },
          "surface": {
            "type": "string",
            "pattern": "^#[0-9a-fA-F]{6}$",
            "description": "Six-digit hexadecimal colour; publication normalizes to lowercase."
          },
          "text": {
            "type": "string",
            "pattern": "^#[0-9a-fA-F]{6}$",
            "description": "Six-digit hexadecimal colour; publication normalizes to lowercase."
          },
          "mutedText": {
            "type": "string",
            "pattern": "^#[0-9a-fA-F]{6}$",
            "description": "Six-digit hexadecimal colour; publication normalizes to lowercase."
          },
          "font": {
            "type": "string",
            "enum": [
              "system",
              "humanist",
              "editorial"
            ]
          },
          "density": {
            "type": "string",
            "enum": [
              "comfortable",
              "roomy"
            ]
          },
          "corners": {
            "type": "string",
            "enum": [
              "subtle",
              "rounded",
              "soft"
            ]
          },
          "contentWidth": {
            "type": "integer",
            "enum": [
              1120,
              1280,
              1440
            ]
          }
        },
        "description": "Validated palette and fixed layout choices only. Main text, secondary text and accent links require contrast >=4.5:1 against both canvas and surface; both surfaces require relative luminance >=0.7. No arbitrary CSS, HTML, script, remote font or feature-visibility input."
      },
      "SiteDesignPublic": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "settings",
          "revision",
          "updatedAt"
        ],
        "properties": {
          "settings": {
            "$ref": "#/components/schemas/SiteDesign"
          },
          "revision": {
            "type": "integer",
            "minimum": 0
          },
          "updatedAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          }
        },
        "description": "Public current design only. Excludes administrator IDs and the prior settings. Defaults use revision 0 and updatedAt null before first publication."
      },
      "SiteDesignManagement": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "settings",
          "revision",
          "updatedAt",
          "canRevert"
        ],
        "properties": {
          "settings": {
            "$ref": "#/components/schemas/SiteDesign"
          },
          "revision": {
            "type": "integer",
            "minimum": 0
          },
          "updatedAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "canRevert": {
            "type": "boolean"
          }
        }
      },
      "SiteDesignChange": {
        "oneOf": [
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "action",
              "expectedRevision",
              "settings"
            ],
            "properties": {
              "action": {
                "type": "string",
                "const": "publish"
              },
              "expectedRevision": {
                "type": "integer",
                "minimum": 0,
                "maximum": 1000000000
              },
              "settings": {
                "$ref": "#/components/schemas/SiteDesign"
              }
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "action",
              "expectedRevision"
            ],
            "properties": {
              "action": {
                "type": "string",
                "const": "revert"
              },
              "expectedRevision": {
                "type": "integer",
                "minimum": 0,
                "maximum": 1000000000
              }
            }
          }
        ],
        "discriminator": {
          "propertyName": "action"
        },
        "description": "Publish a complete validated draft or restore one previous publication. expectedRevision must match the current server revision; a successful change increments it."
      },
      "GmailConnectionStatus": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "configured",
          "connected",
          "email",
          "status",
          "updatedAt",
          "scope"
        ],
        "properties": {
          "configured": {
            "type": "boolean"
          },
          "connected": {
            "type": "boolean"
          },
          "email": {
            "type": [
              "string",
              "null"
            ],
            "format": "email",
            "maxLength": 254
          },
          "status": {
            "type": "string",
            "enum": [
              "active",
              "reconnect",
              "disconnected"
            ]
          },
          "updatedAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "scope": {
            "type": "string",
            "const": "https://www.googleapis.com/auth/gmail.readonly"
          }
        }
      },
      "AccountConnectionsStatus": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "gmail",
          "openai",
          "chatgpt"
        ],
        "properties": {
          "gmail": {
            "$ref": "#/components/schemas/GmailConnectionStatus"
          },
          "openai": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "connected",
              "last4",
              "method"
            ],
            "properties": {
              "connected": {
                "type": "boolean"
              },
              "last4": {
                "type": [
                  "string",
                  "null"
                ],
                "maxLength": 4
              },
              "method": {
                "type": "string",
                "const": "api-key"
              }
            }
          },
          "chatgpt": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "connected",
              "available",
              "reason",
              "documentationUrl"
            ],
            "properties": {
              "connected": {
                "type": "boolean",
                "const": false
              },
              "available": {
                "type": "boolean",
                "const": false
              },
              "reason": {
                "type": "string",
                "const": "partner-approval-required"
              },
              "documentationUrl": {
                "type": "string",
                "const": "https://developers.openai.com/siwc/request-client-id"
              }
            }
          }
        },
        "description": "Authenticated account metadata only; no API keys or Google access/refresh tokens. ChatGPT identity and API inference are separate provider contracts. No direct ChatGPT OAuth endpoint is implemented or implied."
      },
      "GmailConnectionStart": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "consent"
        ],
        "properties": {
          "consent": {
            "type": "boolean",
            "const": true
          }
        }
      },
      "GmailAuthorization": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "authorizationUrl"
        ],
        "properties": {
          "authorizationUrl": {
            "type": "string",
            "format": "uri",
            "pattern": "^https://accounts\\.google\\.com/o/oauth2/v2/auth\\?"
          }
        },
        "description": "Visit this Google URL explicitly. State and S256 PKCE bind a ten-minute one-use transaction to the current account, exact session and authentication/MFA versions. The Papers.fm email is a login hint; Google account selection and permission remain explicit."
      },
      "GmailMessageSearch": {
        "type": "object",
        "additionalProperties": false,
        "required": [],
        "properties": {
          "query": {
            "type": "string",
            "minLength": 1,
            "maxLength": 160,
            "description": "Trimmed Gmail search syntax. Omit to use (pubmed OR ncbi OR doi.org) newer_than:30d. Spam and trash excluded."
          }
        }
      },
      "GmailMessageSummary": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "subject",
          "from",
          "date"
        ],
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^[a-fA-F0-9]{1,40}$",
            "maxLength": 40
          },
          "subject": {
            "type": "string",
            "maxLength": 200
          },
          "from": {
            "type": "string",
            "maxLength": 200
          },
          "date": {
            "type": "string",
            "maxLength": 200,
            "description": "Original sanitized Date header, not an ISO timestamp."
          }
        }
      },
      "GmailMessages": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "messages",
          "retained"
        ],
        "properties": {
          "messages": {
            "type": "array",
            "maxItems": 10,
            "items": {
              "$ref": "#/components/schemas/GmailMessageSummary"
            }
          },
          "retained": {
            "type": "boolean",
            "const": false
          }
        },
        "description": "At most ten message-header previews; metadata only, no message body. Headers are returned to the current user without database/log/audit retention."
      },
      "GmailMessageExtract": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "messageId"
        ],
        "properties": {
          "messageId": {
            "type": "string",
            "pattern": "^[a-fA-F0-9]{1,40}$",
            "maxLength": 40
          }
        }
      },
      "GmailPaperIdentifiers": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "pmids",
          "dois"
        ],
        "properties": {
          "pmids": {
            "type": "array",
            "maxItems": 50,
            "uniqueItems": true,
            "items": {
              "type": "string",
              "pattern": "^[0-9]{1,12}$",
              "maxLength": 12
            }
          },
          "dois": {
            "type": "array",
            "maxItems": 50,
            "uniqueItems": true,
            "items": {
              "type": "string",
              "pattern": "^10\\.[0-9]{4,9}/[^\\s<>\\\"\\x27?#]{1,200}$",
              "maxLength": 213,
              "description": "Normalized lowercase DOI from an exact doi.org/dx.doi.org link."
            }
          }
        }
      },
      "GmailExtraction": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "identifiers",
          "retained"
        ],
        "properties": {
          "identifiers": {
            "$ref": "#/components/schemas/GmailPaperIdentifiers"
          },
          "retained": {
            "type": "boolean",
            "const": false
          }
        },
        "description": "Identifiers extracted from the explicitly selected message. Only exact PubMed/NCBI and DOI link hosts are recognized; links are never followed. Attachments and unrelated/redirect links are skipped. Message JSON <=512 KiB, decoded text <=256 KiB, traversal depth <=8 and <=50 parts. No body/header retention."
      },
      "GmailDisconnection": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "ok",
          "revoked",
          "revocationUrl"
        ],
        "properties": {
          "ok": {
            "type": "boolean",
            "const": true
          },
          "revoked": {
            "type": "boolean"
          },
          "revocationUrl": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              null,
              "https://myaccount.google.com/connections"
            ]
          }
        },
        "description": "Local grant and pending/in-flight transactions are removed even if Google is unreachable. revoked=false supplies Google permissions URL for manual revocation. Local disconnection is not proof that provider-side revocation succeeded."
      }
    }
  }
}
