{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/lendb-ai/json-schema/lendb-ai-ranked-loan-officer-schema.json",
  "title": "RankedLoanOfficer",
  "x-generated": "2026-11-15",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/lendb-ai-openapi.yml#/components/schemas/RankedLoanOfficer",
  "type": "object",
  "required": [
    "rank",
    "score",
    "loan_officer",
    "reasons",
    "canonical_url"
  ],
  "properties": {
    "rank": {
      "type": "integer"
    },
    "score": {
      "type": "number"
    },
    "reasons": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "Why this person is in the list, with source and verification date."
    },
    "canonical_url": {
      "type": "string",
      "format": "uri"
    },
    "loan_officer": {
      "$ref": "#/$defs/LoanOfficerSummary"
    },
    "distance_mi": {
      "type": [
        "number",
        "null"
      ],
      "description": "Miles from the searched place to the nearest current branch (place searches only)."
    },
    "distance_basis": {
      "type": [
        "string",
        "null"
      ],
      "enum": [
        "office_zip",
        "branch_city",
        null
      ],
      "description": "Measured to the office ZIP centroid, or to the branch city's center when no ZIP is on file."
    },
    "office_location_unknown": {
      "type": "boolean",
      "description": "Local searches: LenDb cannot place this office; listed after placed offices."
    },
    "match_scope": {
      "type": "string",
      "enum": [
        "state"
      ],
      "description": "'state': a place with few offices nearby; this person is listed after the local results only because they are licensed in the property's state (search.state_fill)."
    },
    "license_check": {
      "type": "object",
      "description": "License evidence for the property state. Only confidence 'confirmed' is a state regulator record.",
      "properties": {
        "state": {
          "type": "string"
        },
        "confidence": {
          "type": "string",
          "enum": [
            "confirmed",
            "lender_reported",
            "self_reported",
            "federal_registration",
            "unknown"
          ]
        },
        "eligible": {
          "type": "boolean"
        },
        "label": {
          "type": "string"
        },
        "verified_at": {
          "type": [
            "string",
            "null"
          ]
        },
        "source_url": {
          "type": [
            "string",
            "null"
          ]
        }
      }
    },
    "match_status": {
      "type": "string",
      "enum": [
        "exact",
        "partial"
      ],
      "description": "Specialty searches: exact = every requested specialty on file; partial = some not confirmed."
    },
    "matched_specialties": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "unconfirmed_specialties": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "Requested specialties with no officer-level evidence on file for this person."
    },
    "match_level": {
      "type": "string",
      "enum": [
        "officer",
        "lender"
      ],
      "description": "officer = matched on the person's own focus (their bio, title, certification, own specialty list or claim). lender = listed only because their current lender offers the program (lender_offered_specialties); not confirmed as their focus. Lender-level results appear only in lender_level, never in results."
    },
    "lender_offered_specialties": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "Lender-level results: requested specialties their current lender offers."
    },
    "mentioned_by_loan_officer": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "Free-text searches (q): phrases from this loan officer's own_words that the query names, labeled 'mentioned by the loan officer'. A label only: never why the result is listed or where it ranks. Absent when none."
    }
  },
  "$defs": {
    "LicensedName": {
      "type": "object",
      "required": [
        "name",
        "first_name",
        "last_name",
        "states",
        "source",
        "as_of"
      ],
      "properties": {
        "name": {
          "type": "string",
          "description": "First and last name as the state regulator licenses it, e.g. 'Nicholas Bucca' for Nic Bucca."
        },
        "name_with_middle_initial": {
          "type": [
            "string",
            "null"
          ],
          "description": "'Nicholas A. Bucca' when the regulator lists a middle name. LenDb never publishes the full middle name."
        },
        "first_name": {
          "type": "string"
        },
        "middle_initial": {
          "type": [
            "string",
            "null"
          ]
        },
        "last_name": {
          "type": "string"
        },
        "states": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "Two-letter codes of the states whose regulator lists this form."
        },
        "source": {
          "type": "string",
          "enum": [
            "state_regulator"
          ]
        },
        "as_of": {
          "type": "string",
          "format": "date",
          "description": "Date of the newest regulator file with this form."
        }
      }
    },
    "LoanOfficerSummary": {
      "type": "object",
      "properties": {
        "nmls_id": {
          "type": "integer"
        },
        "slug": {
          "type": "string"
        },
        "full_name": {
          "type": "string"
        },
        "licensed_names": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/LicensedName"
          },
          "description": "Names as state regulators license this NMLS ID, when they differ from full_name (a nickname or short form on the lender site, e.g. Nic for Nicholas). Same person: same NMLS ID, surname and a compatible first name. Absent when there is none."
        },
        "canonical_url": {
          "type": "string",
          "format": "uri"
        },
        "json_url": {
          "type": "string",
          "format": "uri"
        },
        "lender": {
          "type": [
            "object",
            "null"
          ],
          "properties": {
            "nmls_id": {
              "type": "integer"
            },
            "name": {
              "type": "string"
            },
            "slug": {
              "type": "string"
            },
            "canonical_url": {
              "type": "string"
            }
          }
        },
        "branch": {
          "type": [
            "object",
            "null"
          ],
          "properties": {
            "city": {
              "type": [
                "string",
                "null"
              ]
            },
            "state": {
              "type": [
                "string",
                "null"
              ]
            }
          }
        },
        "headshot_url": {
          "type": [
            "string",
            "null"
          ],
          "description": "Photo URL from the person's lender page (hotlinked from there, as on the profile page), or null."
        },
        "licensed_states": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "States with a confirmed (regulator) or lender-reported license."
        },
        "licenses": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "state": {
                "type": "string"
              },
              "confidence": {
                "type": "string",
                "enum": [
                  "confirmed",
                  "lender_reported"
                ]
              }
            }
          }
        },
        "federal_registration_likely": {
          "type": "boolean",
          "description": "Works at a bank or credit union, so likely a federally registered MLO (registered with NMLS, not state-licensed; eligible in any state). Inferred from the employer type; verify at NMLS."
        },
        "languages": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "specialties": {
          "type": "array",
          "description": "Officer-level: the person's own focus. evidence agency_list: a state housing agency lists them for its down payment assistance programs (not their own focus; listed_by names the agency).",
          "items": {
            "type": "object",
            "properties": {
              "slug": {
                "type": "string"
              },
              "evidence": {
                "type": "string",
                "enum": [
                  "self_claimed",
                  "lender_page_text",
                  "production_data",
                  "lender_provided",
                  "lo_provided",
                  "agency_list",
                  "lo_own_site"
                ]
              },
              "listed_by": {
                "type": "string"
              }
            }
          }
        },
        "loan_programs": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "Basic loan programs the person lists, such as conventional. Not a focus and never used in search ranking. Absent when none."
        },
        "lender_offers": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "Lender-level: slugs of programs their current lender offers that are not their own specialties. Never counted as their focus."
        },
        "employer_program_approvals": {
          "type": "array",
          "description": "Their current lender's agency approvals: program fha means the lender is FHA-approved per HUD data (shown as 'Works at an FHA-approved lender, per HUD'). About the lender, never the person. Absent when none is on file.",
          "items": {
            "type": "object",
            "properties": {
              "program": {
                "type": "string",
                "enum": [
                  "fha"
                ]
              },
              "source": {
                "type": "string",
                "enum": [
                  "HUD"
                ]
              },
              "as_of": {
                "type": "string",
                "description": "YYYY-MM: loans endorsed through this month."
              }
            }
          }
        },
        "years_licensed": {
          "type": [
            "integer",
            "null"
          ],
          "deprecated": true,
          "description": "Deprecated: always null. A count of years since the first state license record would imply continuous licensure, which a regulator's initial effective date does not establish. Use earliest_license_record."
        },
        "earliest_license_record": {
          "type": [
            "object",
            "null"
          ],
          "properties": {
            "date": {
              "type": "string",
              "format": "date"
            },
            "state": {
              "type": "string"
            }
          },
          "description": "Earliest state regulator license record LenDb holds (only states with loaded rosters): a record date, not proof of continuous licensure or total experience. Shown as 'Earliest state license record: <date> (<state>), per state regulator'."
        },
        "licensed_since": {
          "type": [
            "object",
            "null"
          ],
          "deprecated": true,
          "properties": {
            "year": {
              "type": "integer"
            },
            "state": {
              "type": "string"
            }
          },
          "description": "Deprecated: the year and state of earliest_license_record."
        },
        "years_experience": {
          "type": [
            "integer",
            "null"
          ],
          "description": "Years of experience the loan officer states on their lender page."
        },
        "lender_profile_url": {
          "type": [
            "string",
            "null"
          ],
          "description": "The loan officer's own page at their lender. Phone and email are not in the API."
        },
        "disciplinary_check": {
          "type": "string",
          "enum": [
            "not_checked",
            "checked"
          ],
          "description": "not_checked: LenDb has not loaded regulator disciplinary records for this person yet. An empty disciplinary_actions list does not mean a clean record. Verify at NMLS Consumer Access."
        }
      }
    }
  }
}