{
  "openapi": "3.1.0",
  "info": {
    "title": "The Even Table Public Pages API",
    "version": "1.0.0",
    "description": "Read-only search and retrieval for the site's published, canonical public pages. No account, write, or arbitrary URL fetch is available."
  },
  "servers": [
    {
      "url": "https://theeventable.com"
    }
  ],
  "components": {
    "schemas": {
      "PageSummary": {
        "type": "object",
        "required": [
          "id",
          "title",
          "source_url",
          "description",
          "snippet"
        ],
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^[a-z0-9-]+$"
          },
          "title": {
            "type": "string"
          },
          "source_url": {
            "type": "string",
            "format": "uri",
            "pattern": "^https://theeventable\\.com/"
          },
          "description": {
            "type": "string"
          },
          "snippet": {
            "type": "string",
            "maxLength": 320
          }
        },
        "additionalProperties": false
      },
      "SearchResponse": {
        "type": "object",
        "required": [
          "query",
          "limit",
          "results"
        ],
        "properties": {
          "query": {
            "type": "string"
          },
          "limit": {
            "type": "integer",
            "const": 8
          },
          "results": {
            "type": "array",
            "maxItems": 8,
            "items": {
              "$ref": "#/components/schemas/PageSummary"
            }
          }
        }
      },
      "PageResponse": {
        "allOf": [
          {
            "$ref": "#/components/schemas/PageSummary"
          },
          {
            "type": "object",
            "required": [
              "content_type",
              "content",
              "generated_from_published_page_at"
            ],
            "properties": {
              "content_type": {
                "const": "text/markdown"
              },
              "content": {
                "type": "string"
              },
              "generated_from_published_page_at": {
                "type": "string",
                "format": "date-time"
              }
            }
          }
        ]
      },
      "Error": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "string"
          },
          "example": {
            "type": "string"
          }
        }
      },
      "HealthResponse": {
        "type": "object",
        "required": [
          "status",
          "service",
          "generated_at"
        ],
        "properties": {
          "status": {
            "const": "ok"
          },
          "service": {
            "const": "published-public-pages"
          },
          "generated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      }
    }
  },
  "paths": {
    "/api/health": {
      "get": {
        "operationId": "getPublicPagesHealth",
        "summary": "Check availability of the read-only public pages API",
        "responses": {
          "200": {
            "description": "The public page lookup is available.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HealthResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/public-pages": {
      "get": {
        "operationId": "findPublicPages",
        "summary": "Search published public pages",
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "required": true,
            "description": "Searches titles, descriptions, and extracted text from pages in the current public sitemap.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 120
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Up to eight matching pages, with stable IDs and source URLs.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SearchResponse"
                }
              }
            }
          },
          "400": {
            "description": "Missing or invalid query.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/public-pages/{id}": {
      "get": {
        "operationId": "readPublicPage",
        "summary": "Read a published page as Markdown",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Stable ID from the public sitemap path (home page ID is home).",
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9-]+$",
              "maxLength": 180
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Page metadata and source-derived Markdown content.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PageResponse"
                }
              }
            }
          },
          "404": {
            "description": "No published page has this ID.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  }
}
