{
  "openapi": "3.1.0",
  "info": {
    "title": "AuthorPage Public API",
    "version": "1.0.0",
    "summary": "Public, unauthenticated endpoints for AuthorPage, the website builder for indie authors.",
    "description": "This spec covers the public surface of the AuthorPage API at https://api.authorpage.me. Account-scoped endpoints (website management, publishing, billing) require an authenticated AuthorPage session and are documented in the full spec at https://api.authorpage.me/openapi.json. There is no public API key program yet — agents can read site content in markdown (https://authorpage.me/llms.txt) and use the endpoints below. An authenticated MCP server is available at https://api.authorpage.me/mcp.",
    "contact": {
      "name": "AuthorPage support",
      "email": "sekar@authorpage.me",
      "url": "https://authorpage.me/s/contact/"
    },
    "termsOfService": "https://authorpage.me/terms-of-service/"
  },
  "externalDocs": {
    "description": "Developer and agent documentation",
    "url": "https://authorpage.me/s/docs/"
  },
  "servers": [
    {
      "url": "https://api.authorpage.me",
      "description": "Production API"
    }
  ],
  "paths": {
    "/health": {
      "get": {
        "summary": "API health check",
        "operationId": "health",
        "tags": ["public"],
        "responses": {
          "200": {
            "description": "The API is up.",
            "content": {
              "application/json": {
                "schema": { "type": "object" }
              }
            }
          }
        }
      }
    },
    "/public/health": {
      "get": {
        "summary": "Public health check",
        "operationId": "publicHealth",
        "tags": ["public"],
        "responses": {
          "200": {
            "description": "The public API surface is up.",
            "content": {
              "application/json": {
                "schema": { "type": "object" }
              }
            }
          }
        }
      }
    },
    "/public/preview-author": {
      "post": {
        "summary": "Preview an author website from an Amazon Author Central URL",
        "description": "Creates a temporary (1-hour) preview session for an unauthenticated user by scraping the author's Amazon Author Central home page. Protected by Cloudflare Turnstile and rate limiting (3/minute, 10/hour per IP), so it is not directly callable by headless agents — send users to https://app.authorpage.me/get-started instead.",
        "operationId": "previewAuthor",
        "tags": ["public"],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["amazon_url", "turnstile_token"],
                "properties": {
                  "amazon_url": {
                    "type": "string",
                    "format": "uri",
                    "description": "Amazon Author Central profile URL"
                  },
                  "turnstile_token": {
                    "type": "string",
                    "description": "Cloudflare Turnstile token proving a human submitted the form"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Preview session created; returns session id and preview data.",
            "content": { "application/json": { "schema": { "type": "object" } } }
          },
          "422": { "description": "Validation error" },
          "429": { "description": "Rate limit exceeded" }
        }
      }
    },
    "/newsletter/{newsletter_id}/subscribe": {
      "post": {
        "summary": "Subscribe to an author's newsletter",
        "description": "Public double-opt-in subscription endpoint used by newsletter forms on published author sites. Creates the subscriber as pending and sends a confirmation email. Rate limited (5/minute, 20/hour per IP) with Turnstile and honeypot bot protection. Intended for author-site forms rather than direct agent calls.",
        "operationId": "subscribeToNewsletter",
        "tags": ["newsletter"],
        "parameters": [
          {
            "name": "newsletter_id",
            "in": "path",
            "required": true,
            "schema": { "type": "string" },
            "description": "Hashed newsletter identifier from the author's site"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["email"],
                "properties": {
                  "email": { "type": "string", "format": "email" }
                }
              }
            }
          }
        },
        "responses": {
          "200": { "description": "Subscription created as pending; confirmation email sent." },
          "422": { "description": "Validation error" },
          "429": { "description": "Rate limit exceeded" }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "sessionAuth": {
        "type": "apiKey",
        "in": "cookie",
        "name": "session",
        "description": "Account-scoped endpoints (see https://api.authorpage.me/openapi.json) use an AuthorPage session established via Google sign-in at https://app.authorpage.me. There is no public API key program yet."
      }
    }
  }
}
