{
  "openapi": "3.1.0",
  "info": {
    "title": "ALLCHOICE Insurance quote request API",
    "version": "1.0",
    "description": "Submit an insurance quote request on behalf of a customer. An ALLCHOICE advisor contacts the customer within 24 hours. This is a request for a quote, not bound coverage. Only submit when the customer asked you to and agreed to be contacted."
  },
  "servers": [
    {
      "url": "https://allchoiceinsurance.com"
    }
  ],
  "paths": {
    "/wp-json/allchoice/v1/quote-requests": {
      "post": {
        "operationId": "submitQuoteRequest",
        "summary": "Submit a quote request for a customer",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/QuoteRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Duplicate of a request received in the last 24 hours. Returns the original request_id.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Received"
                }
              }
            }
          },
          "201": {
            "description": "Request created.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Received"
                }
              }
            }
          },
          "400": {
            "description": "Body is not valid JSON."
          },
          "413": {
            "description": "Body larger than 16 KB."
          },
          "415": {
            "description": "Content-Type must be application/json."
          },
          "422": {
            "description": "Validation failed. The errors array lists each field and the problem.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited. See Retry-After. Email aiquoteteam@allchoiceinsurance.com or call 844.540.0463."
          },
          "503": {
            "description": "Temporarily unavailable. Use the email or phone fallback."
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "QuoteRequest": {
        "title": "ALLCHOICE Insurance quote request",
        "description": "Structured quote request an AI assistant can prepare for a customer. Submit it as JSON with POST to https://allchoiceinsurance.com/wp-json/allchoice/v1/quote-requests (see https://allchoiceinsurance.com/quote/ai/instructions/ and https://allchoiceinsurance.com/quote/ai/openapi.json), or use the form at https://allchoiceinsurance.com/quote/ai/. Only submit with the customer's permission.",
        "type": "object",
        "required": [
          "schema_version",
          "request_type",
          "customer",
          "authorization"
        ],
        "additionalProperties": false,
        "properties": {
          "schema_version": {
            "const": "1.0"
          },
          "request_type": {
            "enum": [
              "personal",
              "business"
            ],
            "description": "personal = home, auto and other personal insurance. business = commercial insurance."
          },
          "customer": {
            "type": "object",
            "required": [
              "first_name",
              "last_name",
              "phone",
              "email",
              "zip_code"
            ],
            "additionalProperties": false,
            "properties": {
              "first_name": {
                "type": "string",
                "minLength": 1,
                "maxLength": 60
              },
              "last_name": {
                "type": "string",
                "minLength": 1,
                "maxLength": 60
              },
              "phone": {
                "type": "string",
                "description": "US phone number, for example 336-555-0100."
              },
              "email": {
                "type": "string",
                "format": "email",
                "description": "The customer's real email address."
              },
              "zip_code": {
                "type": "string",
                "pattern": "^[0-9]{5}$",
                "description": "5-digit ZIP code where the home or business is located."
              },
              "street_address": {
                "type": "string",
                "maxLength": 120,
                "description": "Optional street address (number and street, plus unit if any). Include only if the customer is comfortable sharing it."
              }
            }
          },
          "business": {
            "type": "object",
            "required": [
              "business_name"
            ],
            "additionalProperties": false,
            "description": "Required when request_type is business.",
            "properties": {
              "business_name": {
                "type": "string",
                "minLength": 1,
                "maxLength": 120
              },
              "description": {
                "type": "string",
                "maxLength": 500,
                "description": "What the business does."
              }
            }
          },
          "requested_coverages": {
            "type": "array",
            "uniqueItems": true,
            "items": {
              "enum": [
                "Auto",
                "Home",
                "Renters",
                "Condo",
                "Umbrella",
                "Landlord",
                "Boat or Jet Ski",
                "Flood",
                "Other",
                "General Liability",
                "Commercial Property",
                "Commercial Auto",
                "Workers' Compensation",
                "Business Owners (BOP)",
                "Professional Liability",
                "Bonds"
              ]
            },
            "description": "Personal values: Auto, Home, Renters, Condo, Umbrella, Landlord, Boat or Jet Ski, Flood, Other. Business values: General Liability, Commercial Property, Commercial Auto, Workers' Compensation, Business Owners (BOP), Professional Liability, Bonds, Other."
          },
          "current_insurance": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "carrier": {
                "type": "string",
                "maxLength": 120
              },
              "expiration_date": {
                "type": "string",
                "format": "date",
                "description": "Renewal or expiration date, YYYY-MM-DD."
              }
            }
          },
          "drivers": {
            "type": "array",
            "maxItems": 10,
            "description": "Optional. Include only if the customer agreed to share these details. Needed by an advisor to quote auto insurance. Omit if the customer prefers to provide them by phone.",
            "items": {
              "type": "object",
              "required": [
                "name"
              ],
              "additionalProperties": false,
              "properties": {
                "name": {
                  "type": "string",
                  "maxLength": 120
                },
                "birth_date": {
                  "type": "string",
                  "format": "date",
                  "description": "YYYY-MM-DD."
                },
                "license_number": {
                  "type": "string",
                  "maxLength": 40
                },
                "license_state": {
                  "type": "string",
                  "pattern": "^[A-Z]{2}$"
                }
              }
            }
          },
          "desired_start_date": {
            "type": "string",
            "format": "date",
            "description": "YYYY-MM-DD."
          },
          "authorization": {
            "type": "object",
            "required": [
              "customer_authorized"
            ],
            "additionalProperties": false,
            "properties": {
              "customer_authorized": {
                "const": true,
                "description": "Set true only if the customer asked you to submit this request and agreed to be contacted by ALLCHOICE by phone, text or email."
              }
            }
          },
          "submission_source": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "name": {
                "type": "string",
                "maxLength": 80,
                "description": "Name of the AI assistant or platform."
              }
            }
          },
          "notes": {
            "type": "string",
            "maxLength": 1000,
            "description": "Anything else that helps an advisor. Do not include Social Security numbers, payment details or passwords."
          }
        },
        "allOf": [
          {
            "if": {
              "properties": {
                "request_type": {
                  "const": "business"
                }
              },
              "required": [
                "request_type"
              ]
            },
            "then": {
              "required": [
                "business"
              ],
              "properties": {
                "requested_coverages": {
                  "items": {
                    "enum": [
                      "General Liability",
                      "Commercial Property",
                      "Commercial Auto",
                      "Workers' Compensation",
                      "Business Owners (BOP)",
                      "Professional Liability",
                      "Bonds",
                      "Other"
                    ]
                  }
                }
              }
            }
          },
          {
            "if": {
              "properties": {
                "request_type": {
                  "const": "personal"
                }
              },
              "required": [
                "request_type"
              ]
            },
            "then": {
              "properties": {
                "requested_coverages": {
                  "items": {
                    "enum": [
                      "Auto",
                      "Home",
                      "Renters",
                      "Condo",
                      "Umbrella",
                      "Landlord",
                      "Boat or Jet Ski",
                      "Flood",
                      "Other"
                    ]
                  }
                }
              }
            }
          }
        ]
      },
      "Received": {
        "type": "object",
        "properties": {
          "status": {
            "const": "received"
          },
          "duplicate": {
            "type": "boolean"
          },
          "request_id": {
            "type": "string",
            "description": "For example AI-12345. Give this to the customer."
          },
          "message": {
            "type": "string"
          }
        }
      },
      "Error": {
        "type": "object",
        "properties": {
          "status": {
            "const": "error"
          },
          "error": {
            "type": "string"
          },
          "message": {
            "type": "string"
          },
          "errors": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "field": {
                  "type": "string"
                },
                "message": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    }
  }
}