{
  "openapi": "3.1.0",
  "info": {
    "title": "Pressline Autonomous Content Engineering Engine API",
    "version": "3.2.0",
    "description": "Enterprise API for autonomous 8-agent publishing, ground-truth fact verification, mathematical cash-flow reconciliation, and deterministic SVG cover generation.",
    "contact": {
      "name": "Huzaifa Malik (Principal AI Systems Architect)",
      "email": "exhuzaifa@gmail.com",
      "url": "https://pressline.vercel.app/contact"
    },
    "license": {
      "name": "Proprietary",
      "url": "https://pressline.vercel.app/terms"
    }
  },
  "servers": [
    {
      "url": "https://pressline.vercel.app",
      "description": "Production Cloud Vercel Infrastructure"
    },
    {
      "url": "https://pressline.unicorn-realtors.com",
      "description": "Production Edge Hostinger Infrastructure"
    }
  ],
  "paths": {
    "/api/mcp": {
      "get": {
        "summary": "MCP Server Manifest & Capability Discovery",
        "operationId": "getMcpManifest",
        "description": "Returns Model Context Protocol (MCP) streamable HTTP capabilities, tool schemas, and server metadata.",
        "responses": {
          "200": {
            "description": "MCP Manifest and active tools",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/McpManifest" }
              }
            }
          }
        }
      },
      "post": {
        "summary": "Model Context Protocol JSON-RPC Execution",
        "operationId": "executeMcpJsonRpc",
        "description": "Executes JSON-RPC 2.0 MCP protocol methods including initialize, tools/list, and tools/call.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/JsonRpcRequest" }
            }
          }
        },
        "responses": {
          "200": {
            "description": "JSON-RPC 2.0 response",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/JsonRpcResponse" }
              }
            }
          },
          "400": {
            "description": "Invalid JSON-RPC request",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ErrorResponse" }
              }
            }
          }
        }
      }
    },
    "/api/knowledge-base/query": {
      "get": {
        "summary": "Query Ground Truth Knowledge Base",
        "operationId": "queryKnowledgeBase",
        "description": "Searches verified regulatory rules, FBR tax schedules, LDA master plans, and developer pricing matrices.",
        "parameters": [
          {
            "name": "query",
            "in": "query",
            "required": true,
            "description": "Search term, property name, or statutory rule",
            "schema": { "type": "string" }
          },
          {
            "name": "category",
            "in": "query",
            "required": false,
            "description": "Optional category filter",
            "schema": { "type": "string" }
          }
        ],
        "responses": {
          "200": {
            "description": "Matching ground truth records",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/KnowledgeBaseResult" }
              }
            }
          },
          "404": {
            "description": "No records found",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ErrorResponse" }
              }
            }
          }
        }
      }
    },
    "/api/critic/audit": {
      "post": {
        "summary": "Audit Article Draft with Critic v5",
        "operationId": "auditArticleDraft",
        "description": "Executes pre-publish fact checking, tax law disambiguation (Section 236K vs 155), and payment table mathematical reconciliation on draft HTML.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "html": { "type": "string", "description": "Raw HTML article draft" },
                  "topic": { "type": "string", "description": "Topic headline" },
                  "category": { "type": "string", "description": "Target publishing category" }
                },
                "required": ["html", "topic"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Audit scorecard and mathematical verification",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/AuditScorecard" }
              }
            }
          },
          "422": {
            "description": "Audit failed with critical defects",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/AuditFailure" }
              }
            }
          }
        }
      }
    },
    "/api/graphics/cover": {
      "post": {
        "summary": "Generate Native 16:9 Branded SVG Cover",
        "operationId": "generateCoverGraphic",
        "description": "Compiles a lightweight (<6KB) inline vector SVG graphic matching brand design tokens with category badge and title typography.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "title": { "type": "string", "description": "Headline text" },
                  "category": { "type": "string", "description": "Post category" },
                  "author": { "type": "string", "description": "Author name", "default": "Huzaifa Malik" }
                },
                "required": ["title", "category"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Generated SVG cover payload",
            "content": {
              "image/svg+xml": {
                "schema": { "type": "string" }
              },
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "svg": { "type": "string" },
                    "byteLength": { "type": "integer" }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/pipeline/run": {
      "post": {
        "summary": "Trigger Autonomous Publishing Pipeline Run",
        "operationId": "runPublishingPipeline",
        "description": "Initiates an end-to-end publishing cycle from trend discovery, blueprint drafting, neural humanization, critic gatekeeper, SVG generation, and static server deployment.",
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "autoDeploy": { "type": "boolean", "default": true },
                  "forceCategory": { "type": "string" },
                  "forceTopic": { "type": "string" }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Pipeline execution results",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": { "type": "boolean" },
                    "slug": { "type": "string" },
                    "title": { "type": "string" },
                    "durationSeconds": { "type": "number" },
                    "zeroGptScore": { "type": "number" },
                    "publishedUrl": { "type": "string" }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Pipeline execution error",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ErrorResponse" }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "JsonRpcRequest": {
        "type": "object",
        "properties": {
          "jsonrpc": { "type": "string", "enum": ["2.0"] },
          "id": { "oneOf": [{ "type": "string" }, { "type": "integer" }] },
          "method": { "type": "string" },
          "params": { "type": "object" }
        },
        "required": ["jsonrpc", "method"]
      },
      "JsonRpcResponse": {
        "type": "object",
        "properties": {
          "jsonrpc": { "type": "string", "enum": ["2.0"] },
          "id": { "oneOf": [{ "type": "string" }, { "type": "integer" }, { "type": "null" }] },
          "result": { "type": "object" },
          "error": {
            "type": "object",
            "properties": {
              "code": { "type": "integer" },
              "message": { "type": "string" }
            }
          }
        },
        "required": ["jsonrpc"]
      },
      "McpManifest": {
        "type": "object",
        "properties": {
          "name": { "type": "string" },
          "version": { "type": "string" },
          "protocol": { "type": "string" },
          "status": { "type": "string" },
          "capabilities": { "type": "object" }
        }
      },
      "KnowledgeBaseResult": {
        "type": "object",
        "properties": {
          "query": { "type": "string" },
          "matches": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "key": { "type": "string" },
                "verifiedValue": { "type": "string" },
                "source": { "type": "string" }
              }
            }
          }
        }
      },
      "AuditScorecard": {
        "type": "object",
        "properties": {
          "passed": { "type": "boolean" },
          "predictedZeroGptScore": { "type": "number" },
          "mathReconciled": { "type": "boolean" },
          "taxDisambiguated": { "type": "boolean" },
          "wordCount": { "type": "integer" }
        }
      },
      "AuditFailure": {
        "type": "object",
        "properties": {
          "passed": { "type": "boolean", "enum": [false] },
          "reasons": {
            "type": "array",
            "items": { "type": "string" }
          }
        }
      },
      "ErrorResponse": {
        "type": "object",
        "properties": {
          "error": {
            "type": "object",
            "properties": {
              "code": { "type": "string" },
              "message": { "type": "string" },
              "resolution": { "type": "string" },
              "documentation_url": { "type": "string" },
              "status": { "type": "integer" }
            },
            "required": ["code", "message"]
          }
        },
        "required": ["error"]
      }
    }
  }
}
