{
  "openapi": "3.1.0",
  "info": {
    "title": "Horix Public API",
    "version": "1.0.0",
    "description": "Public contact and subscription request endpoints used by the Horix marketing site."
  },
  "servers": [
    {
      "url": "https://bo.myhorix.com"
    }
  ],
  "paths": {
    "/api/subscription-requests": {
      "post": {
        "summary": "Create a free trial request",
        "operationId": "createSubscriptionRequest",
        "security": [
          {
            "HorixOAuth": [
              "horix:write"
            ]
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SubscriptionRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Request accepted"
          },
          "422": {
            "description": "Validation error"
          }
        }
      }
    },
    "/api/contact-support": {
      "post": {
        "summary": "Send a contact or support request",
        "operationId": "createContactSupportRequest",
        "security": [
          {
            "HorixOAuth": [
              "horix:write"
            ]
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ContactSupportRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Request accepted"
          },
          "422": {
            "description": "Validation error"
          }
        }
      }
    },
    "/api/health": {
      "get": {
        "summary": "API health check",
        "operationId": "getHealth",
        "security": [
          {
            "HorixOAuth": [
              "horix:read"
            ]
          }
        ],
        "responses": {
          "200": {
            "description": "API is healthy"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "HorixOAuth": {
        "type": "oauth2",
        "description": "OAuth 2.0 authorization server for Horix protected API access. Agents can discover protected resource metadata at https://bo.myhorix.com/.well-known/oauth-protected-resource.",
        "flows": {
          "authorizationCode": {
            "authorizationUrl": "https://bo.myhorix.com/oauth/authorize",
            "tokenUrl": "https://bo.myhorix.com/oauth/token",
            "scopes": {
              "horix:read": "Read Horix protected API resources.",
              "horix:write": "Create or update Horix protected API resources."
            }
          },
          "clientCredentials": {
            "tokenUrl": "https://bo.myhorix.com/oauth/token",
            "scopes": {
              "horix:read": "Read Horix protected API resources.",
              "horix:write": "Create or update Horix protected API resources."
            }
          }
        }
      }
    },
    "schemas": {
      "SubscriptionRequest": {
        "type": "object",
        "required": ["company_name", "contact_name", "email", "phone", "form_started_at"],
        "properties": {
          "company_name": { "type": "string" },
          "contact_name": { "type": "string" },
          "email": { "type": "string", "format": "email" },
          "phone": { "type": "string" },
          "employees": { "type": ["integer", "null"] },
          "message": { "type": ["string", "null"] },
          "language": { "type": "string", "enum": ["es", "en"] },
          "website": { "type": "string", "description": "Honeypot anti-spam; debe enviarse vacío." },
          "form_started_at": { "type": "integer", "description": "Timestamp Unix, en segundos, del momento en que se mostró el formulario." }
        }
      },
      "ContactSupportRequest": {
        "type": "object",
        "required": ["name", "company", "email", "category", "form_started_at"],
        "properties": {
          "name": { "type": "string" },
          "company": { "type": "string" },
          "email": { "type": "string", "format": "email" },
          "phone": { "type": ["string", "null"] },
          "category": { "type": "string", "enum": ["Cotización white-label", "Demo personalizada", "Ayuda con tu cuenta", "Facturación", "Privacidad o datos", "Otro"] },
          "message": { "type": ["string", "null"] },
          "instance_url": { "type": ["string", "null"] },
          "billing_reference": { "type": ["string", "null"] },
          "privacy_request_type": { "type": ["string", "null"] },
          "website": { "type": "string", "description": "Honeypot anti-spam; debe enviarse vacío." },
          "form_started_at": { "type": "integer", "description": "Timestamp Unix, en segundos, del momento en que se mostró el formulario." }
        }
      }
    }
  }
}
