{
  "openapi": "3.1.0",
  "info": {
    "title": "Penn Relations API",
    "version": "0.1.0",
    "description": "Penn Relations is an agent-first PR system. Most callers should use the MCP server transport at https://pr.capitalfactory.com/mcp — it exposes typed tools with full schema. This OpenAPI is provided for HTTP-only clients that can't speak MCP.",
    "contact": {
      "name": "Penn Relations",
      "email": "press@capitalfactory.com",
      "url": "https://pennrelations.com"
    }
  },
  "servers": [
    {
      "url": "https://pr.capitalfactory.com",
      "description": "Production (current — pre-domain-migration)"
    }
  ],
  "paths": {
    "/health": {
      "get": {
        "summary": "Liveness + mode probe",
        "responses": {
          "200": {
            "description": "ok",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": { "type": "boolean" },
                    "schema_version": { "type": "string" },
                    "mode": { "type": "string", "enum": ["shadow", "internal", "live"] },
                    "mode_source": { "type": "string" }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/mcp": {
      "post": {
        "summary": "MCP JSON-RPC transport (streamable HTTP)",
        "description": "Primary integration surface. Speak MCP 2026-03-01. See /.well-known/mcp/server.json for discovery.",
        "security": [{ "bearerAuth": [] }],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/JsonRpcRequest" }
            }
          }
        },
        "responses": {
          "200": {
            "description": "JSON-RPC response",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/JsonRpcResponse" }
              }
            }
          }
        }
      }
    },
    "/postmark-inbound": {
      "post": {
        "summary": "Postmark inbound webhook",
        "description": "Internal — receives parsed inbound email from Postmark. Not for direct agent use. Authenticated by Postmark Basic Auth.",
        "security": [{ "postmarkBasic": [] }],
        "responses": {
          "200": { "description": "Inbound accepted, async dispatched" },
          "401": { "description": "Auth failed" }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "penn_<43char>"
      },
      "postmarkBasic": {
        "type": "http",
        "scheme": "basic"
      }
    },
    "schemas": {
      "JsonRpcRequest": {
        "type": "object",
        "required": ["jsonrpc", "id", "method"],
        "properties": {
          "jsonrpc": { "type": "string", "enum": ["2.0"] },
          "id": { "oneOf": [{ "type": "string" }, { "type": "number" }] },
          "method": { "type": "string", "description": "MCP method — e.g. 'tools/list', 'tools/call'" },
          "params": { "type": "object" }
        }
      },
      "JsonRpcResponse": {
        "type": "object",
        "required": ["jsonrpc", "id"],
        "properties": {
          "jsonrpc": { "type": "string", "enum": ["2.0"] },
          "id": { "oneOf": [{ "type": "string" }, { "type": "number" }] },
          "result": {},
          "error": {
            "type": "object",
            "properties": {
              "code": { "type": "integer" },
              "message": { "type": "string" }
            }
          }
        }
      }
    }
  }
}
