{
  "openapi": "3.1.0",
  "info": {
    "title": "Factored Quality Inspection Estimate API",
    "version": "0.1.0",
    "description": "Public, no-auth API that gives a non-binding estimate for a factory product inspection booked through Factored Quality, plus a quote PDF and a link to book a sales call. Uses the same AQL sampling and inspector-day rules as the Factored Quality platform. Do not send names, emails or other personal data."
  },
  "servers": [{ "url": "https://fq-estimate.pages.dev" }],
  "paths": {
    "/api/estimate": {
      "get": {
        "operationId": "getInspectionEstimate",
        "summary": "Estimate a product inspection and get a quote PDF and booking link",
        "description": "Returns sample size, inspector-days and a price range for inspection services (psi, inline, fai, cl, ia, ic, cpk). Audits, lab testing and other services return priced=false and a note that FQ quotes them. Always give the buyer deliverables.quotePdf and deliverables.bookCall.",
        "parameters": [
          { "name": "service", "in": "query", "required": true, "schema": { "type": "string", "enum": ["psi", "inline", "fai", "cl", "ia", "ic", "cpk", "fa", "soc", "env", "pct", "capa_rca", "ss"], "default": "psi" }, "description": "psi=Pre-Shipment Inspection, inline=In-Line Inspection, fai=First Article Inspection, cl=Container Loading Check, ia=Inventory Audit, ic=Inventory Count, cpk=Process Capability Index, fa=Factory Audit, soc=Social & Ethical Audit, env=Environmental Audit, pct=Product Compliance / Lab Testing, capa_rca=CAPA / Root Cause Analysis, ss=Supplier Sourcing." },
          { "name": "quantity", "in": "query", "required": false, "schema": { "type": "integer", "minimum": 1 }, "description": "Total units in the order, digits only (5000, not 5,000). Required for inspection services unless skuQuantities is given." },
          { "name": "skuQuantities", "in": "query", "required": false, "schema": { "type": "string" }, "description": "Units per SKU, comma-separated digits, e.g. 3000,2000. Use instead of quantity when the order has several SKUs." },
          { "name": "grouping", "in": "query", "required": false, "schema": { "type": "string", "enum": ["order", "sku"] }, "description": "order = one AQL sample for the whole order (default for quantity). sku = a separate sample per SKU (default when skuQuantities is given)." },
          { "name": "aqlLevel", "in": "query", "required": false, "schema": { "type": "string", "enum": ["I", "II", "III"], "default": "II" }, "description": "AQL General Inspection Level." },
          { "name": "country", "in": "query", "required": false, "schema": { "type": "string" }, "description": "Factory country, e.g. China, Vietnam, India." },
          { "name": "city", "in": "query", "required": false, "schema": { "type": "string" }, "description": "Factory city, e.g. Ningbo." },
          { "name": "product", "in": "query", "required": false, "schema": { "type": "string" }, "description": "Short product description, e.g. insulated steel water bottles." },
          { "name": "targetDate", "in": "query", "required": false, "schema": { "type": "string" }, "description": "Target inspection date or cargo-ready date, e.g. 2027-01-12." }
        ],
        "responses": {
          "200": {
            "description": "Non-binding estimate",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "quoteId": { "type": "string" },
                    "issued": { "type": "string" },
                    "validUntil": { "type": "string" },
                    "binding": { "type": "boolean" },
                    "service": { "type": "object", "properties": { "code": { "type": "string" }, "name": { "type": "string" } } },
                    "priced": { "type": "boolean" },
                    "sampling": { "type": "object", "properties": { "generalInspectionLevel": { "type": "string" }, "grouping": { "type": "string" }, "sampleSize": { "type": "integer" } } },
                    "inspectorDays": { "type": "object", "properties": { "low": { "type": "integer" }, "high": { "type": "integer" } } },
                    "dayRateUsd": { "type": "number" },
                    "priceUsd": { "type": "object", "properties": { "low": { "type": "number" }, "high": { "type": "number" } } },
                    "assumptions": { "type": "array", "items": { "type": "string" } },
                    "note": { "type": "string" },
                    "deliverables": { "type": "object", "properties": { "quotePdf": { "type": "string", "description": "Link to the non-binding quote PDF. Give it to the buyer." }, "bookCall": { "type": "string", "description": "Link to book a sales call with Factored Quality." } } },
                    "nextSteps": { "type": "array", "items": { "type": "string" } },
                    "disclaimer": { "type": "string" }
                  }
                }
              }
            }
          },
          "400": { "description": "Invalid input. The error field says what to fix.", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" } } } } } }
        }
      }
    }
  }
}
