{
  "openapi": "3.0.3",
  "info": {
    "title": "SalesHose Public API",
    "version": "1.0.0",
    "description": "Public endpoints for embedding and submitting SalesHose conversational lead-qualification forms. No authentication required for these endpoints. Full docs: https://saleshose.com/docs",
    "contact": { "name": "SalesHose", "url": "https://saleshose.com/docs" }
  },
  "servers": [{ "url": "https://saleshose.com" }],
  "paths": {
    "/api/forms/{slug}": {
      "get": {
        "summary": "Get a form's public config (title, theme, blocks)",
        "parameters": [{ "name": "slug", "in": "path", "required": true, "schema": { "type": "string" } }],
        "responses": {
          "200": {
            "description": "Form config",
            "content": { "application/json": { "schema": {
              "type": "object",
              "properties": {
                "slug": { "type": "string" },
                "title": { "type": "string" },
                "config": { "type": "object" }
              }
            } } }
          },
          "404": { "description": "Not found or unpublished" }
        }
      }
    },
    "/api/forms/{slug}/responses": {
      "post": {
        "summary": "Submit (or partial-capture) a response; returns lead score and resolved ending",
        "parameters": [{ "name": "slug", "in": "path", "required": true, "schema": { "type": "string" } }],
        "requestBody": {
          "required": true,
          "content": { "application/json": { "schema": {
            "type": "object",
            "properties": {
              "data": { "type": "object", "description": "Answers keyed by each block's name", "additionalProperties": true },
              "completed": { "type": "boolean", "default": true },
              "id": { "type": "string", "description": "Stable id for partial-capture upsert" },
              "meta": { "type": "object", "additionalProperties": true }
            },
            "required": ["data"]
          } } }
        },
        "responses": {
          "200": {
            "description": "Saved",
            "content": { "application/json": { "schema": {
              "type": "object",
              "properties": {
                "ok": { "type": "boolean" },
                "id": { "type": "string" },
                "score": { "type": ["integer", "null"] },
                "ending": {
                  "type": ["object", "null"],
                  "properties": {
                    "title": { "type": ["string", "null"] },
                    "description": { "type": ["string", "null"] },
                    "book": { "type": ["object", "null"], "properties": { "url": { "type": "string" } } },
                    "redirect": { "type": ["string", "null"] },
                    "rep": { "type": ["string", "null"] }
                  }
                }
              }
            } } }
          }
        }
      }
    },
    "/api/forms/{slug}/responses/{id}/booked": {
      "post": {
        "summary": "Mark a response as 'meeting booked' (fired automatically by the embedded scheduler on booking success)",
        "parameters": [
          { "name": "slug", "in": "path", "required": true, "schema": { "type": "string" } },
          { "name": "id", "in": "path", "required": true, "schema": { "type": "string" }, "description": "The response id returned by the submit call" }
        ],
        "responses": { "200": { "description": "Marked booked", "content": { "application/json": { "schema": { "type": "object", "properties": { "ok": { "type": "boolean" } } } } } } }
      }
    },
    "/api/forms/{slug}/events": {
      "post": {
        "summary": "Record a funnel event (view, start, complete)",
        "parameters": [{ "name": "slug", "in": "path", "required": true, "schema": { "type": "string" } }],
        "requestBody": {
          "content": { "application/json": { "schema": {
            "type": "object",
            "properties": {
              "kind": { "type": "string", "enum": ["view", "start", "complete"] },
              "session": { "type": "string" }
            }
          } } }
        },
        "responses": { "200": { "description": "OK" } }
      }
    }
  }
}
