{
  "openapi": "3.1.0",
  "info": {
    "title": "Cacerola OS API",
    "version": "1.0.0",
    "description": "API pública de Cacerola: auditoría de dominios, catálogo de skills de growth open-source, e intake de leads. Servidor MCP disponible en /mcp.",
    "contact": {
      "name": "Cacerola Growth Marketing",
      "email": "cocina@cacerola.cl",
      "url": "https://cacerola.cl"
    },
    "license": {
      "name": "MIT",
      "url": "https://opensource.org/licenses/MIT"
    }
  },
  "servers": [
    {
      "url": "https://cacerola.cl"
    }
  ],
  "externalDocs": {
    "description": "llms.txt",
    "url": "https://cacerola.cl/llms.txt"
  },
  "paths": {
    "/api/health": {
      "get": {
        "operationId": "health",
        "summary": "Health check",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "text/plain": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    },
    "/api/audit": {
      "get": {
        "operationId": "auditDomain",
        "summary": "Audita un dominio (SEO, GEO/IA-ready, técnico, growth)",
        "parameters": [
          {
            "name": "domain",
            "in": "query",
            "required": true,
            "description": "Dominio a auditar, por ejemplo acme.com",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Resultado de la auditoría",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AuditResult"
                }
              }
            }
          },
          "400": {
            "description": "Falta el parámetro domain"
          },
          "422": {
            "description": "No se pudo auditar el dominio"
          }
        }
      }
    },
    "/api/skills": {
      "get": {
        "operationId": "listSkills",
        "summary": "Catálogo de skills de growth open-source",
        "responses": {
          "200": {
            "description": "Lista de skills",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SkillList"
                }
              }
            }
          }
        }
      }
    },
    "/api/diagnostic": {
      "post": {
        "operationId": "submitDiagnostic",
        "summary": "Registra un lead de diagnóstico de growth",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "industry",
                  "name",
                  "email",
                  "websiteUrl",
                  "privacyConsent"
                ],
                "properties": {
                  "industry": {
                    "type": "string"
                  },
                  "name": {
                    "type": "string"
                  },
                  "email": {
                    "type": "string",
                    "format": "email"
                  },
                  "websiteUrl": {
                    "type": "string"
                  },
                  "privacyConsent": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Lead registrado"
          },
          "400": {
            "description": "Datos inválidos"
          }
        }
      }
    },
    "/api/roi": {
      "post": {
        "operationId": "submitRoi",
        "summary": "Registra un lead de la calculadora de ROI",
        "responses": {
          "200": {
            "description": "Lead registrado"
          },
          "400": {
            "description": "Datos inválidos"
          }
        }
      }
    },
    "/api/waitlist": {
      "post": {
        "operationId": "joinWaitlist",
        "summary": "Suma un email a la lista de espera del dashboard",
        "responses": {
          "200": {
            "description": "Registrado"
          },
          "400": {
            "description": "Datos inválidos"
          }
        }
      }
    },
    "/mcp": {
      "post": {
        "operationId": "mcp",
        "summary": "Servidor MCP (Model Context Protocol) sobre HTTP. Tools: audit_domain, list_skills.",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "description": "Mensaje JSON-RPC 2.0 de MCP"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Respuesta JSON-RPC 2.0"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Check": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "label": {
            "type": "string"
          },
          "sev": {
            "type": "string",
            "enum": [
              "critical",
              "warning",
              "ok"
            ]
          },
          "detail": {
            "type": "string"
          }
        }
      },
      "CategoryScore": {
        "type": "object",
        "properties": {
          "key": {
            "type": "string",
            "enum": [
              "seo",
              "geo",
              "growth",
              "perf"
            ]
          },
          "label": {
            "type": "string"
          },
          "score": {
            "type": "integer"
          },
          "checks": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Check"
            }
          }
        }
      },
      "AuditResult": {
        "type": "object",
        "properties": {
          "ok": {
            "type": "boolean"
          },
          "domain": {
            "type": "string"
          },
          "finalUrl": {
            "type": "string"
          },
          "fetchedAt": {
            "type": "string",
            "format": "date-time"
          },
          "title": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "score": {
            "type": "integer"
          },
          "grade": {
            "type": "string",
            "enum": [
              "A",
              "B",
              "C",
              "D",
              "F"
            ]
          },
          "categories": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CategoryScore"
            }
          },
          "quickWins": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "SkillList": {
        "type": "object",
        "properties": {
          "repo": {
            "type": "string"
          },
          "license": {
            "type": "string"
          },
          "count": {
            "type": "integer"
          },
          "skills": {
            "type": "array",
            "items": {
              "type": "object"
            }
          }
        }
      }
    }
  }
}