{
  "openapi": "3.1.0",
  "info": {
    "title": "Good Home Capital Agentic Consultation API",
    "version": "2.0.0",
    "description": "Machine-readable Ontario mortgage brokerage facts, live 15-minute Toronto consultation slots, A2UI v1.0 confirmation cards, quote inquiries, and direct consultation booking for Good Home Capital Inc. (FSRA #12596)."
  },
  "servers": [
    {
      "url": "https://www.goodhomecapital.ca"
    }
  ],
  "paths": {
    "/api/agent/facts": {
      "get": {
        "operationId": "getBrokerageFacts",
        "summary": "Get FSRA #12596 canonical brokerage profile, allowed enums, inquiry consent wording, and typical fee ranges",
        "responses": {
          "200": {
            "description": "Canonical brokerage facts JSON",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BrokerageFactsResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/agent/slots": {
      "get": {
        "operationId": "listConsultationSlots",
        "summary": "List upcoming 15-minute Toronto phone consultation slots (excluding weekends & Ontario statutory holidays)",
        "parameters": [
          {
            "name": "days",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 14,
              "default": 5
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Available consultation slots",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SlotsResponse"
                }
              }
            }
          },
          "429": {
            "description": "Per-IP rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "503": {
            "description": "Live calendar availability check failed closed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/agent/prepare-a2ui": {
      "post": {
        "operationId": "prepareA2UIBookingCard",
        "summary": "Return an A2UI v1.0 declarative confirmation card with unchecked consent boxes for human sign-off",
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PrepareA2uiRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "A2UI v1.0 payload",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrepareA2uiResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/agent/book": {
      "post": {
        "operationId": "bookConsultationWithBrief",
        "summary": "Book a 15-minute phone consultation with structured Ontario borrower brief and explicit inquiry consent version",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 128
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BookingRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Booking status (CONFIRMED in live mode, SANDBOX_PREVIEW in sandbox, or PENDING_HUMAN_REVIEW if quarantined)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BookingResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation, enum, NANP phone, consent_version, slot allowlist, Ontario jurisdiction, or sensitive-data rejection",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Foreign Origin/CSRF rejection or Turnstile hostname/action verification failure",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "Selected slot already booked or Idempotency-Key body mismatch conflict",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "415": {
            "description": "Unsupported Media Type (must be application/json)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate or capacity cap exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "503": {
            "description": "Durable write failure, calendar error/reconciliation required, or live/production config missing",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/agent/quote-request": {
      "post": {
        "operationId": "submitMortgageQuoteRequest",
        "summary": "Submit an Ontario mortgage quote inquiry with explicit inquiry consent, consent_version, and privacy acknowledgement",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 128
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/QuoteRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Quote inquiry reference ID and security screening status",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/QuoteResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation or consent rejection",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "CSRF or Turnstile rejection",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "Idempotency-Key body mismatch conflict",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "415": {
            "description": "Unsupported Media Type (must be application/json)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate or quote cap exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "503": {
            "description": "Durable write failure or missing live/production configuration",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "BorrowerInput": {
        "type": "object",
        "required": [
          "first_name",
          "last_name",
          "email",
          "phone",
          "ontario_city"
        ],
        "properties": {
          "first_name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 60
          },
          "last_name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 60
          },
          "email": {
            "type": "string",
            "format": "email",
            "maxLength": 120
          },
          "phone": {
            "type": "string"
          },
          "ontario_city": {
            "type": "string"
          },
          "province": {
            "type": "string",
            "enum": [
              "ON",
              "Ontario"
            ],
            "default": "ON"
          }
        }
      },
      "SituationInput": {
        "type": "object",
        "required": [
          "goal"
        ],
        "properties": {
          "goal": {
            "type": "string",
            "enum": [
              "second_mortgage",
              "debt_consolidation",
              "private_mortgage",
              "bad_credit",
              "self_employed",
              "consumer_proposal_or_cra",
              "bridge",
              "renewal",
              "refinance",
              "purchase",
              "other"
            ]
          },
          "property_type": {
            "type": "string",
            "enum": [
              "detached",
              "semi_detached",
              "townhouse",
              "condo",
              "multi_unit",
              "rural_or_vacant",
              "commercial",
              "other",
              "unspecified"
            ],
            "default": "unspecified"
          },
          "approx_home_value_band": {
            "type": "string",
            "enum": [
              "Under $100k",
              "$100k - $250k",
              "Under $250k",
              "$250k - $500k",
              "Under $500k",
              "$500k - $750k",
              "$750k - $1M",
              "$1M - $1.5M",
              "$1.5M - $2.5M",
              "$2.5M+",
              "unsure"
            ],
            "default": "unsure"
          },
          "approx_loan_needed_band": {
            "type": "string",
            "enum": [
              "Under $50k",
              "$50k - $75k",
              "$75k - $150k",
              "$150k - $250k",
              "Under $100k",
              "$100k - $250k",
              "$250k - $500k",
              "$500k - $750k",
              "$750k - $1M",
              "$1M - $1.5M",
              "$1.5M - $2.5M",
              "$2.5M+",
              "unsure"
            ],
            "default": "unsure"
          },
          "credit_profile_band": {
            "type": "string",
            "enum": [
              "under_550",
              "550-599",
              "600-679",
              "680-739",
              "740+",
              "bruised_or_collections",
              "consumer_proposal_or_bankruptcy",
              "unknown"
            ],
            "default": "unknown"
          },
          "income_type": {
            "type": "string",
            "enum": [
              "salaried",
              "self_employed",
              "business_owner",
              "commission",
              "retired_or_pension",
              "rental_or_investment",
              "mixed",
              "other",
              "unspecified"
            ],
            "default": "unspecified"
          },
          "urgency_timeline": {
            "type": "string",
            "enum": [
              "immediate_under_7_days",
              "within_14_days",
              "within_30_days",
              "within_60_days",
              "within_90_days",
              "exploring"
            ],
            "default": "exploring"
          },
          "summary_for_broker": {
            "type": "string",
            "maxLength": 600
          }
        }
      },
      "AgentMetaInput": {
        "type": "object",
        "properties": {
          "is_ai_agent": {
            "type": "boolean",
            "default": true
          },
          "agent_name": {
            "type": "string",
            "maxLength": 40
          }
        }
      },
      "VerificationInput": {
        "type": "object",
        "properties": {
          "turnstile_token": {
            "type": "string"
          }
        }
      },
      "CalculationInput": {
        "type": "object",
        "properties": {
          "home_price": {
            "type": "number",
            "minimum": 0
          },
          "down_payment": {
            "type": "number",
            "minimum": 0
          },
          "mortgage_amount": {
            "type": "number",
            "minimum": 0
          },
          "amortization_years": {
            "type": "integer",
            "minimum": 1,
            "maximum": 40
          },
          "toronto_ltt": {
            "type": "boolean"
          },
          "first_time_buyer": {
            "type": "boolean"
          }
        }
      },
      "ConsentBookingInput": {
        "type": "object",
        "required": [
          "human_authorized_booking",
          "casl_contact_consent",
          "no_sensitive_docs_confirmed",
          "consent_version"
        ],
        "properties": {
          "human_authorized_booking": {
            "type": "boolean",
            "const": true
          },
          "casl_contact_consent": {
            "type": "boolean",
            "const": true
          },
          "no_sensitive_docs_confirmed": {
            "type": "boolean",
            "const": true
          },
          "consent_version": {
            "type": "string",
            "enum": [
              "2026-11-23-v3"
            ],
            "default": "2026-11-23-v3"
          },
          "marketing_followup_consent": {
            "type": "boolean",
            "default": false
          },
          "marketing_consent_version": {
            "type": "string",
            "enum": [
              "2026-11-23-m1"
            ]
          }
        }
      },
      "ConsentQuoteInput": {
        "type": "object",
        "required": [
          "casl_contact_consent",
          "privacy_notice_acknowledged",
          "consent_version"
        ],
        "properties": {
          "casl_contact_consent": {
            "type": "boolean",
            "const": true
          },
          "privacy_notice_acknowledged": {
            "type": "boolean",
            "const": true
          },
          "consent_version": {
            "type": "string",
            "enum": [
              "2026-11-23-v3"
            ],
            "default": "2026-11-23-v3"
          },
          "marketing_followup_consent": {
            "type": "boolean",
            "default": false
          },
          "marketing_consent_version": {
            "type": "string",
            "enum": [
              "2026-11-23-m1"
            ]
          }
        }
      },
      "PrepareA2uiRequest": {
        "type": "object",
        "properties": {
          "ontario_city": {
            "type": "string"
          },
          "goal": {
            "type": "string",
            "enum": [
              "second_mortgage",
              "debt_consolidation",
              "private_mortgage",
              "bad_credit",
              "self_employed",
              "consumer_proposal_or_cra",
              "bridge",
              "renewal",
              "refinance",
              "purchase",
              "other"
            ]
          },
          "approx_home_value_band": {
            "type": "string",
            "enum": [
              "Under $100k",
              "$100k - $250k",
              "Under $250k",
              "$250k - $500k",
              "Under $500k",
              "$500k - $750k",
              "$750k - $1M",
              "$1M - $1.5M",
              "$1.5M - $2.5M",
              "$2.5M+",
              "unsure"
            ]
          },
          "approx_loan_needed_band": {
            "type": "string",
            "enum": [
              "Under $50k",
              "$50k - $75k",
              "$75k - $150k",
              "$150k - $250k",
              "Under $100k",
              "$100k - $250k",
              "$250k - $500k",
              "$500k - $750k",
              "$750k - $1M",
              "$1M - $1.5M",
              "$1.5M - $2.5M",
              "$2.5M+",
              "unsure"
            ]
          },
          "summary_for_broker": {
            "type": "string",
            "maxLength": 600
          }
        }
      },
      "BookingRequest": {
        "type": "object",
        "required": [
          "slot_iso",
          "borrower",
          "situation",
          "consent"
        ],
        "properties": {
          "slot_iso": {
            "type": "string",
            "format": "date-time"
          },
          "borrower": {
            "$ref": "#/components/schemas/BorrowerInput"
          },
          "situation": {
            "$ref": "#/components/schemas/SituationInput"
          },
          "agent_meta": {
            "$ref": "#/components/schemas/AgentMetaInput"
          },
          "consent": {
            "$ref": "#/components/schemas/ConsentBookingInput"
          },
          "verification": {
            "$ref": "#/components/schemas/VerificationInput"
          },
          "return_a2ui": {
            "type": "boolean",
            "default": true
          }
        }
      },
      "QuoteRequest": {
        "type": "object",
        "required": [
          "borrower",
          "consent"
        ],
        "properties": {
          "borrower": {
            "$ref": "#/components/schemas/BorrowerInput"
          },
          "purpose": {
            "type": "string",
            "enum": [
              "purchase",
              "refinance",
              "renewal",
              "second_mortgage",
              "debt_consolidation",
              "private_mortgage",
              "home_equity",
              "other"
            ],
            "default": "refinance"
          },
          "calculation": {
            "$ref": "#/components/schemas/CalculationInput"
          },
          "situation": {
            "type": "object",
            "properties": {
              "goal": {
                "type": "string",
                "enum": [
                  "second_mortgage",
                  "debt_consolidation",
                  "private_mortgage",
                  "bad_credit",
                  "self_employed",
                  "consumer_proposal_or_cra",
                  "bridge",
                  "renewal",
                  "refinance",
                  "purchase",
                  "other"
                ]
              },
              "property_type": {
                "type": "string",
                "enum": [
                  "detached",
                  "semi_detached",
                  "townhouse",
                  "condo",
                  "multi_unit",
                  "rural_or_vacant",
                  "commercial",
                  "other",
                  "unspecified"
                ]
              },
              "approx_home_value_band": {
                "type": "string",
                "enum": [
                  "Under $100k",
                  "$100k - $250k",
                  "Under $250k",
                  "$250k - $500k",
                  "Under $500k",
                  "$500k - $750k",
                  "$750k - $1M",
                  "$1M - $1.5M",
                  "$1.5M - $2.5M",
                  "$2.5M+",
                  "unsure"
                ]
              },
              "approx_loan_needed_band": {
                "type": "string",
                "enum": [
                  "Under $50k",
                  "$50k - $75k",
                  "$75k - $150k",
                  "$150k - $250k",
                  "Under $100k",
                  "$100k - $250k",
                  "$250k - $500k",
                  "$500k - $750k",
                  "$750k - $1M",
                  "$1M - $1.5M",
                  "$1.5M - $2.5M",
                  "$2.5M+",
                  "unsure"
                ]
              },
              "credit_profile_band": {
                "type": "string",
                "enum": [
                  "under_550",
                  "550-599",
                  "600-679",
                  "680-739",
                  "740+",
                  "bruised_or_collections",
                  "consumer_proposal_or_bankruptcy",
                  "unknown"
                ]
              },
              "income_type": {
                "type": "string",
                "enum": [
                  "salaried",
                  "self_employed",
                  "business_owner",
                  "commission",
                  "retired_or_pension",
                  "rental_or_investment",
                  "mixed",
                  "other",
                  "unspecified"
                ]
              },
              "urgency_timeline": {
                "type": "string",
                "enum": [
                  "immediate_under_7_days",
                  "within_14_days",
                  "within_30_days",
                  "within_60_days",
                  "within_90_days",
                  "exploring"
                ]
              },
              "summary_for_broker": {
                "type": "string",
                "maxLength": 600
              }
            }
          },
          "notes": {
            "type": "string",
            "maxLength": 400
          },
          "agent_meta": {
            "$ref": "#/components/schemas/AgentMetaInput"
          },
          "consent": {
            "$ref": "#/components/schemas/ConsentQuoteInput"
          },
          "verification": {
            "$ref": "#/components/schemas/VerificationInput"
          }
        }
      },
      "BrokerageFactsResponse": {
        "type": "object",
        "properties": {
          "ok": {
            "type": "boolean"
          },
          "schema_version": {
            "type": "string"
          },
          "brokerage": {
            "type": "object"
          },
          "typical_terms_indication": {
            "type": "object"
          },
          "casl_consent": {
            "type": "object"
          },
          "allowed_enums": {
            "type": "object"
          }
        }
      },
      "SlotsResponse": {
        "type": "object",
        "required": [
          "ok",
          "brokerage",
          "timezone",
          "duration_minutes",
          "mode",
          "slots"
        ],
        "properties": {
          "ok": {
            "type": "boolean"
          },
          "brokerage": {
            "type": "string"
          },
          "timezone": {
            "type": "string"
          },
          "duration_minutes": {
            "type": "integer"
          },
          "mode": {
            "type": "string",
            "enum": [
              "sandbox",
              "google_calendar_live"
            ]
          },
          "slots": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "slot_iso",
                "end_iso",
                "duration_minutes",
                "timezone",
                "offset",
                "label_toronto"
              ],
              "properties": {
                "slot_iso": {
                  "type": "string",
                  "format": "date-time"
                },
                "end_iso": {
                  "type": "string",
                  "format": "date-time"
                },
                "duration_minutes": {
                  "type": "integer"
                },
                "timezone": {
                  "type": "string"
                },
                "offset": {
                  "type": "string"
                },
                "label_toronto": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "PrepareA2uiResponse": {
        "type": "object",
        "properties": {
          "ok": {
            "type": "boolean"
          },
          "a2ui": {
            "type": "object"
          }
        }
      },
      "BookingResponse": {
        "type": "object",
        "properties": {
          "ok": {
            "type": "boolean"
          },
          "status": {
            "type": "string"
          },
          "mode": {
            "type": "string"
          },
          "booking_id": {
            "type": "string"
          },
          "slot_iso": {
            "type": "string"
          },
          "cancellation_policy": {
            "type": "string"
          }
        }
      },
      "QuoteResponse": {
        "type": "object",
        "properties": {
          "ok": {
            "type": "boolean"
          },
          "status": {
            "type": "string"
          },
          "mode": {
            "type": "string",
            "enum": [
              "sandbox",
              "live"
            ]
          },
          "reference_id": {
            "type": "string"
          },
          "disclaimer": {
            "type": "string"
          }
        }
      },
      "ErrorResponse": {
        "type": "object",
        "properties": {
          "ok": {
            "type": "boolean"
          },
          "error": {
            "type": "string"
          }
        }
      }
    }
  }
}