{
  "openapi": "3.1.0",
  "info": {
    "title": "FixMySauna order API",
    "version": "1.0.0",
    "description": "Find, fit and order Coastal Saunas replacement parts. Prices in USD; US shipping is free. Parts with fit status 'confirm' are checked with Coastal Saunas service before payment. Never submit an order without the customer's confirmation. MCP clients: https://fixmysauna-christopher-baileys-projects-7c988399.vercel.app/api/mcp"
  },
  "servers": [
    {
      "url": "https://fixmysauna-christopher-baileys-projects-7c988399.vercel.app"
    }
  ],
  "paths": {
    "/api/products": {
      "get": {
        "operationId": "searchParts",
        "summary": "Search parts (never empty)",
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Words the customer uses, e.g. control panel, heater, cover"
          },
          {
            "name": "model",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "Malibu",
                "Delmar",
                "Newport",
                "Hollywood"
              ]
            },
            "description": "Adds each part's fit and option for this model"
          }
        ],
        "responses": {
          "200": {
            "description": "Matching parts, or every part with matched=false"
          }
        }
      }
    },
    "/api/fit": {
      "get": {
        "operationId": "checkFit",
        "summary": "Does a part fit a model",
        "parameters": [
          {
            "name": "model",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Malibu, Delmar, Newport or Hollywood (forgiving)"
          },
          {
            "name": "voltage",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Alternative to model: 110 or 240"
          },
          {
            "name": "part",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Part id, base SKU or variant SKU; omit for every part"
          }
        ],
        "responses": {
          "200": {
            "description": "status fits|confirm, sku, variant, price, checkout"
          },
          "300": {
            "description": "Several models match"
          },
          "404": {
            "description": "Unknown model or part; lists what exists"
          }
        }
      }
    },
    "/api/submit-request": {
      "post": {
        "operationId": "submitQuoteRequest",
        "summary": "Send an order or parts request (emails the business; returns a case number)",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "type",
                  "name"
                ],
                "properties": {
                  "type": {
                    "type": "string",
                    "enum": [
                      "quote",
                      "request"
                    ]
                  },
                  "name": {
                    "type": "string"
                  },
                  "phone": {
                    "type": "string"
                  },
                  "email": {
                    "type": "string"
                  },
                  "address": {
                    "type": "object",
                    "properties": {
                      "line1": {
                        "type": "string"
                      },
                      "line2": {
                        "type": "string"
                      },
                      "city": {
                        "type": "string"
                      },
                      "state": {
                        "type": "string"
                      },
                      "zip": {
                        "type": "string"
                      }
                    }
                  },
                  "model": {
                    "type": "string"
                  },
                  "brand": {
                    "type": "string"
                  },
                  "symptom": {
                    "type": "string"
                  },
                  "quoteItems": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "name": {
                          "type": "string"
                        },
                        "sku": {
                          "type": "string"
                        },
                        "variant": {
                          "type": "string"
                        },
                        "qty": {
                          "type": "integer"
                        },
                        "unitPrice": {
                          "type": "number"
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "{ caseId, received, emailed }"
          },
          "400": {
            "description": "What is missing"
          },
          "429": {
            "description": "Too many requests"
          }
        }
      }
    },
    "/api/create-checkout": {
      "post": {
        "operationId": "startCheckout",
        "summary": "Stripe Checkout link for parts that can be bought online",
        "description": "Item key: part id for single-price parts (e.g. keypad), or id::option label for parts with options (e.g. cover::Hollywood). The customer enters shipping and payment on Stripe's page; nothing is charged by this call.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "mode",
                  "items"
                ],
                "properties": {
                  "mode": {
                    "type": "string",
                    "enum": [
                      "cart"
                    ]
                  },
                  "items": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "required": [
                        "key",
                        "qty"
                      ],
                      "properties": {
                        "key": {
                          "type": "string",
                          "examples": [
                            "keypad",
                            "cover::Hollywood"
                          ]
                        },
                        "qty": {
                          "type": "integer",
                          "minimum": 1,
                          "maximum": 99
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "{ url, id }"
          },
          "400": {
            "description": "Unknown item, or a part that must be confirmed first"
          },
          "503": {
            "description": "Online payment not configured; use submitQuoteRequest"
          }
        }
      }
    }
  }
}
