{
 "openapi": "3.1.0",
 "info": {
  "title": "Comptroller Desk read-only API",
  "version": "1.2.0",
  "description": "Public resource management source documents. No authentication. Ranking is mechanical; see /llms.txt. The MCP server is at /mcp (Streamable HTTP, JSON-RPC).",
  "contact": {
   "email": "tim@comptrollerdesk.com",
   "url": "https://comptrollerdesk.com/support"
  },
  "termsOfService": "https://comptrollerdesk.com/terms"
 },
 "servers": [
  {
   "url": "https://comptrollerdesk.com"
  }
 ],
 "paths": {
  "/api/search": {
   "get": {
    "operationId": "search",
    "summary": "Search documents and extracted page text",
    "parameters": [
     {
      "name": "q",
      "in": "query",
      "schema": {
       "type": "string",
       "maxLength": 200
      },
      "description": "Words, phrase or citation. Empty lists documents."
     },
     {
      "name": "collection",
      "in": "query",
      "schema": {
       "type": "string"
      },
      "description": "Collection id, or group:law, group:defense, group:services, group:budget."
     },
     {
      "name": "issuer",
      "in": "query",
      "schema": {
       "type": "string"
      },
      "description": "Exact issuer name."
     },
     {
      "name": "from",
      "in": "query",
      "schema": {
       "type": "string",
       "pattern": "^\\d{4}(-\\d{2}(-\\d{2})?)?$"
      },
      "description": "YYYY, YYYY-MM or YYYY-MM-DD. Excludes undated documents."
     },
     {
      "name": "to",
      "in": "query",
      "schema": {
       "type": "string",
       "pattern": "^\\d{4}(-\\d{2}(-\\d{2})?)?$"
      },
      "description": "YYYY, YYYY-MM or YYYY-MM-DD. Excludes undated documents."
     },
     {
      "name": "sort",
      "in": "query",
      "schema": {
       "type": "string",
       "enum": [
        "relevance",
        "date",
        "title"
       ]
      }
     },
     {
      "name": "offset",
      "in": "query",
      "schema": {
       "type": "integer",
       "minimum": 0,
       "maximum": 10000,
       "default": 0
      }
     },
     {
      "name": "limit",
      "in": "query",
      "schema": {
       "type": "integer",
       "minimum": 1,
       "maximum": 100,
       "default": 20
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Search results",
      "headers": {
       "ETag": {
        "schema": {
         "type": "string"
        }
       },
       "Last-Modified": {
        "schema": {
         "type": "string"
        }
       },
       "Cache-Control": {
        "schema": {
         "type": "string"
        }
       },
       "RateLimit-Limit": {
        "schema": {
         "type": "integer"
        },
        "description": "Requests allowed per minute for this client."
       },
       "RateLimit-Remaining": {
        "schema": {
         "type": "integer"
        }
       },
       "RateLimit-Reset": {
        "schema": {
         "type": "integer"
        },
        "description": "Seconds until the window resets."
       }
      },
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/SearchResult"
        }
       }
      }
     },
     "304": {
      "description": "Not modified (If-None-Match or If-Modified-Since matched)."
     },
     "400": {
      "description": "Invalid parameter",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Too many requests for this client.",
      "headers": {
       "RateLimit-Limit": {
        "schema": {
         "type": "integer"
        },
        "description": "Requests allowed per minute for this client."
       },
       "RateLimit-Remaining": {
        "schema": {
         "type": "integer"
        }
       },
       "RateLimit-Reset": {
        "schema": {
         "type": "integer"
        },
        "description": "Seconds until the window resets."
       },
       "Retry-After": {
        "schema": {
         "type": "integer"
        }
       }
      },
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "503": {
      "description": "Endpoint turned off by the site operator.",
      "headers": {
       "Retry-After": {
        "schema": {
         "type": "integer"
        }
       }
      },
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/api/appropriations": {
   "get": {
    "operationId": "listAppropriations",
    "summary": "Appropriation cheat sheet entries matching a Treasury code, short name or title words (all entries when q is empty)",
    "parameters": [
     {
      "name": "q",
      "in": "query",
      "schema": {
       "type": "string",
       "maxLength": 100
      },
      "description": "Treasury code ('17 1106', '017-1106', '1106'), short name ('O&M,MC') or words from the title. Exact code and name matches come first."
     }
    ],
    "responses": {
     "200": {
      "description": "Entries with their citations",
      "headers": {
       "ETag": {
        "schema": {
         "type": "string"
        }
       },
       "Last-Modified": {
        "schema": {
         "type": "string"
        }
       },
       "Cache-Control": {
        "schema": {
         "type": "string"
        }
       },
       "RateLimit-Limit": {
        "schema": {
         "type": "integer"
        },
        "description": "Requests allowed per minute for this client."
       },
       "RateLimit-Remaining": {
        "schema": {
         "type": "integer"
        }
       },
       "RateLimit-Reset": {
        "schema": {
         "type": "integer"
        },
        "description": "Seconds until the window resets."
       }
      },
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/AppropriationsResponse"
        }
       }
      }
     },
     "304": {
      "description": "Not modified (If-None-Match or If-Modified-Since matched)."
     },
     "400": {
      "description": "Invalid parameter",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Too many requests for this client.",
      "headers": {
       "RateLimit-Limit": {
        "schema": {
         "type": "integer"
        },
        "description": "Requests allowed per minute for this client."
       },
       "RateLimit-Remaining": {
        "schema": {
         "type": "integer"
        }
       },
       "RateLimit-Reset": {
        "schema": {
         "type": "integer"
        },
        "description": "Seconds until the window resets."
       },
       "Retry-After": {
        "schema": {
         "type": "integer"
        }
       }
      },
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "503": {
      "description": "Endpoint turned off by the site operator.",
      "headers": {
       "Retry-After": {
        "schema": {
         "type": "integer"
        }
       }
      },
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/api/appropriations/{code}": {
   "get": {
    "operationId": "getAppropriation",
    "summary": "One appropriation cheat sheet entry by Treasury code",
    "parameters": [
     {
      "name": "code",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Treasury code, e.g. '17 1106' (URL-encoded), '17-1106' or '171106'."
     }
    ],
    "responses": {
     "200": {
      "description": "Entry with its citations",
      "headers": {
       "ETag": {
        "schema": {
         "type": "string"
        }
       },
       "Last-Modified": {
        "schema": {
         "type": "string"
        }
       },
       "Cache-Control": {
        "schema": {
         "type": "string"
        }
       },
       "RateLimit-Limit": {
        "schema": {
         "type": "integer"
        },
        "description": "Requests allowed per minute for this client."
       },
       "RateLimit-Remaining": {
        "schema": {
         "type": "integer"
        }
       },
       "RateLimit-Reset": {
        "schema": {
         "type": "integer"
        },
        "description": "Seconds until the window resets."
       }
      },
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/AppropriationResponse"
        }
       }
      }
     },
     "304": {
      "description": "Not modified (If-None-Match or If-Modified-Since matched)."
     },
     "404": {
      "description": "Not found",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Too many requests for this client.",
      "headers": {
       "RateLimit-Limit": {
        "schema": {
         "type": "integer"
        },
        "description": "Requests allowed per minute for this client."
       },
       "RateLimit-Remaining": {
        "schema": {
         "type": "integer"
        }
       },
       "RateLimit-Reset": {
        "schema": {
         "type": "integer"
        },
        "description": "Seconds until the window resets."
       },
       "Retry-After": {
        "schema": {
         "type": "integer"
        }
       }
      },
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "503": {
      "description": "Endpoint turned off by the site operator.",
      "headers": {
       "Retry-After": {
        "schema": {
         "type": "integer"
        }
       }
      },
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/api/catalog": {
   "get": {
    "operationId": "catalog",
    "summary": "Counts and every catalog record",
    "responses": {
     "200": {
      "description": "Catalog",
      "headers": {
       "ETag": {
        "schema": {
         "type": "string"
        }
       },
       "Last-Modified": {
        "schema": {
         "type": "string"
        }
       },
       "Cache-Control": {
        "schema": {
         "type": "string"
        }
       },
       "RateLimit-Limit": {
        "schema": {
         "type": "integer"
        },
        "description": "Requests allowed per minute for this client."
       },
       "RateLimit-Remaining": {
        "schema": {
         "type": "integer"
        }
       },
       "RateLimit-Reset": {
        "schema": {
         "type": "integer"
        },
        "description": "Seconds until the window resets."
       }
      },
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/CatalogResponse"
        }
       }
      }
     },
     "304": {
      "description": "Not modified (If-None-Match or If-Modified-Since matched)."
     },
     "429": {
      "description": "Too many requests for this client.",
      "headers": {
       "RateLimit-Limit": {
        "schema": {
         "type": "integer"
        },
        "description": "Requests allowed per minute for this client."
       },
       "RateLimit-Remaining": {
        "schema": {
         "type": "integer"
        }
       },
       "RateLimit-Reset": {
        "schema": {
         "type": "integer"
        },
        "description": "Seconds until the window resets."
       },
       "Retry-After": {
        "schema": {
         "type": "integer"
        }
       }
      },
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "503": {
      "description": "Endpoint turned off by the site operator.",
      "headers": {
       "Retry-After": {
        "schema": {
         "type": "integer"
        }
       }
      },
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/api/collections": {
   "get": {
    "operationId": "listCollections",
    "summary": "Collections with document and page counts",
    "responses": {
     "200": {
      "description": "Collections",
      "headers": {
       "ETag": {
        "schema": {
         "type": "string"
        }
       },
       "Last-Modified": {
        "schema": {
         "type": "string"
        }
       },
       "Cache-Control": {
        "schema": {
         "type": "string"
        }
       },
       "RateLimit-Limit": {
        "schema": {
         "type": "integer"
        },
        "description": "Requests allowed per minute for this client."
       },
       "RateLimit-Remaining": {
        "schema": {
         "type": "integer"
        }
       },
       "RateLimit-Reset": {
        "schema": {
         "type": "integer"
        },
        "description": "Seconds until the window resets."
       }
      },
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/CollectionsResponse"
        }
       }
      }
     },
     "304": {
      "description": "Not modified (If-None-Match or If-Modified-Since matched)."
     },
     "429": {
      "description": "Too many requests for this client.",
      "headers": {
       "RateLimit-Limit": {
        "schema": {
         "type": "integer"
        },
        "description": "Requests allowed per minute for this client."
       },
       "RateLimit-Remaining": {
        "schema": {
         "type": "integer"
        }
       },
       "RateLimit-Reset": {
        "schema": {
         "type": "integer"
        },
        "description": "Seconds until the window resets."
       },
       "Retry-After": {
        "schema": {
         "type": "integer"
        }
       }
      },
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "503": {
      "description": "Endpoint turned off by the site operator.",
      "headers": {
       "Retry-After": {
        "schema": {
         "type": "integer"
        }
       }
      },
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/api/documents/{id}": {
   "get": {
    "operationId": "getDocument",
    "summary": "One catalog record",
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "pattern": "^[a-z0-9]+(?:[.-][a-z0-9]+)*$",
       "maxLength": 80,
       "description": "Stable id; never changes once published."
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Document record",
      "headers": {
       "ETag": {
        "schema": {
         "type": "string"
        }
       },
       "Last-Modified": {
        "schema": {
         "type": "string"
        }
       },
       "Cache-Control": {
        "schema": {
         "type": "string"
        }
       },
       "RateLimit-Limit": {
        "schema": {
         "type": "integer"
        },
        "description": "Requests allowed per minute for this client."
       },
       "RateLimit-Remaining": {
        "schema": {
         "type": "integer"
        }
       },
       "RateLimit-Reset": {
        "schema": {
         "type": "integer"
        },
        "description": "Seconds until the window resets."
       }
      },
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/DocumentRecord"
        }
       }
      }
     },
     "304": {
      "description": "Not modified (If-None-Match or If-Modified-Since matched)."
     },
     "404": {
      "description": "Not found",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Too many requests for this client.",
      "headers": {
       "RateLimit-Limit": {
        "schema": {
         "type": "integer"
        },
        "description": "Requests allowed per minute for this client."
       },
       "RateLimit-Remaining": {
        "schema": {
         "type": "integer"
        }
       },
       "RateLimit-Reset": {
        "schema": {
         "type": "integer"
        },
        "description": "Seconds until the window resets."
       },
       "Retry-After": {
        "schema": {
         "type": "integer"
        }
       }
      },
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "503": {
      "description": "Endpoint turned off by the site operator.",
      "headers": {
       "Retry-After": {
        "schema": {
         "type": "integer"
        }
       }
      },
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/catalog.json": {
   "get": {
    "operationId": "catalogJson",
    "summary": "Every catalog record as a JSON array",
    "responses": {
     "200": {
      "description": "Records",
      "headers": {
       "ETag": {
        "schema": {
         "type": "string"
        }
       },
       "Last-Modified": {
        "schema": {
         "type": "string"
        }
       },
       "Cache-Control": {
        "schema": {
         "type": "string"
        }
       }
      },
      "content": {
       "application/json": {
        "schema": {
         "type": "array",
         "items": {
          "$ref": "#/components/schemas/DocumentRecord"
         }
        }
       }
      }
     },
     "304": {
      "description": "Not modified (If-None-Match or If-Modified-Since matched)."
     }
    }
   }
  },
  "/catalog.jsonl": {
   "get": {
    "operationId": "catalogJsonl",
    "summary": "One JSON record per line",
    "responses": {
     "200": {
      "description": "Records",
      "headers": {
       "ETag": {
        "schema": {
         "type": "string"
        }
       },
       "Last-Modified": {
        "schema": {
         "type": "string"
        }
       },
       "Cache-Control": {
        "schema": {
         "type": "string"
        }
       }
      },
      "content": {
       "application/x-ndjson": {
        "schema": {
         "type": "string"
        }
       }
      }
     },
     "304": {
      "description": "Not modified (If-None-Match or If-Modified-Since matched)."
     }
    }
   }
  },
  "/catalog.csv": {
   "get": {
    "operationId": "catalogCsv",
    "summary": "Catalog as CSV (RFC 4180), same columns as DocumentRecord",
    "responses": {
     "200": {
      "description": "Records",
      "headers": {
       "ETag": {
        "schema": {
         "type": "string"
        }
       },
       "Last-Modified": {
        "schema": {
         "type": "string"
        }
       },
       "Cache-Control": {
        "schema": {
         "type": "string"
        }
       }
      },
      "content": {
       "text/csv": {
        "schema": {
         "type": "string"
        }
       }
      }
     },
     "304": {
      "description": "Not modified (If-None-Match or If-Modified-Since matched)."
     }
    }
   }
  },
  "/docs/{id}/file": {
   "get": {
    "operationId": "getFile",
    "summary": "Original file (PDF or spreadsheet). Supports Range requests.",
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "pattern": "^[a-z0-9]+(?:[.-][a-z0-9]+)*$",
       "maxLength": 80,
       "description": "Stable id; never changes once published."
      }
     }
    ],
    "responses": {
     "200": {
      "description": "File",
      "headers": {
       "ETag": {
        "schema": {
         "type": "string"
        }
       },
       "Last-Modified": {
        "schema": {
         "type": "string"
        }
       },
       "Cache-Control": {
        "schema": {
         "type": "string"
        }
       }
      },
      "content": {
       "application/pdf": {
        "schema": {
         "type": "string",
         "format": "binary"
        }
       },
       "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": {
        "schema": {
         "type": "string",
         "format": "binary"
        }
       }
      }
     },
     "206": {
      "description": "Partial content"
     },
     "302": {
      "description": "Redirect to the stored file"
     },
     "304": {
      "description": "Not modified (If-None-Match or If-Modified-Since matched)."
     },
     "404": {
      "description": "No such document, page or file.",
      "content": {
       "text/plain": {
        "schema": {
         "type": "string"
        }
       }
      }
     }
    }
   }
  },
  "/docs/{id}/text.txt": {
   "get": {
    "operationId": "getText",
    "summary": "Full extracted text with '=== page N ===' markers",
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "pattern": "^[a-z0-9]+(?:[.-][a-z0-9]+)*$",
       "maxLength": 80,
       "description": "Stable id; never changes once published."
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Text",
      "headers": {
       "ETag": {
        "schema": {
         "type": "string"
        }
       },
       "Last-Modified": {
        "schema": {
         "type": "string"
        }
       },
       "Cache-Control": {
        "schema": {
         "type": "string"
        }
       }
      },
      "content": {
       "text/plain": {
        "schema": {
         "type": "string"
        }
       }
      }
     },
     "304": {
      "description": "Not modified (If-None-Match or If-Modified-Since matched)."
     },
     "404": {
      "description": "No such document, page or file.",
      "content": {
       "text/plain": {
        "schema": {
         "type": "string"
        }
       }
      }
     }
    }
   }
  },
  "/docs/{id}/pages/{n}.txt": {
   "get": {
    "operationId": "getPageText",
    "summary": "Extracted text of one page, starting with its '=== page N ===' marker",
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "pattern": "^[a-z0-9]+(?:[.-][a-z0-9]+)*$",
       "maxLength": 80,
       "description": "Stable id; never changes once published."
      }
     },
     {
      "name": "n",
      "in": "path",
      "required": true,
      "schema": {
       "type": "integer",
       "minimum": 1
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Page text",
      "headers": {
       "ETag": {
        "schema": {
         "type": "string"
        }
       },
       "Last-Modified": {
        "schema": {
         "type": "string"
        }
       },
       "Cache-Control": {
        "schema": {
         "type": "string"
        }
       }
      },
      "content": {
       "text/plain": {
        "schema": {
         "type": "string"
        }
       }
      }
     },
     "304": {
      "description": "Not modified (If-None-Match or If-Modified-Since matched)."
     },
     "404": {
      "description": "No such document, page or file.",
      "content": {
       "text/plain": {
        "schema": {
         "type": "string"
        }
       }
      }
     }
    }
   }
  },
  "/llms.txt": {
   "get": {
    "operationId": "llmsTxt",
    "summary": "Guide for AI agents",
    "responses": {
     "200": {
      "description": "Guide",
      "headers": {
       "ETag": {
        "schema": {
         "type": "string"
        }
       },
       "Last-Modified": {
        "schema": {
         "type": "string"
        }
       },
       "Cache-Control": {
        "schema": {
         "type": "string"
        }
       }
      },
      "content": {
       "text/plain": {
        "schema": {
         "type": "string"
        }
       }
      }
     }
    }
   }
  },
  "/mcp": {
   "post": {
    "operationId": "mcp",
    "summary": "Model Context Protocol endpoint (Streamable HTTP, stateless, read-only tools). Send JSON-RPC 2.0 messages.",
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object"
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "JSON-RPC response",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     },
     "202": {
      "description": "Notification accepted"
     },
     "304": {
      "description": "Not modified (If-None-Match or If-Modified-Since matched)."
     },
     "403": {
      "description": "Browser origin not allowed"
     },
     "429": {
      "description": "Too many requests for this client.",
      "headers": {
       "RateLimit-Limit": {
        "schema": {
         "type": "integer"
        },
        "description": "Requests allowed per minute for this client."
       },
       "RateLimit-Remaining": {
        "schema": {
         "type": "integer"
        }
       },
       "RateLimit-Reset": {
        "schema": {
         "type": "integer"
        },
        "description": "Seconds until the window resets."
       },
       "Retry-After": {
        "schema": {
         "type": "integer"
        }
       }
      },
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "503": {
      "description": "Endpoint turned off by the site operator.",
      "headers": {
       "Retry-After": {
        "schema": {
         "type": "integer"
        }
       }
      },
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  }
 },
 "components": {
  "schemas": {
   "DocumentRecord": {
    "type": "object",
    "description": "One catalog record. Field meanings follow the library catalog schema.",
    "required": [
     "id",
     "collection",
     "title",
     "issuer",
     "document_date",
     "format",
     "official_url",
     "link_only",
     "file_url",
     "text_url"
    ],
    "properties": {
     "id": {
      "type": "string",
      "pattern": "^[a-z0-9]+(?:[.-][a-z0-9]+)*$",
      "maxLength": 80,
      "description": "Stable id; never changes once published."
     },
     "link_only": {
      "type": "boolean",
      "description": "true: not hosted here; no file or text. Follow official_url."
     },
     "collection": {
      "type": "string",
      "description": "Collection path, e.g. dod or budget/fy2027/army."
     },
     "title": {
      "type": "string",
      "description": "Title as printed on the document."
     },
     "number": {
      "type": "string",
      "description": "Number or citation as printed; empty if none."
     },
     "issuer": {
      "type": "string",
      "description": "Issuing office as named on the document."
     },
     "document_date": {
      "type": "string",
      "pattern": "^(\\d{4}(-\\d{2}(-\\d{2})?)?|undated)$",
      "description": "YYYY-MM-DD, YYYY-MM, YYYY, or 'undated'."
     },
     "document_type": {
      "type": "string"
     },
     "format": {
      "type": "string",
      "enum": [
       "pdf",
       "xlsx",
       "xls"
      ]
     },
     "official_url": {
      "type": "string",
      "description": "Issuer's own address (http/https), or 'unrecorded'. 'unrecorded' is not a link."
     },
     "copy_source": {
      "type": "string",
      "description": "official, wayback, tim-download, unrecorded, other:<name>, or empty for link-only records."
     },
     "copy_url": {
      "type": "string",
      "description": "Archive or other address used when copy_source is not official."
     },
     "retrieved_date": {
      "type": "string",
      "description": "Date the stored copy was obtained (YYYY-MM-DD); empty for link-only records."
     },
     "last_checked": {
      "type": "string",
      "description": "Last date the official URL was checked; may be empty."
     },
     "pages": {
      "type": "integer",
      "description": "Page count; 0 when not applicable or unknown."
     },
     "bytes": {
      "type": "integer",
      "description": "File size; 0 for link-only records."
     },
     "sha256": {
      "type": "string",
      "description": "SHA-256 of the hosted file; empty for link-only records."
     },
     "supersedes": {
      "type": "string",
      "description": "Semicolon-separated ids this document replaces, per the issuer."
     },
     "superseded_by": {
      "type": "string",
      "description": "Semicolon-separated ids that replace this document, per the issuer."
     },
     "status_source": {
      "type": "string",
      "description": "Where the issuer states the supersession."
     },
     "excerpt_of": {
      "type": "string",
      "description": "For a page-subset file, the id of the whole document."
     },
     "description": {
      "type": "string"
     },
     "file_url": {
      "type": "string",
      "description": "Site path of the original file, e.g. /docs/{id}/file.pdf; empty for link-only records."
     },
     "text_url": {
      "type": "string",
      "description": "Site path of the extracted text; empty when no text."
     }
    }
   },
   "SearchHit": {
    "type": "object",
    "required": [
     "document",
     "page",
     "snippet"
    ],
    "properties": {
     "document": {
      "$ref": "#/components/schemas/DocumentRecord"
     },
     "page": {
      "type": [
       "integer",
       "null"
      ],
      "description": "Page of the text match; null for a metadata match or a browse listing."
     },
     "snippet": {
      "type": "string",
      "description": "Short passage around the match, or the document description."
     }
    }
   },
   "SearchResult": {
    "type": "object",
    "required": [
     "results",
     "total",
     "offset",
     "limit"
    ],
    "properties": {
     "results": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/SearchHit"
      }
     },
     "total": {
      "type": "integer"
     },
     "offset": {
      "type": "integer"
     },
     "limit": {
      "type": "integer"
     },
     "meta": {
      "type": "object",
      "required": [
       "mode"
      ],
      "description": "How the search ran.",
      "properties": {
       "mode": {
        "type": "string",
        "enum": [
         "hybrid",
         "fulltext",
         "browse",
         "off",
         "local"
        ],
        "description": "hybrid: citation, full-text and meaning search; fulltext: citation and full-text only; browse: no query; off: search switched off; local: development index."
       },
       "note": {
        "type": "string",
        "description": "Present when search ran in a reduced mode, and why."
       }
      }
     }
    }
   },
   "Citation": {
    "type": "object",
    "required": [
     "doc",
     "page",
     "quote"
    ],
    "properties": {
     "doc": {
      "type": "string",
      "description": "Library document id."
     },
     "page": {
      "type": "integer",
      "description": "PDF page position (the '=== page N ===' marker)."
     },
     "quote": {
      "type": "string",
      "description": "Exact words on that page."
     }
    }
   },
   "Appropriation": {
    "type": "object",
    "description": "One cheat sheet entry exactly as the library publishes it (treasury_code, short_name, title, service, component, category, verified, aliases, identity_cite, plain_explanation, period_of_availability, typical_uses, examples, not_for, budget_activities with sags, notes). Every line lists citation keys in 'cite'.",
    "additionalProperties": true
   },
   "AppropriationsResponse": {
    "type": "object",
    "required": [
     "query",
     "total",
     "version",
     "appropriations",
     "citations",
     "citation_urls"
    ],
    "properties": {
     "query": {
      "type": "string"
     },
     "total": {
      "type": "integer"
     },
     "title": {
      "type": "string"
     },
     "version": {
      "type": "string"
     },
     "fiscal_year_basis": {
      "type": "string"
     },
     "page_numbers": {
      "type": "string"
     },
     "advice": {
      "type": "string"
     },
     "appropriations": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/Appropriation"
      }
     },
     "citations": {
      "type": "object",
      "additionalProperties": {
       "$ref": "#/components/schemas/Citation"
      }
     },
     "citation_urls": {
      "type": "object",
      "additionalProperties": {
       "type": "string"
      },
      "description": "Citation key to a link: the hosted PDF at that page, else the document record."
     }
    }
   },
   "AppropriationResponse": {
    "type": "object",
    "required": [
     "version",
     "appropriation",
     "citations",
     "citation_urls"
    ],
    "properties": {
     "version": {
      "type": "string"
     },
     "fiscal_year_basis": {
      "type": "string"
     },
     "advice": {
      "type": "string"
     },
     "appropriation": {
      "$ref": "#/components/schemas/Appropriation"
     },
     "citations": {
      "type": "object",
      "additionalProperties": {
       "$ref": "#/components/schemas/Citation"
      }
     },
     "citation_urls": {
      "type": "object",
      "additionalProperties": {
       "type": "string"
      }
     }
    }
   },
   "LibraryStats": {
    "type": "object",
    "required": [
     "documents",
     "pages",
     "collections",
     "generated"
    ],
    "properties": {
     "documents": {
      "type": "integer"
     },
     "pages": {
      "type": "integer"
     },
     "collections": {
      "type": "integer"
     },
     "generated": {
      "type": "string",
      "description": "Date the library build was generated."
     }
    }
   },
   "CatalogResponse": {
    "type": "object",
    "required": [
     "stats",
     "documents"
    ],
    "properties": {
     "stats": {
      "$ref": "#/components/schemas/LibraryStats"
     },
     "documents": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/DocumentRecord"
      }
     }
    }
   },
   "Collection": {
    "type": "object",
    "required": [
     "id",
     "label",
     "documents",
     "pages"
    ],
    "properties": {
     "id": {
      "type": "string"
     },
     "label": {
      "type": "string"
     },
     "documents": {
      "type": "integer"
     },
     "pages": {
      "type": "integer"
     }
    }
   },
   "CollectionsResponse": {
    "type": "object",
    "required": [
     "collections",
     "groups"
    ],
    "properties": {
     "collections": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/Collection"
      }
     },
     "groups": {
      "type": "array",
      "items": {
       "type": "object",
       "required": [
        "id",
        "label",
        "collections"
       ],
       "properties": {
        "id": {
         "type": "string"
        },
        "label": {
         "type": "string"
        },
        "collections": {
         "type": "array",
         "items": {
          "type": "string"
         }
        }
       }
      }
     }
    }
   },
   "Error": {
    "type": "object",
    "required": [
     "error"
    ],
    "properties": {
     "error": {
      "type": "string"
     }
    }
   }
  }
 }
}