{
  "openapi": "3.1.0",
  "info": {
    "title": "SursaTech Public API",
    "version": "1.0.0",
    "description": "Public surface for SursaTech: visitor chat and agent-to-agent exchange. All responses are grounded in /company-context.json.",
    "contact": {
      "name": "SursaTech",
      "email": "info@sursatech.com",
      "url": "https://www.sursatech.com"
    }
  },
  "servers": [
    { "url": "https://www.sursatech.com", "description": "Production" }
  ],
  "paths": {
    "/api/chat": {
      "post": {
        "summary": "Visitor chat",
        "description": "Accepts a free-form visitor message and returns a grounded answer card.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/ChatRequest" }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Grounded answer card",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/AnswerCard" }
              }
            }
          }
        }
      }
    },
    "/api/agent/query": {
      "post": {
        "summary": "Agent question",
        "description": "Read-only natural-language query from an external agent.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/AgentQueryRequest" }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Grounded answer with sources",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/AgentQueryResponse" }
              }
            }
          }
        }
      }
    },
    "/api/agent/exchange": {
      "post": {
        "summary": "Agent structured exchange",
        "description": "Structured intent exchange between external agents and SursaTech.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/AgentExchangeRequest" }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Structured response keyed by intent",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/AgentExchangeResponse" }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "ChatRequest": {
        "type": "object",
        "required": ["message"],
        "properties": {
          "message": { "type": "string", "description": "Visitor message" }
        }
      },
      "AnswerCard": {
        "type": "object",
        "required": ["title", "answer"],
        "properties": {
          "title": { "type": "string" },
          "answer": { "type": "string" },
          "items": { "type": "array", "items": { "type": "string" } },
          "action": {
            "type": "object",
            "properties": {
              "label": { "type": "string" },
              "href": { "type": "string", "format": "uri" }
            }
          },
          "source": { "type": "string" }
        }
      },
      "AgentQueryRequest": {
        "type": "object",
        "required": ["question"],
        "properties": {
          "requestId": { "type": "string" },
          "agent": {
            "type": "object",
            "properties": {
              "id": { "type": "string" },
              "name": { "type": "string" }
            }
          },
          "question": { "type": "string" }
        }
      },
      "AgentQueryResponse": {
        "type": "object",
        "properties": {
          "requestId": { "type": "string" },
          "status": { "type": "string", "enum": ["ok", "out_of_scope", "error"] },
          "answer": { "type": "string" },
          "sources": { "type": "array", "items": { "type": "string" } },
          "confidence": { "type": "number" },
          "updatedAt": { "type": "string", "format": "date" }
        }
      },
      "AgentExchangeRequest": {
        "type": "object",
        "required": ["intent"],
        "properties": {
          "requestId": { "type": "string" },
          "agent": {
            "type": "object",
            "properties": {
              "id": { "type": "string" },
              "name": { "type": "string" }
            }
          },
          "intent": {
            "type": "string",
            "enum": [
              "company.profile",
              "company.services",
              "company.products",
              "company.booking",
              "company.engagements"
            ]
          },
          "input": { "type": "object", "additionalProperties": true }
        }
      },
      "AgentExchangeResponse": {
        "type": "object",
        "properties": {
          "requestId": { "type": "string" },
          "status": { "type": "string", "enum": ["ok", "unsupported_intent", "error"] },
          "data": { "type": "object", "additionalProperties": true },
          "source": { "type": "string" },
          "updatedAt": { "type": "string", "format": "date" }
        }
      }
    }
  }
}
