{
  "openapi": "3.1.0",
  "info": {
    "title": "Alishahi Insurance quote requests",
    "version": "1.0.0",
    "description": "Request an insurance quote from Alishahi Insurance, an independent broker in Beverly Hills, California (Sam Alishahi, CA License #4348151). Requests are reviewed personally by Sam, who follows up by phone or email. No prices are given and no coverage is bound until confirmed in writing."
  },
  "servers": [{ "url": "https://alishahiinsurance.com" }],
  "paths": {
    "/agent/coverages.json": {
      "get": {
        "operationId": "listCoverages",
        "summary": "List the coverages Alishahi Insurance quotes, with a page for each.",
        "responses": { "200": { "description": "Coverages", "content": { "application/json": { "schema": { "type": "object",
          "properties": { "broker": { "type": "string" }, "license": { "type": "string" },
            "coverages": { "type": "array", "items": { "type": "object", "properties": {
              "coverage": { "type": "string" }, "page": { "type": "string" }, "summary": { "type": "string" } } } } } } } } } }
      }
    },
    "/api/agent/questions": {
      "get": {
        "operationId": "getQuoteQuestions",
        "summary": "Get the questions to ask for one coverage. All are optional.",
        "parameters": [{ "name": "coverage", "in": "query", "required": true, "schema": { "type": "string" }, "description": "A coverage name from listCoverages, e.g. Homeowners or Tow truck." }],
        "responses": {
          "200": { "description": "Questions", "content": { "application/json": { "schema": { "type": "object", "properties": {
            "coverage": { "type": "string" },
            "questions": { "type": "array", "items": { "type": "object", "properties": {
              "name": { "type": "string" }, "type": { "type": "string" }, "choices": { "type": "array", "items": { "type": "string" } } } } } } } } } },
          "404": { "description": "Unknown coverage" }
        }
      }
    },
    "/api/agent/quote": {
      "post": {
        "operationId": "submitQuoteRequest",
        "summary": "Send the person's quote request to Sam Alishahi. Only after they confirm they want to be contacted.",
        "x-openai-isConsequential": true,
        "requestBody": { "required": true, "content": { "application/json": { "schema": { "type": "object",
          "required": ["coverage", "name", "phone", "email", "contact_consent"],
          "properties": {
            "coverage": { "type": "string", "description": "Coverage name from listCoverages." },
            "name": { "type": "string" },
            "phone": { "type": "string" },
            "email": { "type": "string" },
            "zip": { "type": "string" },
            "answers": { "type": "object", "additionalProperties": { "type": "string" }, "description": "Answers keyed by question name from getQuoteQuestions. Select questions must use one of the listed choices." },
            "notes": { "type": "string", "description": "Anything else Sam should know, such as deadlines or lender requirements." },
            "contact_consent": { "type": "boolean", "description": "True only after the person confirmed they want Sam Alishahi to contact them by phone or email." }
          } } } } },
        "responses": {
          "200": { "description": "Sent", "content": { "application/json": { "schema": { "type": "object", "properties": { "ok": { "type": "boolean" }, "reference": { "type": "string" }, "message": { "type": "string" } } } } } },
          "400": { "description": "Missing or invalid information; the message says what to ask for", "content": { "application/json": { "schema": { "type": "object", "properties": { "ok": { "type": "boolean" }, "error": { "type": "string" }, "message": { "type": "string" } } } } } }
        }
      }
    },
    "/api/agent/application": {
      "get": {
        "operationId": "getApplication",
        "summary": "Read a quote application Sam started from the person's email: every field, its choices, what's filled in and what's still required.",
        "description": "The id and t values are in the link in Sam Alishahi's reply email. Add format=text for a plain-text version.",
        "parameters": [
          { "name": "id", "in": "query", "required": true, "schema": { "type": "string" }, "description": "application_id from Sam's email (Reference APP-<id>)." },
          { "name": "t", "in": "query", "required": true, "schema": { "type": "string" }, "description": "The token from the link in Sam's email." },
          { "name": "format", "in": "query", "required": false, "schema": { "type": "string", "enum": ["json", "text"] } }
        ],
        "responses": {
          "200": { "description": "The application", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Application" } } } },
          "404": { "description": "Link not valid" }
        }
      },
      "post": {
        "operationId": "completeApplication",
        "summary": "Add the person's answers to the application. Only send what the person told you or confirmed.",
        "x-openai-isConsequential": true,
        "parameters": [
          { "name": "id", "in": "query", "required": true, "schema": { "type": "string" } },
          { "name": "t", "in": "query", "required": true, "schema": { "type": "string" } }
        ],
        "requestBody": { "required": true, "content": { "application/json": { "schema": { "type": "object", "required": ["answers"],
          "properties": {
            "answers": { "type": "object", "additionalProperties": { "type": "string" }, "description": "Answers keyed by field name. Select fields take one of their choices; dates are YYYY-MM-DD; numbers are digits." },
            "notes": { "type": "string", "description": "Anything else the person wants Sam to know." },
            "submit": { "type": "boolean", "description": "True when the person is done, even if optional fields are blank." }
          } } } } },
        "responses": {
          "200": { "description": "The updated application, with saved and rejected answers", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Application" } } } },
          "404": { "description": "Link not valid" },
          "429": { "description": "Too many updates today" }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Application": { "type": "object", "properties": {
        "application_id": { "type": "string" }, "coverage": { "type": "string" },
        "status": { "type": "string", "enum": ["needs_information", "ready_to_submit", "complete"] },
        "missing_required": { "type": "array", "items": { "type": "string" } },
        "fields": { "type": "array", "items": { "type": "object", "properties": {
          "name": { "type": "string" }, "label": { "type": "string" }, "type": { "type": "string" },
          "choices": { "type": "array", "items": { "type": "string" } }, "required": { "type": "boolean" },
          "value": { "type": ["string", "null"] }, "group": { "type": "string" } } } },
        "how_to_complete": { "type": "object" }, "rules": { "type": "array", "items": { "type": "string" } },
        "saved": { "type": "array", "items": { "type": "string" } },
        "rejected": { "type": "array", "items": { "type": "object", "properties": { "field": { "type": "string" }, "error": { "type": "string" }, "choices": { "type": "array", "items": { "type": "string" } } } } },
        "message": { "type": "string" } } }
    }
  }
}
