{
  "openapi": "3.1.0",
  "info": {
    "title": "OSON Quote Request API",
    "version": "1.1.0",
    "description": "API for creating quote requests for OSON, a dedicated CRM, task and automation system for small and medium businesses."
  },
  "servers": [
    {
      "url": "https://oson.ro"
    }
  ],
  "paths": {
    "/api/quote/": {
      "post": {
        "operationId": "createQuoteRequest",
        "summary": "Create a quote request for OSON",
        "description": "Creates a new quote request. Requires server-side Bearer token. Do not call from browser clients.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Unique key to safely retry the same request without creating duplicates."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/QuoteRequestCreate"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Quote request created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/QuoteRequestResponse"
                }
              }
            }
          },
          "200": {
            "description": "Idempotent replay of an existing request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/QuoteRequestResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error"
          },
          "403": {
            "description": "Unauthorized"
          },
          "409": {
            "description": "Duplicate request in time window"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/quote/public/": {
      "post": {
        "operationId": "createPublicQuoteRequest",
        "summary": "Create a quote request (anonymous LLM agents, no token)",
        "description": "Public endpoint for agents that read llms.txt. No Bearer auth. Strict rate limit (3/IP/hour). Sets is_public_submission. Hidden website field is a honeypot.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PublicQuoteRequestCreate"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Quote request created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/QuoteRequestResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error or invalid source"
          },
          "409": {
            "description": "Duplicate request in time window"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "Server-side API token issued by OSON. Never embed in public pages or llms.txt."
      }
    },
    "schemas": {
      "QuoteRequestCreate": {
        "type": "object",
        "required": ["name", "company", "email", "project_needs", "privacy_consent"],
        "properties": {
          "name": { "type": "string" },
          "company": { "type": "string" },
          "email": { "type": "string", "format": "email" },
          "phone": { "type": "string" },
          "industry": { "type": "string" },
          "users_count": { "type": "integer", "minimum": 1 },
          "current_tools": {
            "oneOf": [
              { "type": "string" },
              { "type": "array", "items": { "type": "string" } }
            ]
          },
          "organize_goals": {
            "oneOf": [
              { "type": "string" },
              { "type": "array", "items": { "type": "string" } }
            ]
          },
          "project_needs": { "type": "string" },
          "deadline": { "type": "string" },
          "privacy_consent": { "type": "boolean" },
          "source": {
            "type": "string",
            "enum": ["website", "api", "chatgpt", "claude", "mcp", "other"]
          },
          "user_intent_summary": {
            "type": "string",
            "maxLength": 2000,
            "description": "Short summary of user intent. Do not send full conversation transcripts."
          },
          "consent_text_version": {
            "type": "string",
            "example": "privacy-2026-05-22"
          }
        }
      },
      "PublicQuoteRequestCreate": {
        "type": "object",
        "required": ["name", "company", "email", "project_needs", "privacy_consent", "source"],
        "properties": {
          "name": { "type": "string" },
          "company": { "type": "string" },
          "email": { "type": "string", "format": "email" },
          "phone": { "type": "string" },
          "industry": { "type": "string" },
          "users_count": { "type": "integer", "minimum": 1 },
          "current_tools": {
            "oneOf": [
              { "type": "string" },
              { "type": "array", "items": { "type": "string" } }
            ]
          },
          "organize_goals": {
            "oneOf": [
              { "type": "string" },
              { "type": "array", "items": { "type": "string" } }
            ]
          },
          "project_needs": { "type": "string" },
          "deadline": { "type": "string" },
          "privacy_consent": { "type": "boolean" },
          "source": {
            "type": "string",
            "enum": ["chatgpt", "claude", "mcp", "other"],
            "description": "Identifică agentul LLM care trimite cererea."
          },
          "user_intent_summary": {
            "type": "string",
            "maxLength": 2000
          },
          "website": {
            "type": "string",
            "description": "Honeypot — must stay empty. If filled, request is silently accepted without saving."
          }
        }
      },
      "QuoteRequestResponse": {
        "type": "object",
        "properties": {
          "success": { "type": "boolean" },
          "id": { "type": "integer" },
          "reference": { "type": "string", "example": "OSON-42" },
          "status": { "type": "string", "example": "new" },
          "message": { "type": "string" }
        }
      }
    }
  }
}
