{
  "openapi": "3.1.0",
  "info": {
    "title": "Tape Engine",
    "version": "1.3.0",
    "description": "Create SOPs, lead magnets, workbooks, checklists, playbooks, guides and books: outline, write, design covers and export PDFs.",
    "x-logo": { "url": "https://tapeengine.com/TAPE_APP_ICON.png" }
  },
  "servers": [{ "url": "https://tapeengine.com/api/gpt" }],
  "components": {
    "securitySchemes": { "apiKey": { "type": "http", "scheme": "bearer" } },
    "schemas": {
      "Result": { "type": "object", "additionalProperties": true }
    }
  },
  "security": [{ "apiKey": [] }],
  "paths": {
    "/create_digital_product": {
      "post": {
        "operationId": "createDigitalProduct",
        "summary": "Create a digital product (SOP, lead magnet, workbook, checklist, playbook, guide). Returns the project id.",
        "requestBody": { "required": true, "content": { "application/json": { "schema": {
          "type": "object",
          "required": ["title", "niche"],
          "properties": {
            "title": { "type": "string" },
            "niche": { "type": "string" },
            "subtitle": { "type": "string" },
            "description": { "type": "string" },
            "product_type": { "type": "string", "enum": ["sop", "lead_magnet", "workbook", "checklist", "playbook", "guide"] },
            "num_chapters": { "type": "number", "description": "Number of sections" },
            "author_name": { "type": "string" }
          }
        } } } },
        "responses": { "200": { "description": "Created", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Result" } } } } }
      }
    },
    "/generate_outline": {
      "post": {
        "operationId": "generateOutline",
        "summary": "Generate the section outline for a project.",
        "requestBody": { "required": true, "content": { "application/json": { "schema": {
          "type": "object",
          "required": ["project_id", "niche"],
          "properties": {
            "project_id": { "type": "string" },
            "niche": { "type": "string" },
            "chapter_count": { "type": "number" },
            "book_idea": { "type": "string" }
          }
        } } } },
        "responses": { "200": { "description": "Outline", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Result" } } } } }
      }
    },
    "/write_book": {
      "post": {
        "operationId": "writeSection",
        "summary": "Write one section/chapter. Call once per section. May return a job_id to poll with getJob.",
        "requestBody": { "required": true, "content": { "application/json": { "schema": {
          "type": "object",
          "required": ["project_id", "chapter_number"],
          "properties": {
            "project_id": { "type": "string" },
            "chapter_number": { "type": "number" },
            "chapter_title": { "type": "string" }
          }
        } } } },
        "responses": { "200": { "description": "Section written or job started", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Result" } } } } }
      }
    },
    "/generate_cover": {
      "post": {
        "operationId": "generateCover",
        "summary": "Generate cover or product mockup artwork for a project.",
        "requestBody": { "required": true, "content": { "application/json": { "schema": {
          "type": "object",
          "required": ["project_id"],
          "properties": {
            "project_id": { "type": "string" },
            "prompt": { "type": "string" },
            "style": { "type": "string" }
          }
        } } } },
        "responses": { "200": { "description": "Cover", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Result" } } } } }
      }
    },
    "/export_pdf": {
      "post": {
        "operationId": "exportPdf",
        "summary": "Export a finished project to PDF and return a download link.",
        "requestBody": { "required": true, "content": { "application/json": { "schema": {
          "type": "object", "required": ["project_id"], "properties": { "project_id": { "type": "string" } }
        } } } },
        "responses": { "200": { "description": "Export", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Result" } } } } }
      }
    },
    "/get_job": {
      "post": {
        "operationId": "getJob",
        "summary": "Check progress of a long-running job.",
        "requestBody": { "required": true, "content": { "application/json": { "schema": {
          "type": "object", "required": ["job_id"], "properties": { "job_id": { "type": "string" } }
        } } } },
        "responses": { "200": { "description": "Job status", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Result" } } } } }
      }
    },
    "/list_projects": {
      "post": {
        "operationId": "listProjects",
        "summary": "List the user's projects.",
        "requestBody": { "required": false, "content": { "application/json": { "schema": { "type": "object", "properties": {} } } } },
        "responses": { "200": { "description": "Projects", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Result" } } } } }
      }
    },
    "/get_project": {
      "post": {
        "operationId": "getProject",
        "summary": "Get one project with its outline and sections.",
        "requestBody": { "required": true, "content": { "application/json": { "schema": {
          "type": "object", "required": ["project_id"], "properties": { "project_id": { "type": "string" } }
        } } } },
        "responses": { "200": { "description": "Project", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Result" } } } } }
      }
    }
  }
}
