openapi: 3.1.0
info:
  title: Sunset API
  description: |
    Estate and probate management platform API. Manage cases, track assets, handle bank accounts, and navigate probate proceedings across all US states and counties.

    ## Key Features

    - **Full Estate Lifecycle** — Case creation through final asset distribution
    - **Instant Inheritance** — Pull a deceased account holder's bank balance into the estate account without waiting on the bank
    - **Identity Verification** — Verify deceased (SSDI, vital records) and executor (government ID, KBA) identity
    - **Real Estate Valuations** — Automated property valuations with comparable sales and lien tracking
    - **Communication Tools** — Recorded phone calls, emails, faxes, and online notarization
    - **Probate Reference Data** — Requirements for all 50 states, DC, and US territories
    - **Multi-Estate Management** — Pro and Enterprise tiers for managing multiple cases

    ## API Quality

    - **Idempotency** — `Idempotency-Key` header on all POST endpoints to prevent duplicate operations
    - **Rate Limiting** — Tiered rate limits (Pro: 300/min, Enterprise: 1,000/min)
    - **Conditional Requests** — ETag support with `If-None-Match` and `If-Match` headers
    - **Request Tracing** — `X-Request-Id` header on every response
    - **Cursor Pagination** — Optional cursor-based pagination for high-volume resources
    - **JSON Merge Patch** — All PATCH endpoints use JSON Merge Patch semantics (RFC 7396)
  version: 1.0.0
  contact:
    name: Sunset API Support

servers:
  - url: https://api.example.com/v1
    description: Production
  - url: https://staging-api.example.com/v1
    description: Staging

tags:
  - name: Cases
    description: Estate/probate case management
  - name: Deceased
    description: Deceased person information
  - name: Executor
    description: Estate executor information
  - name: Authority
    description: Authority verification
  - name: EIN
    description: Employer Identification Number
  - name: Financial Accounts
    description: Estate financial accounts and assets
  - name: Documents
    description: Case document management
  - name: Searches
    description: Asset and background searches
  - name: Persons
    description: Interested persons and beneficiaries
  - name: Goals
    description: Estate management goals
  - name: Bank Accounts
    description: Bank account management
  - name: Signers
    description: Bank account holders and signers
  - name: Transactions
    description: Bank account transactions
  - name: Recurring Payments
    description: Recurring payments and deposits
  - name: Account Beneficiaries
    description: POD/TOD beneficiary designations
  - name: Statements
    description: Bank account statements
  - name: Balance History
    description: Historical balance snapshots
  - name: Transfers
    description: Instant Inheritance transfers into the estate account
  - name: Probate Reference
    description: State and county probate reference data
  - name: Probate Forms
    description: State-level probate forms
  - name: Probate Case
    description: Case-level probate tracking
  - name: Probate Deadlines
    description: Probate deadlines and due dates
  - name: Probate Filings
    description: Court filings
  - name: Creditor Claims
    description: Creditor claims against the estate
  - name: Distributions
    description: Beneficiary distributions
  - name: Pro Users
    description: Pro user multi-estate management
  - name: Collaborators
    description: Multi-user collaboration and estate sharing
  - name: Closure
    description: Estate closure steps and status tracking
  - name: Institution Contacts
    description: Financial institution contact information and departments
  - name: Phone Calls
    description: Twilio-powered phone calls with recording and summarization
  - name: Emails
    description: Email tool for sending forms and attachments
  - name: Notarization
    description: DocuSign-powered online notarization
  - name: Faxes
    description: One-click fax sending with receipts
  - name: Identity Verification
    description: Verify deceased and executor identity
  - name: Real Estate Valuations
    description: Automated property valuations and tax assessments
  - name: Life Insurance
    description: Life insurance policies and claims
  - name: Credit Cards & Debts
    description: Credit cards, loans, and debt management
  - name: Retirement Accounts
    description: 401(k), IRA, pension, and retirement account management
  - name: Investment Accounts
    description: Brokerage, stocks, bonds, and investment accounts
  - name: Real Estate Properties
    description: Real estate ownership, titles, and property management
  - name: Unclaimed Property
    description: Unclaimed property search and claims
  - name: Vehicles
    description: Vehicles, boats, and titled property
  - name: Business Ownership
    description: Business entities, ownership interests, and succession

components:
  schemas:
    Address:
      type: object
      properties:
        address1:
          type: string
          example: "123 Main Street"
        address2:
          type:
            - string
            - "null"
          example: null
        city:
          type: string
          example: "Salt Lake City"
        state:
          type: string
          minLength: 2
          maxLength: 2
          example: "UT"
        zip:
          type: string
          pattern: "^\\d{5}(-\\d{4})?$"
          example: "84101"

    PaginationMeta:
      type: object
      properties:
        page:
          type: integer
          example: 1
        per_page:
          type: integer
          example: 25
        total_count:
          type: integer
          example: 142
        total_pages:
          type: integer
          example: 6
        next_cursor:
          type:
            - string
            - "null"
          description: "Opaque cursor for fetching the next page. Pass as the `cursor` query parameter. Null when on the last page."
          example: "eyJpZCI6IjAxSzVXRjA2TUo2VDk5SFJZRTQ4QU43WE04In0="
        has_more:
          type: boolean
          description: "Whether more results exist beyond this page."
          example: true

    Error:
      type: object
      required:
        - error
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              example: "validation_error"
            message:
              type: string
              example: "The request body contains invalid fields."
            details:
              type: array
              items:
                type: object
                properties:
                  field:
                    type: string
                  message:
                    type: string

    Case:
      type: object
      properties:
        id:
          type: string
          example: "01K5WF06MJ6T99HRYE78AN7XM8"
        onboarding_id:
          type: string
          example: "01K5WET89VJ8HKBTMP3PS6KFBF"
        queue_assignment:
          type:
            - string
            - "null"
          example: "John's Queue"
        flow_position:
          type: string
          example: "Closure - Decisions - Initial"
        estate_value:
          type: string
          enum: [unknown, under_25k, 25k_to_100k, 100k_to_500k, 500k_to_1m, over_1m]
          example: "unknown"
        progress:
          type: string
          enum: [no_clue, just_started, making_progress, almost_done, completed]
          example: "no_clue"
        possible_dispute:
          type: string
          enum: [no_dispute_expected, possible_dispute, active_dispute]
          example: "no_dispute_expected"
        pending_searches:
          type: array
          items:
            type: string
          example: ["irs"]
        date_of_sign_up:
          type: string
          format: date-time
          example: "2025-09-23T10:30:00Z"
        terms_accepted_at:
          type: string
          format: date-time
          example: "2025-09-23T10:30:00Z"
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time

    CaseCreate:
      type: object
      required:
        - estate_value
        - progress
      properties:
        queue_assignment:
          type: string
        estate_value:
          type: string
          enum: [unknown, under_25k, 25k_to_100k, 100k_to_500k, 500k_to_1m, over_1m]
        progress:
          type: string
          enum: [no_clue, just_started, making_progress, almost_done, completed]
        possible_dispute:
          type: string
          enum: [no_dispute_expected, possible_dispute, active_dispute]

    CaseUpdate:
      type: object
      properties:
        queue_assignment:
          type: string
        flow_position:
          type: string
        estate_value:
          type: string
          enum: [unknown, under_25k, 25k_to_100k, 100k_to_500k, 500k_to_1m, over_1m]
        progress:
          type: string
          enum: [no_clue, just_started, making_progress, almost_done, completed]
        possible_dispute:
          type: string
          enum: [no_dispute_expected, possible_dispute, active_dispute]

    Deceased:
      type: object
      properties:
        full_name:
          type: string
          example: "John Jonas Johnson"
        first_name:
          type: string
          example: "John"
        middle_name:
          type:
            - string
            - "null"
          example: "Jonas"
        last_name:
          type: string
          example: "Johnson"
        date_of_birth:
          type: string
          format: date
          example: "1940-03-15"
        date_of_death:
          type: string
          format: date
          example: "2025-10-01"
        ssn:
          type: string
          description: "Masked in responses (last 4 digits only). Full SSN accepted on writes."
          example: "***-**-1234"
        address:
          $ref: "#/components/schemas/Address"
        email:
          type:
            - string
            - "null"
          format: email
          example: "jane@example.com"
        verification_level:
          type: string
          enum: [level_0, level_1, level_2, level_3]
          example: "level_2"

    DeceasedWrite:
      type: object
      required:
        - first_name
        - last_name
        - date_of_birth
        - date_of_death
      properties:
        first_name:
          type: string
        middle_name:
          type: string
        last_name:
          type: string
        date_of_birth:
          type: string
          format: date
        date_of_death:
          type: string
          format: date
        ssn:
          type: string
          description: "Full SSN (9 digits, no dashes)."
          example: "123456789"
        address:
          $ref: "#/components/schemas/Address"
        email:
          type: string
          format: email
        verification_level:
          type: string
          enum: [level_0, level_1, level_2, level_3]

    Executor:
      type: object
      properties:
        full_name:
          type: string
          example: "John Jonas Johnson"
        first_name:
          type: string
          example: "John"
        middle_name:
          type:
            - string
            - "null"
          example: "Jonas"
        last_name:
          type: string
          example: "Johnson"
        phone:
          type:
            - string
            - "null"
          example: "+11112223333"
        date_of_birth:
          type: string
          format: date
          example: "1990-06-20"
        address:
          $ref: "#/components/schemas/Address"
        email:
          type: string
          format: email
          example: "john.doe@example.com"
        relationship_to_deceased:
          type: string
          enum: [spouse, child, grandchild, grandchild_step_or_in_law, parent, sibling, niece_nephew, friend, other]
          example: "grandchild_step_or_in_law"
        verification_level:
          type: string
          enum: [level_0, level_1, level_2, level_3]
          example: "level_2"

    ExecutorWrite:
      type: object
      required:
        - first_name
        - last_name
        - email
        - relationship_to_deceased
      properties:
        first_name:
          type: string
        middle_name:
          type: string
        last_name:
          type: string
        phone:
          type: string
        date_of_birth:
          type: string
          format: date
        address:
          $ref: "#/components/schemas/Address"
        email:
          type: string
          format: email
        relationship_to_deceased:
          type: string
          enum: [spouse, child, grandchild, grandchild_step_or_in_law, parent, sibling, niece_nephew, friend, other]
        verification_level:
          type: string
          enum: [level_0, level_1, level_2, level_3]

    Authority:
      type: object
      properties:
        level:
          type: string
          enum: [level_0, level_1, level_2, level_3]
          example: "level_0"
        types:
          type: array
          items:
            type: string
            enum: [executor_in_will, trustee_in_trust, named_in_probate, had_power_of_attorney, next_of_kin, verbal_agreement, signed_waiver, helping_someone_with_authority, other]
          example: ["executor_in_will", "next_of_kin"]

    EIN:
      type: object
      properties:
        has_ein:
          type: boolean
          example: false
        ein:
          type:
            - string
            - "null"
          description: "Employer Identification Number in XX-XXXXXXX format."
          example: "12-3456789"

    FinancialAccount:
      type: object
      properties:
        id:
          type: string
          example: "01K5XA09BJ4T11HRYE78AN7ABC"
        type:
          type: string
          enum: [bank_account, debt, insurance, investment, retirement, property, vehicle, business, unclaimed_money]
          example: "bank_account"
        institution_name:
          type: string
          example: "Chase Bank"
        account_number:
          type: string
          description: "Masked in responses (last 4 digits only)."
          example: "***1234"
        balance:
          type:
            - number
            - "null"
          format: double
          example: 15230.50
        details:
          type:
            - string
            - "null"
          example: "Joint checking account"
        user_notes:
          type:
            - string
            - "null"
          example: "Need to contact branch for paperwork"
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time

    FinancialAccountWrite:
      type: object
      required:
        - type
        - institution_name
      properties:
        type:
          type: string
          enum: [bank_account, debt, insurance, investment, retirement, property, vehicle, business, unclaimed_money]
        institution_name:
          type: string
        account_number:
          type: string
          description: "Full account number."
        balance:
          type: number
          format: double
        details:
          type: string
        user_notes:
          type: string

    Document:
      type: object
      properties:
        id:
          type: string
          example: "01K5XB07CJ5T22HRYE78AN7DEF"
        type:
          type: string
          enum: [death_certificate, probate_document, bank_document, credit_report, birth_certificate, deceased_id, executor_id, property_report, will, trust_documents, other]
          example: "death_certificate"
        file_name:
          type: string
          example: "death_cert_scan.pdf"
        file_size_bytes:
          type: integer
          example: 245000
        mime_type:
          type: string
          example: "application/pdf"
        status:
          type: string
          enum: [uploaded, skipped, pending, rejected]
          example: "uploaded"
        uploaded_at:
          type: string
          format: date-time
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time

    Search:
      type: object
      properties:
        id:
          type: string
          example: "01K5XC08DJ6T33HRYE78AN7GHI"
        type:
          type: string
          enum: [real_estate, credit, investments, life_insurance, retirement, bank_accounts, businesses, vehicles, unclaimed_property]
          example: "real_estate"
        status:
          type: string
          enum: [pending, in_progress, completed, failed, cancelled]
          example: "completed"
        completed_at:
          type:
            - string
            - "null"
          format: date-time
          example: "2025-09-24T12:52:00Z"
        results_summary:
          type:
            - string
            - "null"
          example: "2 properties found in Cache County, UT"
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time

    SearchCreate:
      type: object
      required:
        - type
      properties:
        type:
          type: string
          enum: [real_estate, credit, investments, life_insurance, retirement, bank_accounts, businesses, vehicles, unclaimed_property]

    Person:
      type: object
      properties:
        id:
          type: string
          example: "01K5XD09EJ7T44HRYE78AN7JKL"
        first_name:
          type: string
          example: "John"
        middle_name:
          type:
            - string
            - "null"
          example: "Jonas"
        last_name:
          type: string
          example: "Johnson"
        suffix:
          type:
            - string
            - "null"
          example: null
        relationship:
          type: string
          example: "daughter"
        email:
          type:
            - string
            - "null"
          format: email
          example: "alice@example.com"
        phone:
          type:
            - string
            - "null"
          example: "+11112223333"
        is_beneficiary:
          type: boolean
          example: true
        possible_dispute:
          type: boolean
          example: false
        is_deceased:
          type: boolean
          example: false
        waiver_status:
          type: string
          enum: [no_waiver_needed, waiver_pending, waiver_signed, waiver_refused]
          example: "no_waiver_needed"
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time

    PersonWrite:
      type: object
      required:
        - first_name
        - last_name
      properties:
        first_name:
          type: string
        middle_name:
          type: string
        last_name:
          type: string
        suffix:
          type: string
        relationship:
          type: string
        email:
          type: string
          format: email
        phone:
          type: string
        is_beneficiary:
          type: boolean
        possible_dispute:
          type: boolean
        is_deceased:
          type: boolean
        waiver_status:
          type: string
          enum: [no_waiver_needed, waiver_pending, waiver_signed, waiver_refused]

    Goal:
      type: object
      properties:
        id:
          type: string
          example: "01K5XE10FJ8T55HRYE78AN7MNO"
        type:
          type: string
          enum: [discover_financial_accounts, discover_life_insurance, consolidate_finances, open_estate_bank_account, prepare_probate_documents, sell_real_estate]
          example: "discover_financial_accounts"
        status:
          type: string
          enum: [pending, in_progress, completed]
          example: "in_progress"
        completed_at:
          type:
            - string
            - "null"
          format: date-time
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time

    GoalCreate:
      type: object
      required:
        - type
      properties:
        type:
          type: string
          enum: [discover_financial_accounts, discover_life_insurance, consolidate_finances, open_estate_bank_account, prepare_probate_documents, sell_real_estate]

    # ---- Bank Accounts & Related Schemas ----
    BankAccount:
      type: object
      properties:
        id:
          type: string
          example: "01K6BA01AJ9T66HRYE78AN7PQR"
        institution_name:
          type: string
          example: "Chase Bank"
        institution_routing_number:
          type:
            - string
            - "null"
          example: "021000021"
        account_type:
          type: string
          enum: [checking, savings, cd, money_market, hsa, trust_account, estate_account, joint_account]
          example: "checking"
        account_number:
          type: string
          description: "Masked in responses (last 4 digits only)."
          example: "***5678"
        account_title:
          type:
            - string
            - "null"
          example: "John Johnson Living Trust Checking"
        ownership_type:
          type: string
          enum: [individual, joint_tenants_wros, tenants_in_common, pod_payable_on_death, tod_transfer_on_death, trust, estate]
          example: "individual"
        status:
          type: string
          enum: [open, closed, frozen, dormant, pending_closure, restricted]
          example: "open"
        current_balance:
          type:
            - number
            - "null"
          format: double
          example: 15230.50
        available_balance:
          type:
            - number
            - "null"
          format: double
          example: 14980.25
        currency:
          type: string
          default: "USD"
          example: "USD"
        interest_rate:
          type:
            - number
            - "null"
          format: double
          description: "Annual interest rate as a percentage. Relevant for savings, CDs, money market."
          example: 4.25
        maturity_date:
          type:
            - string
            - "null"
          format: date
          description: "Maturity date for CDs."
          example: "2026-06-15"
        opened_date:
          type:
            - string
            - "null"
          format: date
          example: "2010-03-20"
        closed_date:
          type:
            - string
            - "null"
          format: date
        branch_name:
          type:
            - string
            - "null"
          example: "Springfield Main Branch"
        branch_address:
          $ref: "#/components/schemas/Address"
        branch_phone:
          type:
            - string
            - "null"
          example: "+11112223333"
        online_access:
          type: boolean
          example: true
        has_overdraft_protection:
          type: boolean
          example: false
        is_estate_account:
          type: boolean
          description: "Whether this account was opened specifically for the estate."
          example: false
        closure_method:
          type:
            - string
            - "null"
          enum: [transfer_to_estate, instant_inheritance, check_mailed, transfer_to_beneficiary, pending, null]
          example: null
        instant_inheritance:
          $ref: "#/components/schemas/InstantInheritanceSummary"
        notes:
          type:
            - string
            - "null"
          example: "Need to visit branch with Letters Testamentary"
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time

    BankAccountWrite:
      type: object
      required:
        - institution_name
        - account_type
      properties:
        institution_name:
          type: string
        institution_routing_number:
          type: string
        account_type:
          type: string
          enum: [checking, savings, cd, money_market, hsa, trust_account, estate_account, joint_account]
        account_number:
          type: string
          description: "Full account number."
        account_title:
          type: string
        ownership_type:
          type: string
          enum: [individual, joint_tenants_wros, tenants_in_common, pod_payable_on_death, tod_transfer_on_death, trust, estate]
        status:
          type: string
          enum: [open, closed, frozen, dormant, pending_closure, restricted]
        current_balance:
          type: number
          format: double
        available_balance:
          type: number
          format: double
        currency:
          type: string
        interest_rate:
          type: number
          format: double
        maturity_date:
          type: string
          format: date
        opened_date:
          type: string
          format: date
        closed_date:
          type: string
          format: date
        branch_name:
          type: string
        branch_address:
          $ref: "#/components/schemas/Address"
        branch_phone:
          type: string
        online_access:
          type: boolean
        has_overdraft_protection:
          type: boolean
        is_estate_account:
          type: boolean
        closure_method:
          type: string
          enum: [transfer_to_estate, instant_inheritance, check_mailed, transfer_to_beneficiary, pending]
        notes:
          type: string

    Signer:
      type: object
      properties:
        id:
          type: string
          example: "01K6SG02BJ0T77HRYE78AN7STU"
        name:
          type: string
          example: "John Jonas Johnson"
        role:
          type: string
          enum: [primary_holder, joint_holder, authorized_signer, power_of_attorney, executor, trustee]
          example: "primary_holder"
        is_deceased:
          type: boolean
          example: true
        date_added:
          type:
            - string
            - "null"
          format: date
        date_removed:
          type:
            - string
            - "null"
          format: date

    SignerWrite:
      type: object
      required:
        - name
        - role
      properties:
        name:
          type: string
        role:
          type: string
          enum: [primary_holder, joint_holder, authorized_signer, power_of_attorney, executor, trustee]
        is_deceased:
          type: boolean
        date_added:
          type: string
          format: date
        date_removed:
          type: string
          format: date

    Transaction:
      type: object
      properties:
        id:
          type: string
          example: "01K6TX03CJ1T88HRYE78AN7VWX"
        date:
          type: string
          format: date
          example: "2025-09-15"
        posted_date:
          type:
            - string
            - "null"
          format: date
          example: "2025-09-16"
        effective_date:
          type:
            - string
            - "null"
          format: date
        type:
          type: string
          enum: [credit, debit, transfer_in, transfer_out, interest, fee, dividend, check, ach, wire, atm, pos, adjustment, estate_distribution]
          example: "debit"
        amount:
          type: number
          format: double
          example: -150.00
        running_balance:
          type:
            - number
            - "null"
          format: double
          example: 15080.50
        description:
          type: string
          example: "Electric Company Payment"
        merchant_name:
          type:
            - string
            - "null"
          example: "Springfield Electric Co."
        reference_number:
          type:
            - string
            - "null"
          example: "REF-2025-09-15-001"
        check_number:
          type:
            - string
            - "null"
          example: null
        category:
          type: string
          enum: [income, bills, insurance_premium, medical, taxes, estate_expense, legal_fee, funeral_expense, beneficiary_distribution, other]
          example: "bills"
        is_recurring:
          type: boolean
          example: true
        is_flagged:
          type: boolean
          example: false
        flag_reason:
          type:
            - string
            - "null"
          enum: [suspicious, needs_review, disputed, estate_related, null]
        notes:
          type:
            - string
            - "null"
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time

    TransactionWrite:
      type: object
      required:
        - date
        - type
        - amount
        - description
      properties:
        date:
          type: string
          format: date
        posted_date:
          type: string
          format: date
        effective_date:
          type: string
          format: date
        type:
          type: string
          enum: [credit, debit, transfer_in, transfer_out, interest, fee, dividend, check, ach, wire, atm, pos, adjustment, estate_distribution]
        amount:
          type: number
          format: double
        running_balance:
          type: number
          format: double
        description:
          type: string
        merchant_name:
          type: string
        reference_number:
          type: string
        check_number:
          type: string
        category:
          type: string
          enum: [income, bills, insurance_premium, medical, taxes, estate_expense, legal_fee, funeral_expense, beneficiary_distribution, other]
        is_recurring:
          type: boolean
        is_flagged:
          type: boolean
        flag_reason:
          type: string
          enum: [suspicious, needs_review, disputed, estate_related]
        notes:
          type: string

    RecurringPayment:
      type: object
      properties:
        id:
          type: string
          example: "01K6RP04DJ2T99HRYE78AN7YZA"
        payee_name:
          type: string
          example: "Springfield Electric Co."
        type:
          type: string
          enum: [direct_deposit, autopay, subscription, loan_payment, insurance_premium, utility, pension, social_security, annuity]
          example: "utility"
        amount:
          type: number
          format: double
          example: 150.00
        frequency:
          type: string
          enum: [weekly, biweekly, monthly, quarterly, annually]
          example: "monthly"
        next_payment_date:
          type:
            - string
            - "null"
          format: date
          example: "2025-10-15"
        last_payment_date:
          type:
            - string
            - "null"
          format: date
          example: "2025-09-15"
        status:
          type: string
          enum: [active, cancelled, paused, transferred]
          example: "active"
        cancellation_date:
          type:
            - string
            - "null"
          format: date
        cancelled_by:
          type:
            - string
            - "null"
        notes:
          type:
            - string
            - "null"
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time

    RecurringPaymentWrite:
      type: object
      required:
        - payee_name
        - type
        - amount
        - frequency
      properties:
        payee_name:
          type: string
        type:
          type: string
          enum: [direct_deposit, autopay, subscription, loan_payment, insurance_premium, utility, pension, social_security, annuity]
        amount:
          type: number
          format: double
        frequency:
          type: string
          enum: [weekly, biweekly, monthly, quarterly, annually]
        next_payment_date:
          type: string
          format: date
        last_payment_date:
          type: string
          format: date
        status:
          type: string
          enum: [active, cancelled, paused, transferred]
        cancellation_date:
          type: string
          format: date
        cancelled_by:
          type: string
        notes:
          type: string

    AccountBeneficiary:
      type: object
      properties:
        id:
          type: string
          example: "01K6AB05EJ3T10HRYE78AN7BCD"
        name:
          type: string
          example: "John Jonas Johnson"
        relationship:
          type: string
          example: "son"
        percentage_share:
          type: number
          format: double
          example: 50.0
        designation_type:
          type: string
          enum: [pod, tod]
          description: "POD = Payable on Death, TOD = Transfer on Death."
          example: "pod"
        is_contingent:
          type: boolean
          description: "true for contingent beneficiary, false for primary."
          example: false
        contact_info:
          type: object
          properties:
            email:
              type:
                - string
                - "null"
              format: email
            phone:
              type:
                - string
                - "null"
            address:
              $ref: "#/components/schemas/Address"
        status:
          type: string
          enum: [active, claimed, pending_verification]
          example: "active"
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time

    AccountBeneficiaryWrite:
      type: object
      required:
        - name
        - designation_type
      properties:
        name:
          type: string
        relationship:
          type: string
        percentage_share:
          type: number
          format: double
        designation_type:
          type: string
          enum: [pod, tod]
        is_contingent:
          type: boolean
        contact_info:
          type: object
          properties:
            email:
              type: string
              format: email
            phone:
              type: string
            address:
              $ref: "#/components/schemas/Address"
        status:
          type: string
          enum: [active, claimed, pending_verification]

    Statement:
      type: object
      properties:
        id:
          type: string
          example: "01K6ST06FJ4T11HRYE78AN7EFG"
        period_start:
          type: string
          format: date
          example: "2025-09-01"
        period_end:
          type: string
          format: date
          example: "2025-09-30"
        opening_balance:
          type: number
          format: double
          example: 15500.00
        closing_balance:
          type: number
          format: double
          example: 15230.50
        total_credits:
          type: number
          format: double
          example: 2500.00
        total_debits:
          type: number
          format: double
          example: 2769.50
        total_fees:
          type: number
          format: double
          example: 0.00
        file_name:
          type: string
          example: "statement_2025_09.pdf"
        file_size_bytes:
          type: integer
          example: 128000
        uploaded_at:
          type: string
          format: date-time

    BalanceSnapshot:
      type: object
      properties:
        date:
          type: string
          format: date
          example: "2025-09-30"
        balance:
          type: number
          format: double
          example: 15230.50
        available_balance:
          type:
            - number
            - "null"
          format: double
          example: 14980.25

    # ---- Instant Inheritance Schemas ----
    InstantInheritanceSummary:
      type: object
      description: |
        Instant Inheritance status for a bank account, embedded on every bank account resource.
      properties:
        eligibility:
          type: string
          enum: [eligible, ineligible]
          description: |
            Whether Sunset has approved this account for an Instant Inheritance transfer. Sunset
            re-evaluates continuously, so an account that reads `ineligible` may become `eligible`
            later without any action on your part.
          example: "eligible"
        max_transfer_amount:
          type:
            - number
            - "null"
          format: double
          description: "Largest amount that may be requested. Null unless `eligibility` is `eligible`."
          example: 15230.50
        active_transfer_id:
          type:
            - string
            - "null"
          description: "The in-flight transfer for this account, if one exists. Only one transfer may be in flight per account."
          example: null
        transferred_amount:
          type: number
          format: double
          description: "Total settled into the estate account from this account to date."
          example: 0
        evaluated_at:
          type:
            - string
            - "null"
          format: date-time
          example: "2026-08-24T14:02:11Z"

    Transfer:
      type: object
      description: "An Instant Inheritance transfer pulling funds from a deceased account holder's bank account into the case's estate account."
      properties:
        id:
          type: string
          example: "01K9TR01AJ0T55HRYE78AN7TRF"
        case_id:
          type: string
          example: "01K5WF06MJ6T99HRYE78AN7XM8"
        bank_account_id:
          type: string
          description: "The deceased's bank account the funds are pulled from."
          example: "01K6BA01AJ9T66HRYE78AN7PQR"
        estate_account_id:
          type: string
          description: "The FDIC-insured Sunset estate account the funds land in."
          example: "01K6BA07XJ9T66HRYE78AN7EST"
        method:
          type: string
          enum: [ach_debit]
          description: "Transfer rail. ACH debit is the only method at launch."
          example: "ach_debit"
        amount_requested:
          type: number
          format: double
          example: 15230.50
        amount_settled:
          type:
            - number
            - "null"
          format: double
          description: "Amount actually credited to the estate account. Null until the transfer settles."
          example: null
        currency:
          type: string
          default: "USD"
          example: "USD"
        status:
          type: string
          enum: [requested, verifying, approved, submitted, in_transit, completed, returned, rejected, cancelled]
          example: "in_transit"
        status_reason:
          type:
            - string
            - "null"
          description: "Explanation for a `rejected`, `returned`, or `cancelled` transfer."
          example: null
        return_code:
          type:
            - string
            - "null"
          description: "NACHA return code when `status` is `returned`."
          enum: [R01, R02, R03, R04, R08, R10, R16, R20, R29, null]
          example: null
        requested_by:
          type: string
          description: "User who requested the transfer."
          example: "01K8PU01AJ0T77HRYE78AN7AAA"
        requested_at:
          type: string
          format: date-time
          example: "2026-08-24T14:10:00Z"
        submitted_at:
          type:
            - string
            - "null"
          format: date-time
          example: "2026-08-24T21:00:00Z"
        expected_settlement_date:
          type:
            - string
            - "null"
          format: date
          description: "Business day the funds are expected in the estate account."
          example: "2026-08-27"
        settled_at:
          type:
            - string
            - "null"
          format: date-time
          example: null
        trace_number:
          type:
            - string
            - "null"
          description: "ACH trace number, available once submitted."
          example: "021000020000001"
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time

    TransferCreate:
      type: object
      required:
        - bank_account_id
      properties:
        bank_account_id:
          type: string
          description: "Bank account to pull from. Must have `instant_inheritance.eligibility` of `eligible`."
          example: "01K6BA01AJ9T66HRYE78AN7PQR"
        amount:
          type: number
          format: double
          description: |
            Amount to transfer. Omit to transfer the full confirmed available balance.
            Must not exceed `max_transfer_amount`.
          example: 15230.50
        estate_account_id:
          type: string
          description: "Destination estate account. Defaults to the case's primary estate account."
          example: "01K6BA07XJ9T66HRYE78AN7EST"
        notes:
          type: string
          description: "Internal note stored on the transfer record."
          example: "Requested after Letters Testamentary were accepted."

    # ---- Pro Users & Collaboration Schemas ----
    ProUser:
      type: object
      properties:
        id:
          type: string
          example: "01K8PU01AJ0T77HRYE78AN7AAA"
        email:
          type: string
          format: email
          example: "logan@example.com"
        first_name:
          type: string
          example: "John"
        last_name:
          type: string
          example: "Johnson"
        plan:
          type: string
          enum: [pro, enterprise]
          example: "pro"
        cases_limit:
          type:
            - integer
            - "null"
          description: "Maximum number of cases allowed. Null for unlimited (enterprise)."
          example: 50
        cases_count:
          type: integer
          description: "Current number of active cases."
          example: 12
        phone:
          type:
            - string
            - "null"
          example: "+11112223333"
        organization:
          type:
            - string
            - "null"
          example: "Johnson Estate Services"
        role:
          type: string
          enum: [owner, admin, member]
          description: "Role within their organization."
          example: "owner"
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time

    ProUserUpdate:
      type: object
      properties:
        first_name:
          type: string
        last_name:
          type: string
        phone:
          type: string
        organization:
          type: string

    ProUserCaseSummary:
      type: object
      description: "Abbreviated case info for pro user case listing."
      properties:
        id:
          type: string
        deceased_name:
          type: string
          example: "John Jonas Johnson"
        estate_value:
          type: string
        flow_position:
          type: string
        progress:
          type: string
        role:
          type: string
          enum: [owner, editor, viewer]
          description: "The pro user's role on this specific case."
          example: "owner"
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time

    Collaborator:
      type: object
      properties:
        id:
          type: string
          example: "01K8CL02BJ1T88HRYE78AN7BBB"
        user_id:
          type:
            - string
            - "null"
          description: "User ID if the collaborator has a Sunset account. Null if invite is pending."
        email:
          type: string
          format: email
          example: "edith@example.com"
        first_name:
          type:
            - string
            - "null"
          example: "John"
        last_name:
          type:
            - string
            - "null"
          example: "Johnson"
        role:
          type: string
          enum: [owner, editor, viewer]
          description: "Owner has full control. Editor can modify data. Viewer has read-only access."
          example: "editor"
        status:
          type: string
          enum: [pending, accepted, declined, revoked]
          example: "accepted"
        invited_at:
          type: string
          format: date-time
        accepted_at:
          type:
            - string
            - "null"
          format: date-time
        invited_by:
          type: string
          description: "User ID of the person who sent the invite."
        permissions:
          type: object
          description: "Granular permissions beyond the role."
          properties:
            can_manage_collaborators:
              type: boolean
              example: false
            can_manage_documents:
              type: boolean
              example: true
            can_manage_financials:
              type: boolean
              example: true
            can_manage_probate:
              type: boolean
              example: false
            can_use_tools:
              type: boolean
              description: "Can use phone, email, fax, and notarization tools."
              example: true
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time

    CollaboratorInvite:
      type: object
      required:
        - email
        - role
      properties:
        email:
          type: string
          format: email
        first_name:
          type: string
        last_name:
          type: string
        role:
          type: string
          enum: [editor, viewer]
          description: "Role to assign. Owner cannot be assigned via invite."
        permissions:
          type: object
          properties:
            can_manage_collaborators:
              type: boolean
            can_manage_documents:
              type: boolean
            can_manage_financials:
              type: boolean
            can_manage_probate:
              type: boolean
            can_use_tools:
              type: boolean
        message:
          type: string
          description: "Optional personal message included in the invitation email."

    CollaboratorUpdate:
      type: object
      properties:
        role:
          type: string
          enum: [editor, viewer]
        permissions:
          type: object
          properties:
            can_manage_collaborators:
              type: boolean
            can_manage_documents:
              type: boolean
            can_manage_financials:
              type: boolean
            can_manage_probate:
              type: boolean
            can_use_tools:
              type: boolean

    # ---- Closure Schemas ----
    ClosureStatus:
      type: object
      properties:
        overall_status:
          type: string
          enum: [not_started, in_progress, blocked, review, completed]
          example: "in_progress"
        completion_percentage:
          type: integer
          minimum: 0
          maximum: 100
          example: 45
        steps:
          type: array
          items:
            $ref: "#/components/schemas/ClosureStep"
        started_at:
          type:
            - string
            - "null"
          format: date-time
        completed_at:
          type:
            - string
            - "null"
          format: date-time

    ClosureStep:
      type: object
      properties:
        id:
          type: string
          example: "01K8CS03CJ2T99HRYE78AN7CCC"
        step_type:
          type: string
          enum:
            - notify_institutions
            - close_accounts
            - cancel_recurring_payments
            - pay_debts
            - file_final_taxes
            - obtain_tax_clearance
            - file_final_accounting
            - distribute_assets
            - close_estate_accounts
            - file_closing_documents
            - discharge_executor
          example: "notify_institutions"
        title:
          type: string
          example: "Notify Financial Institutions"
        description:
          type:
            - string
            - "null"
          example: "Contact all banks and financial institutions to notify them of the death and freeze accounts."
        status:
          type: string
          enum: [not_started, in_progress, blocked, waiting, completed, skipped]
          example: "in_progress"
        order:
          type: integer
          description: "Display order (1-based)."
          example: 1
        depends_on:
          type: array
          items:
            type: string
          description: "IDs of steps that must be completed before this one."
          example: []
        blocked_reason:
          type:
            - string
            - "null"
          example: null
        assigned_to:
          type:
            - string
            - "null"
          description: "Collaborator ID assigned to this step."
        due_date:
          type:
            - string
            - "null"
          format: date
        completed_date:
          type:
            - string
            - "null"
          format: date
        notes:
          type:
            - string
            - "null"
        sub_tasks:
          type: array
          items:
            type: object
            properties:
              id:
                type: string
              title:
                type: string
                example: "Contact Chase Bank"
              completed:
                type: boolean
                example: true
              institution_contact_id:
                type:
                  - string
                  - "null"
                description: "Reference to the institution contact used."
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time

    ClosureStepUpdate:
      type: object
      properties:
        status:
          type: string
          enum: [not_started, in_progress, blocked, waiting, completed, skipped]
        blocked_reason:
          type: string
        assigned_to:
          type: string
        due_date:
          type: string
          format: date
        completed_date:
          type: string
          format: date
        notes:
          type: string

    # ---- Institution Contact Schemas ----
    InstitutionContact:
      type: object
      properties:
        id:
          type: string
          example: "01K8IC04DJ3T10HRYE78AN7DDD"
        financial_account_id:
          type:
            - string
            - "null"
          description: "Reference to a specific financial account. Null if this is a general institution contact."
        institution_name:
          type: string
          example: "Chase Bank"
        department_name:
          type: string
          example: "Estate Services Department"
        is_default_contact:
          type: boolean
          description: "If true, this is the fallback contact when no specific department matches."
          example: false
        account_types:
          type: array
          items:
            type: string
            enum: [bank, debt, investment, retirement, insurance]
          description: "Account types this contact handles. Empty array means ALL account types."
          example: ["bank"]
        debt_subtypes:
          type: array
          items:
            type: string
            enum: [credit_card, mortgage_and_real_estate, auto_loans_and_leases, personal_loan, education, business_credit, collections, medical, secured_loan]
          description: "Only relevant if 'debt' is in account_types. Empty array means all debt types."
          example: []
        contact_methods:
          type: object
          properties:
            phone:
              type:
                - string
                - "null"
              example: "+11112223333"
            phone_hours:
              type:
                - string
                - "null"
              example: "Mon-Fri 8am-6pm EST"
            phone_extension:
              type:
                - string
                - "null"
            fax:
              type:
                - string
                - "null"
              example: "+11112223333"
            email:
              type:
                - string
                - "null"
              format: email
              example: "estates@chase.com"
            mailing_address:
              $ref: "#/components/schemas/Address"
            website:
              type:
                - string
                - "null"
              format: uri
              example: "https://www.chase.com/personal/estates"
        contact_person:
          type:
            - string
            - "null"
          example: "John Johnson"
        contact_title:
          type:
            - string
            - "null"
          example: "Estate Services Specialist"
        reference_number:
          type:
            - string
            - "null"
          description: "Case or reference number assigned by the institution."
          example: "EST-2025-00456"
        notes:
          type:
            - string
            - "null"
          example: "Ask for estate services team, reference case number."
        last_contacted:
          type:
            - string
            - "null"
          format: date-time
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time

    InstitutionContactWrite:
      type: object
      required:
        - institution_name
        - department_name
      properties:
        financial_account_id:
          type: string
        institution_name:
          type: string
        department_name:
          type: string
        is_default_contact:
          type: boolean
        account_types:
          type: array
          items:
            type: string
            enum: [bank, debt, investment, retirement, insurance]
        debt_subtypes:
          type: array
          items:
            type: string
            enum: [credit_card, mortgage_and_real_estate, auto_loans_and_leases, personal_loan, education, business_credit, collections, medical, secured_loan]
        contact_methods:
          type: object
          properties:
            phone:
              type: string
            phone_hours:
              type: string
            phone_extension:
              type: string
            fax:
              type: string
            email:
              type: string
              format: email
            mailing_address:
              $ref: "#/components/schemas/Address"
            website:
              type: string
              format: uri
        contact_person:
          type: string
        contact_title:
          type: string
        reference_number:
          type: string
        notes:
          type: string

    # ---- Phone Call Schemas ----
    PhoneCall:
      type: object
      properties:
        id:
          type: string
          example: "01K8PC05EJ4T11HRYE78AN7EEE"
        institution_contact_id:
          type:
            - string
            - "null"
          description: "Reference to the institution contact called."
        to_number:
          type: string
          example: "+11112223333"
        from_number:
          type: string
          description: "Twilio-provisioned number used for the call."
          example: "+11112223333"
        status:
          type: string
          enum: [initiated, ringing, in_progress, completed, failed, no_answer, busy, cancelled]
          example: "completed"
        direction:
          type: string
          enum: [outbound]
          example: "outbound"
        duration_seconds:
          type:
            - integer
            - "null"
          example: 342
        started_at:
          type:
            - string
            - "null"
          format: date-time
        ended_at:
          type:
            - string
            - "null"
          format: date-time
        recording_url:
          type:
            - string
            - "null"
          format: uri
          description: "URL to the call recording audio file."
        recording_duration_seconds:
          type:
            - integer
            - "null"
        recording_status:
          type:
            - string
            - "null"
          enum: [processing, completed, failed, null]
          example: "completed"
        transcript:
          type:
            - string
            - "null"
          description: "Full transcript of the call."
        summary:
          type:
            - string
            - "null"
          description: "AI-generated summary of the call contents and outcomes."
          example: "Called Chase estate services. Spoke with John Johnson. He confirmed they received the death certificate. Letters Testamentary are still needed before they can release account info. Ref# EST-2025-00456."
        action_items:
          type: array
          items:
            type: object
            properties:
              description:
                type: string
                example: "Mail Letters Testamentary to Chase Estate Services"
              completed:
                type: boolean
                example: false
          description: "AI-extracted action items from the call."
        called_by:
          type:
            - string
            - "null"
          description: "User ID of the person who initiated the call."
        twilio_call_sid:
          type:
            - string
            - "null"
          description: "Twilio Call SID for reference."
          example: "CAxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
        notes:
          type:
            - string
            - "null"
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time

    PhoneCallInitiate:
      type: object
      required:
        - to_number
      properties:
        to_number:
          type: string
          description: "Phone number to call in E.164 format."
        institution_contact_id:
          type: string
          description: "Optional reference to institution contact being called."
        notes:
          type: string
          description: "Pre-call notes or context."

    # ---- Email Schemas ----
    Email:
      type: object
      properties:
        id:
          type: string
          example: "01K8EM06FJ5T22HRYE78AN7FFF"
        institution_contact_id:
          type:
            - string
            - "null"
          description: "Reference to the institution contact emailed."
        to_addresses:
          type: array
          items:
            type: string
            format: email
          example: ["estates@chase.com"]
        cc_addresses:
          type: array
          items:
            type: string
            format: email
          example: []
        from_address:
          type: string
          format: email
          description: "Sunset-managed sender address."
          example: "cases@mail.example.com"
        subject:
          type: string
          example: "Estate of John J. Johnson - Death Certificate and Account Closure Request"
        body_text:
          type: string
          description: "Plain text version of the email body."
        body_html:
          type:
            - string
            - "null"
          description: "HTML version of the email body."
        attachments:
          type: array
          items:
            type: object
            properties:
              id:
                type: string
              file_name:
                type: string
                example: "death_certificate.pdf"
              file_size_bytes:
                type: integer
                example: 245000
              mime_type:
                type: string
                example: "application/pdf"
              document_id:
                type:
                  - string
                  - "null"
                description: "Reference to a case document, if attached from the case."
        status:
          type: string
          enum: [draft, queued, sent, delivered, bounced, failed]
          example: "delivered"
        sent_at:
          type:
            - string
            - "null"
          format: date-time
        delivered_at:
          type:
            - string
            - "null"
          format: date-time
        opened_at:
          type:
            - string
            - "null"
          format: date-time
          description: "Timestamp when the recipient opened the email (if tracking is available)."
        bounce_reason:
          type:
            - string
            - "null"
        sent_by:
          type:
            - string
            - "null"
          description: "User ID of the person who sent the email."
        receipt:
          type:
            - object
            - "null"
          description: "Delivery receipt details."
          properties:
            message_id:
              type: string
              example: "msg_01abc123def456"
            provider:
              type: string
              example: "sendgrid"
            status:
              type: string
              enum: [accepted, delivered, bounced, deferred]
            status_detail:
              type:
                - string
                - "null"
            timestamp:
              type: string
              format: date-time
        notes:
          type:
            - string
            - "null"
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time

    EmailSend:
      type: object
      required:
        - to_addresses
        - subject
        - body_text
      properties:
        to_addresses:
          type: array
          items:
            type: string
            format: email
        cc_addresses:
          type: array
          items:
            type: string
            format: email
        subject:
          type: string
        body_text:
          type: string
        body_html:
          type: string
        attachment_document_ids:
          type: array
          items:
            type: string
          description: "IDs of case documents to attach."
        institution_contact_id:
          type: string
        notes:
          type: string

    # ---- Notarization Schemas ----
    Notarization:
      type: object
      properties:
        id:
          type: string
          example: "01K8NT07GJ6T33HRYE78AN7GGG"
        document_id:
          type:
            - string
            - "null"
          description: "Reference to the case document being notarized."
        title:
          type: string
          example: "Small Estate Affidavit - Notarization"
        description:
          type:
            - string
            - "null"
          example: "Online notarization of small estate affidavit for Cache County filing."
        status:
          type: string
          enum: [draft, pending_signer, pending_notary, in_session, completed, declined, expired, failed]
          example: "completed"
        signers:
          type: array
          items:
            type: object
            properties:
              name:
                type: string
                example: "John Jonas Johnson"
              email:
                type: string
                format: email
                example: "john.doe@example.com"
              role:
                type: string
                enum: [signer, witness]
                example: "signer"
              status:
                type: string
                enum: [pending, signed, declined]
                example: "signed"
              signed_at:
                type:
                  - string
                  - "null"
                format: date-time
        notary_name:
          type:
            - string
            - "null"
          example: "John J. Johnson"
        notary_commission_state:
          type:
            - string
            - "null"
          example: "UT"
        notary_commission_number:
          type:
            - string
            - "null"
        notarized_at:
          type:
            - string
            - "null"
          format: date-time
        notarized_document_url:
          type:
            - string
            - "null"
          format: uri
          description: "URL to download the notarized document."
        docusign_envelope_id:
          type:
            - string
            - "null"
          description: "DocuSign envelope ID for reference."
          example: "env_01abc123-def4-5678-9abc-def012345678"
        session_url:
          type:
            - string
            - "null"
          format: uri
          description: "URL for the notarization session (while active)."
        expires_at:
          type:
            - string
            - "null"
          format: date-time
          description: "When the notarization request expires if not completed."
        initiated_by:
          type:
            - string
            - "null"
          description: "User ID of the person who initiated notarization."
        notes:
          type:
            - string
            - "null"
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time

    NotarizationCreate:
      type: object
      required:
        - title
        - signers
      properties:
        document_id:
          type: string
          description: "Case document to be notarized."
        title:
          type: string
        description:
          type: string
        signers:
          type: array
          items:
            type: object
            required:
              - name
              - email
              - role
            properties:
              name:
                type: string
              email:
                type: string
                format: email
              role:
                type: string
                enum: [signer, witness]
        notes:
          type: string

    # ---- Fax Schemas ----
    Fax:
      type: object
      properties:
        id:
          type: string
          example: "01K8FX08HJ7T44HRYE78AN7HHH"
        institution_contact_id:
          type:
            - string
            - "null"
          description: "Reference to the institution contact faxed."
        to_number:
          type: string
          example: "+11112223333"
        from_number:
          type: string
          description: "Sunset-managed fax number."
          example: "+11112223333"
        status:
          type: string
          enum: [queued, sending, delivered, failed, cancelled]
          example: "delivered"
        pages:
          type: integer
          example: 3
        document_ids:
          type: array
          items:
            type: string
          description: "Case document IDs that were faxed."
        cover_page:
          type: boolean
          description: "Whether a cover page was included."
          example: true
        cover_page_note:
          type:
            - string
            - "null"
          example: "Re: Estate of John J. Johnson. Please process enclosed death certificate and account closure form."
        sent_at:
          type:
            - string
            - "null"
          format: date-time
        delivered_at:
          type:
            - string
            - "null"
          format: date-time
        failed_reason:
          type:
            - string
            - "null"
          example: null
        receipt:
          type:
            - object
            - "null"
          description: "Fax delivery receipt."
          properties:
            confirmation_number:
              type: string
              example: "FAX-2025-1015-001"
            pages_sent:
              type: integer
              example: 3
            duration_seconds:
              type: integer
              example: 45
            status:
              type: string
              enum: [confirmed, partial, failed]
              example: "confirmed"
            remote_station_id:
              type:
                - string
                - "null"
              description: "The receiving fax machine's station ID."
            timestamp:
              type: string
              format: date-time
        sent_by:
          type:
            - string
            - "null"
          description: "User ID of the person who sent the fax."
        notes:
          type:
            - string
            - "null"
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time

    FaxSend:
      type: object
      required:
        - to_number
        - document_ids
      properties:
        to_number:
          type: string
          description: "Fax number in E.164 format."
        institution_contact_id:
          type: string
        document_ids:
          type: array
          items:
            type: string
          description: "Case document IDs to fax."
        cover_page:
          type: boolean
          default: true
        cover_page_note:
          type: string
        notes:
          type: string

    # ---- Identity Verification Schemas ----
    IdentityVerification:
      type: object
      properties:
        id:
          type: string
          example: "01K9IV01AJ0T55HRYE78AN7VVV"
        subject_type:
          type: string
          enum: [deceased, executor]
          description: "Who is being verified."
          example: "deceased"
        status:
          type: string
          enum: [not_started, pending, in_progress, verified, failed, expired, requires_manual_review]
          description: "Current verification status."
          example: "verified"
        verification_method:
          type: string
          enum: [ssdi_lookup, vital_records, credit_header, government_id, knowledge_based, manual_review]
          description: "Method used for verification."
          example: "ssdi_lookup"
        verification_level:
          type: string
          enum: [level_0, level_1, level_2, level_3]
          description: "Level 0 = unverified, Level 1 = basic info match, Level 2 = document-verified, Level 3 = government-verified."
          example: "level_2"
        checks:
          type: array
          description: "Individual verification checks performed."
          items:
            type: object
            properties:
              check_type:
                type: string
                enum: [name_match, dob_match, ssn_match, address_match, death_record_match, photo_id_match, liveness_check]
              status:
                type: string
                enum: [passed, failed, pending, skipped]
              checked_at:
                type:
                  - string
                  - "null"
                format: date-time
              details:
                type:
                  - string
                  - "null"
                description: "Additional context about the check result."
        document_ids:
          type: array
          items:
            type: string
          description: "Case document IDs submitted for verification (e.g., death certificate, government ID)."
        verified_at:
          type:
            - string
            - "null"
          format: date-time
        expires_at:
          type:
            - string
            - "null"
          format: date-time
          description: "When the verification expires and needs renewal."
        failure_reason:
          type:
            - string
            - "null"
          description: "Reason for verification failure, if applicable."
        notes:
          type:
            - string
            - "null"
        initiated_by:
          type:
            - string
            - "null"
          description: "User ID of who initiated the verification."
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time

    IdentityVerificationInitiate:
      type: object
      required:
        - subject_type
        - verification_method
      properties:
        subject_type:
          type: string
          enum: [deceased, executor]
        verification_method:
          type: string
          enum: [ssdi_lookup, vital_records, credit_header, government_id, knowledge_based, manual_review]
        document_ids:
          type: array
          items:
            type: string
          description: "Document IDs to use for verification (e.g., uploaded death certificate, driver's license)."
        notes:
          type: string

    # ---- Real Estate Valuation Schemas ----
    RealEstateValuation:
      type: object
      properties:
        id:
          type: string
          example: "01K9RE01AJ0T66HRYE78AN7WWW"
        financial_account_id:
          type: string
          description: "Reference to the financial account of type 'property'."
          example: "01K5XA09BJ4T11HRYE78AN7ABC"
        property_address:
          $ref: "#/components/schemas/Address"
        property_type:
          type: string
          enum: [single_family, multi_family, condo, townhouse, mobile_home, vacant_land, commercial, farm_ranch, mixed_use, other]
          example: "single_family"
        estimated_value:
          type:
            - number
            - "null"
          format: double
          description: "Current estimated market value."
          example: 385000.00
        valuation_source:
          type: string
          enum: [automated_avm, county_assessor, appraisal, comparative_market_analysis, owner_estimate, tax_assessment]
          description: "How the value was determined."
          example: "automated_avm"
        valuation_date:
          type:
            - string
            - "null"
          format: date
          description: "Date the valuation was performed."
          example: "2025-10-20"
        confidence_score:
          type:
            - number
            - "null"
          format: double
          description: "Confidence score of the valuation (0.0 to 1.0). Only available for automated valuations."
          example: 0.87
        tax_assessed_value:
          type:
            - number
            - "null"
          format: double
          description: "County tax assessed value."
          example: 310000.00
        tax_year:
          type:
            - integer
            - "null"
          example: 2025
        annual_property_tax:
          type:
            - number
            - "null"
          format: double
          example: 3250.00
        lot_size_sqft:
          type:
            - number
            - "null"
          format: double
          example: 8500
        living_area_sqft:
          type:
            - number
            - "null"
          format: double
          example: 2200
        bedrooms:
          type:
            - integer
            - "null"
          example: 4
        bathrooms:
          type:
            - number
            - "null"
          format: double
          description: "Full and half baths (e.g., 2.5)."
          example: 2.5
        year_built:
          type:
            - integer
            - "null"
          example: 1998
        parcel_number:
          type:
            - string
            - "null"
          description: "County parcel/APN number."
          example: "12-345-678-9"
        zoning:
          type:
            - string
            - "null"
          example: "Residential R-1"
        mortgage_balance:
          type:
            - number
            - "null"
          format: double
          description: "Outstanding mortgage balance, if known."
          example: 145000.00
        equity_estimate:
          type:
            - number
            - "null"
          format: double
          description: "Estimated equity (estimated_value - mortgage_balance)."
          example: 240000.00
        liens:
          type: array
          items:
            type: object
            properties:
              lien_type:
                type: string
                enum: [mortgage, home_equity, tax_lien, mechanics_lien, judgment_lien, hoa_lien, other]
              holder:
                type: string
              amount:
                type: number
                format: double
              recorded_date:
                type:
                  - string
                  - "null"
                format: date
        comparable_sales:
          type: array
          description: "Recent comparable property sales used in the valuation."
          items:
            type: object
            properties:
              address:
                type: string
              sale_price:
                type: number
                format: double
              sale_date:
                type: string
                format: date
              living_area_sqft:
                type: number
                format: double
              distance_miles:
                type: number
                format: double
        status:
          type: string
          enum: [pending, completed, failed, stale]
          description: "Valuation status. 'stale' indicates the valuation is older than 90 days."
          example: "completed"
        notes:
          type:
            - string
            - "null"
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time

    RealEstateValuationRequest:
      type: object
      required:
        - property_address
      properties:
        financial_account_id:
          type: string
          description: "Link to an existing financial account of type 'property'."
        property_address:
          $ref: "#/components/schemas/Address"
        property_type:
          type: string
          enum: [single_family, multi_family, condo, townhouse, mobile_home, vacant_land, commercial, farm_ranch, mixed_use, other]
        valuation_source:
          type: string
          enum: [automated_avm, county_assessor, appraisal, comparative_market_analysis, owner_estimate, tax_assessment]
          default: automated_avm
        mortgage_balance:
          type: number
          format: double
        notes:
          type: string

    # ---- Life Insurance Schemas ----
    LifeInsurancePolicy:
      type: object
      properties:
        id:
          type: string
          example: "01K9LI01AJ0T11HRYE78AN7LLL"
        case_id:
          type: string
        policy_type:
          type: string
          enum: [term_life, whole_life, universal_life, variable_life, group_employer, group_government, supplemental, accidental_death, annuity_with_death_benefit]
          example: "whole_life"
        carrier_name:
          type: string
          example: "Northwestern Mutual"
        policy_number:
          type:
            - string
            - "null"
          description: "Masked in responses (last 4 digits only)."
          example: "***1234"
        status:
          type: string
          enum: [active, inactive, lapsed, claimed, paid_out, denied, unknown]
          example: "active"
        death_benefit:
          type:
            - number
            - "null"
          format: double
          description: "Face value / death benefit amount."
          example: 250000.00
        cash_value:
          type:
            - number
            - "null"
          format: double
          description: "Accumulated cash value (whole/universal life only)."
          example: 45000.00
        beneficiaries:
          type: array
          items:
            type: object
            properties:
              name:
                type: string
              relationship:
                type: string
              percentage_share:
                type: number
                format: double
              designation:
                type: string
                enum: [primary, contingent]
              is_irrevocable:
                type: boolean
        premium_status:
          type:
            - string
            - "null"
          enum: [current, past_due, waived, paid_up, null]
        employer_name:
          type:
            - string
            - "null"
          description: "For group/employer-provided policies."
        claim_status:
          type:
            - string
            - "null"
          enum: [not_filed, filed, under_review, approved, paid, denied, null]
        claim_filed_date:
          type:
            - string
            - "null"
          format: date
        claim_paid_date:
          type:
            - string
            - "null"
          format: date
        claim_paid_amount:
          type:
            - number
            - "null"
          format: double
        institution_contact_id:
          type:
            - string
            - "null"
        notes:
          type:
            - string
            - "null"
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time

    LifeInsurancePolicyWrite:
      type: object
      required:
        - policy_type
        - carrier_name
      properties:
        policy_type:
          type: string
          enum: [term_life, whole_life, universal_life, variable_life, group_employer, group_government, supplemental, accidental_death, annuity_with_death_benefit]
        carrier_name:
          type: string
        policy_number:
          type: string
          description: "Full policy number."
        status:
          type: string
          enum: [active, inactive, lapsed, claimed, paid_out, denied, unknown]
        death_benefit:
          type: number
          format: double
        cash_value:
          type: number
          format: double
        beneficiaries:
          type: array
          items:
            type: object
            properties:
              name:
                type: string
              relationship:
                type: string
              percentage_share:
                type: number
                format: double
              designation:
                type: string
                enum: [primary, contingent]
              is_irrevocable:
                type: boolean
        employer_name:
          type: string
        claim_status:
          type: string
          enum: [not_filed, filed, under_review, approved, paid, denied]
        claim_filed_date:
          type: string
          format: date
        institution_contact_id:
          type: string
        notes:
          type: string

    # ---- Credit Cards & Debts Schemas ----
    CreditCardDebt:
      type: object
      properties:
        id:
          type: string
          example: "01K9CD01AJ0T22HRYE78AN7CCC"
        case_id:
          type: string
        debt_type:
          type: string
          enum: [AGR, AUL, AUT, AO, ATY, BCC, BMP, BPG, BUS, "C/C", "C/G", "C/M", "C/S", CCP, CEL, CGA, CHG, CIL, CKG, CLC, CLS, COL, CON, COS, CRC, CSA, CSL, "D/C", DCS, DEP, EDU, EXM, "F/C", "F/S", FCO, FHA, FMH, FSC, "G/B", "G/F", "G/G", GEA, GFS, GMD, GOP, "H+O", "H/E", HEI, "H/I", HHG, "I/L", INS, ISC, LBP, LEA, LPI, LIC, "M/H", MED, MRI, NCS, NTE, "P/S", PHG, PPI, "R/C", "R/E", "R/F", "R/O", "R/S", "R/V", RCK, REC, REN, RES, "S/S", SCC, SAA, SC0, SDL, SEC, SGL, SHI, SMP, SUM, TSL, UDL, UGL, UNK, UNS, UTI, ZZZ, "7B", "3A", "00", "95", "8A", "85", "9B", "10", "15", "98", "6B", "93", "37", "4D", "6C", "07", G1, "96", "7A", "47", "48", "91", "14", "18", "5C", "0F", "43", "34", "8B", "12", "33", "16", "50", "0C", "05", "2C", "75", "71", "69", "73", "72", "74", "70", "23", "89", "6D", "04", "22", "78", "49", "06", "1B", "13", "1A", "3C", "17", "90", "86", "21", "20", "03", "1C", "83", "26", "08", "19", "27", "5B", "25", "77", "11", "29", "5A", "94", "2A", "7C", "09", "68", "02", "66", "9A", "87", "30", "0A", "67", "65", "31", "01", "92", ZZ, "0G"]
          example: "CRC"
        creditor_name:
          type: string
          example: "Capital One"
        account_number:
          type:
            - string
            - "null"
          description: "Masked in responses (last 4 digits only)."
          example: "***5678"
        condition:
          type: string
          enum: [DECEASED, CHARGEOFF, BANKRUPTCY, TRANSFER, REPOSSESSION, CLOSED, BANKRUPTCYPET, COLLECTIONS, DELINQUENT120, DELINQUENT90, DELINQUENT60, DELINQUENT30, REFINANCED, LOST, OPEN, PAID, UNKNOWN]
          example: "OPEN"
        responsibility:
          type:
            - string
            - "null"
          enum: ["1", B, I, "8", C, "5", S, "2", J, "4", P, "3", A, "7", M, "0", O, U, "9", T, X, null]
          description: "The deceased's responsibility for the debt."
          example: "I"
        balance:
          type:
            - number
            - "null"
          format: double
          description: "Current outstanding balance."
          example: 4523.89
        credit_limit:
          type:
            - number
            - "null"
          format: double
        minimum_payment:
          type:
            - number
            - "null"
          format: double
        interest_rate:
          type:
            - number
            - "null"
          format: double
          description: "APR as a percentage."
          example: 24.99
        is_joint_account:
          type: boolean
          description: "Whether a surviving spouse or co-signer is liable."
          example: false
        joint_holder_name:
          type:
            - string
            - "null"
        collection_agency:
          type:
            - string
            - "null"
          description: "If in collections, the agency handling the debt."
        original_creditor:
          type:
            - string
            - "null"
          description: "Original creditor if the debt was sold/transferred."
        credit_bureau_source:
          type:
            - string
            - "null"
          enum: [experian, equifax, transunion, null]
        last_payment_date:
          type:
            - string
            - "null"
          format: date
        notification_status:
          type: string
          enum: [not_notified, notified, acknowledged, resolved]
          description: "Whether the creditor has been notified of the death."
          example: "not_notified"
        notification_date:
          type:
            - string
            - "null"
          format: date
        institution_contact_id:
          type:
            - string
            - "null"
        notes:
          type:
            - string
            - "null"
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time

    CreditCardDebtWrite:
      type: object
      required:
        - debt_type
        - creditor_name
      properties:
        debt_type:
          type: string
          enum: [AGR, AUL, AUT, AO, ATY, BCC, BMP, BPG, BUS, "C/C", "C/G", "C/M", "C/S", CCP, CEL, CGA, CHG, CIL, CKG, CLC, CLS, COL, CON, COS, CRC, CSA, CSL, "D/C", DCS, DEP, EDU, EXM, "F/C", "F/S", FCO, FHA, FMH, FSC, "G/B", "G/F", "G/G", GEA, GFS, GMD, GOP, "H+O", "H/E", HEI, "H/I", HHG, "I/L", INS, ISC, LBP, LEA, LPI, LIC, "M/H", MED, MRI, NCS, NTE, "P/S", PHG, PPI, "R/C", "R/E", "R/F", "R/O", "R/S", "R/V", RCK, REC, REN, RES, "S/S", SCC, SAA, SC0, SDL, SEC, SGL, SHI, SMP, SUM, TSL, UDL, UGL, UNK, UNS, UTI, ZZZ, "7B", "3A", "00", "95", "8A", "85", "9B", "10", "15", "98", "6B", "93", "37", "4D", "6C", "07", G1, "96", "7A", "47", "48", "91", "14", "18", "5C", "0F", "43", "34", "8B", "12", "33", "16", "50", "0C", "05", "2C", "75", "71", "69", "73", "72", "74", "70", "23", "89", "6D", "04", "22", "78", "49", "06", "1B", "13", "1A", "3C", "17", "90", "86", "21", "20", "03", "1C", "83", "26", "08", "19", "27", "5B", "25", "77", "11", "29", "5A", "94", "2A", "7C", "09", "68", "02", "66", "9A", "87", "30", "0A", "67", "65", "31", "01", "92", ZZ, "0G"]
        creditor_name:
          type: string
        account_number:
          type: string
          description: "Full account number."
        condition:
          type: string
          enum: [DECEASED, CHARGEOFF, BANKRUPTCY, TRANSFER, REPOSSESSION, CLOSED, BANKRUPTCYPET, COLLECTIONS, DELINQUENT120, DELINQUENT90, DELINQUENT60, DELINQUENT30, REFINANCED, LOST, OPEN, PAID, UNKNOWN]
        responsibility:
          type:
            - string
            - "null"
          enum: ["1", B, I, "8", C, "5", S, "2", J, "4", P, "3", A, "7", M, "0", O, U, "9", T, X, null]
          description: "The deceased's responsibility for the debt."
        balance:
          type: number
          format: double
        credit_limit:
          type: number
          format: double
        interest_rate:
          type: number
          format: double
        is_joint_account:
          type: boolean
        joint_holder_name:
          type: string
        collection_agency:
          type: string
        original_creditor:
          type: string
        notification_status:
          type: string
          enum: [not_notified, notified, acknowledged, resolved]
        institution_contact_id:
          type: string
        notes:
          type: string

    # ---- Retirement Accounts Schemas ----
    RetirementAccount:
      type: object
      properties:
        id:
          type: string
          example: "01K9RA01AJ0T33HRYE78AN7RRR"
        case_id:
          type: string
        account_type:
          type: string
          enum: [traditional_ira, roth_ira, "401k", "403b", "457", sep_ira, simple_ira, keogh, pension, tsp, military_pension, fegli, inherited_ira, other]
          example: "401k"
        custodian_name:
          type: string
          description: "Financial institution holding the account."
          example: "Fidelity Investments"
        account_number:
          type:
            - string
            - "null"
          description: "Masked in responses (last 4 digits only)."
          example: "***9012"
        status:
          type: string
          enum: [active, inactive, dormant, distributed, rolled_over, closed, unknown]
          example: "active"
        balance:
          type:
            - number
            - "null"
          format: double
          example: 185000.00
        employer_name:
          type:
            - string
            - "null"
          description: "Employer associated with the plan."
          example: "Acme Corporation"
        beneficiaries:
          type: array
          items:
            type: object
            properties:
              name:
                type: string
              relationship:
                type: string
              percentage_share:
                type: number
                format: double
              designation:
                type: string
                enum: [primary, contingent]
        distribution_options:
          type: array
          items:
            type: string
            enum: [lump_sum, rollover_to_inherited_ira, periodic_payments, five_year_rule, life_expectancy]
          description: "Available distribution methods for beneficiaries."
        rmd_required:
          type: boolean
          description: "Whether Required Minimum Distributions apply."
          example: true
        rmd_amount:
          type:
            - number
            - "null"
          format: double
        tax_treatment:
          type:
            - string
            - "null"
          enum: [pre_tax, post_tax_roth, mixed, null]
          description: "Tax treatment of the account balance."
        distribution_status:
          type: string
          enum: [not_started, in_progress, completed, pending_beneficiary_docs]
          example: "not_started"
        institution_contact_id:
          type:
            - string
            - "null"
        notes:
          type:
            - string
            - "null"
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time

    RetirementAccountWrite:
      type: object
      required:
        - account_type
        - custodian_name
      properties:
        account_type:
          type: string
          enum: [traditional_ira, roth_ira, "401k", "403b", "457", sep_ira, simple_ira, keogh, pension, tsp, military_pension, fegli, inherited_ira, other]
        custodian_name:
          type: string
        account_number:
          type: string
        status:
          type: string
          enum: [active, inactive, dormant, distributed, rolled_over, closed, unknown]
        balance:
          type: number
          format: double
        employer_name:
          type: string
        beneficiaries:
          type: array
          items:
            type: object
            properties:
              name:
                type: string
              relationship:
                type: string
              percentage_share:
                type: number
                format: double
              designation:
                type: string
                enum: [primary, contingent]
        distribution_options:
          type: array
          items:
            type: string
            enum: [lump_sum, rollover_to_inherited_ira, periodic_payments, five_year_rule, life_expectancy]
        rmd_required:
          type: boolean
        tax_treatment:
          type: string
          enum: [pre_tax, post_tax_roth, mixed]
        distribution_status:
          type: string
          enum: [not_started, in_progress, completed, pending_beneficiary_docs]
        institution_contact_id:
          type: string
        notes:
          type: string

    # ---- Investment Accounts Schemas ----
    InvestmentAccount:
      type: object
      properties:
        id:
          type: string
          example: "01K9IA01AJ0T44HRYE78AN7III"
        case_id:
          type: string
        account_type:
          type: string
          enum: [brokerage, mutual_fund, etf, individual_stocks, individual_bonds, index_fund, managed_account, "529_plan", drip, private_equity, alternative_investment, hsa, msa, cryptocurrency, other]
          example: "brokerage"
        custodian_name:
          type: string
          description: "Brokerage or platform holding the account."
          example: "Charles Schwab"
        account_number:
          type:
            - string
            - "null"
          description: "Masked in responses (last 4 digits only)."
          example: "***3456"
        status:
          type: string
          enum: [active, inactive, frozen, transferred, liquidated, closed, unknown]
          example: "active"
        balance:
          type:
            - number
            - "null"
          format: double
          description: "Total account value."
          example: 92500.00
        holdings:
          type: array
          description: "Individual holdings within the account."
          items:
            type: object
            properties:
              symbol:
                type: string
                example: "AAPL"
              name:
                type: string
                example: "Apple Inc."
              quantity:
                type: number
                format: double
              market_value:
                type: number
                format: double
              cost_basis:
                type:
                  - number
                  - "null"
                format: double
              asset_class:
                type: string
                enum: [stock, bond, mutual_fund, etf, option, cryptocurrency, cash, other]
        beneficiaries:
          type: array
          items:
            type: object
            properties:
              name:
                type: string
              relationship:
                type: string
              percentage_share:
                type: number
                format: double
              designation:
                type: string
                enum: [primary, contingent, tod]
        date_of_death_value:
          type:
            - number
            - "null"
          format: double
          description: "Account value on the date of death (for stepped-up cost basis)."
        transfer_status:
          type: string
          enum: [not_started, paperwork_submitted, in_review, transferred, liquidated]
          example: "not_started"
        institution_contact_id:
          type:
            - string
            - "null"
        notes:
          type:
            - string
            - "null"
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time

    InvestmentAccountWrite:
      type: object
      required:
        - account_type
        - custodian_name
      properties:
        account_type:
          type: string
          enum: [brokerage, mutual_fund, etf, individual_stocks, individual_bonds, index_fund, managed_account, "529_plan", drip, private_equity, alternative_investment, hsa, msa, cryptocurrency, other]
        custodian_name:
          type: string
        account_number:
          type: string
        status:
          type: string
          enum: [active, inactive, frozen, transferred, liquidated, closed, unknown]
        balance:
          type: number
          format: double
        holdings:
          type: array
          items:
            type: object
            properties:
              symbol:
                type: string
              name:
                type: string
              quantity:
                type: number
                format: double
              market_value:
                type: number
                format: double
              cost_basis:
                type: number
                format: double
              asset_class:
                type: string
                enum: [stock, bond, mutual_fund, etf, option, cryptocurrency, cash, other]
        date_of_death_value:
          type: number
          format: double
        transfer_status:
          type: string
          enum: [not_started, paperwork_submitted, in_review, transferred, liquidated]
        institution_contact_id:
          type: string
        notes:
          type: string

    # ---- Real Estate Properties Schemas ----
    RealEstateProperty:
      type: object
      properties:
        id:
          type: string
          example: "01K9RP01AJ0T55HRYE78AN7PPP"
        case_id:
          type: string
        property_type:
          type: string
          enum: [primary_residence, vacation_home, investment_property, rental_property, vacant_land, commercial, farm_ranch, mixed_use, other]
          example: "primary_residence"
        address:
          $ref: "#/components/schemas/Address"
        ownership_type:
          type: string
          enum: [sole_ownership, joint_tenancy, tenants_in_common, community_property, transfer_on_death_deed, lady_bird_deed, trust, life_estate, other]
          example: "sole_ownership"
        title_vesting:
          type:
            - string
            - "null"
          description: "How the title is vested."
          example: "John J. Johnson, a single man"
        co_owners:
          type: array
          items:
            type: object
            properties:
              name:
                type: string
              relationship:
                type: string
              ownership_share:
                type:
                  - number
                  - "null"
                format: double
        estimated_value:
          type:
            - number
            - "null"
          format: double
          example: 385000.00
        assessed_value:
          type:
            - number
            - "null"
          format: double
        outstanding_mortgage:
          type:
            - number
            - "null"
          format: double
        mortgage_holder:
          type:
            - string
            - "null"
        equity_estimate:
          type:
            - number
            - "null"
          format: double
        liens:
          type: array
          items:
            type: object
            properties:
              lien_type:
                type: string
                enum: [mortgage, heloc, tax_lien, mechanics_lien, judgment_lien, hoa_lien, other]
              holder:
                type: string
              amount:
                type: number
                format: double
              recorded_date:
                type:
                  - string
                  - "null"
                format: date
        annual_property_tax:
          type:
            - number
            - "null"
          format: double
        parcel_number:
          type:
            - string
            - "null"
        deed_type:
          type:
            - string
            - "null"
          enum: [warranty, quitclaim, grant, special_warranty, transfer_on_death, lady_bird, null]
        rental_income:
          type:
            - number
            - "null"
          format: double
          description: "Monthly rental income if property is rented."
        is_homestead:
          type: boolean
          description: "Whether the property qualifies as a homestead for exemption purposes."
        requires_probate:
          type: boolean
          description: "Whether the property must go through probate (based on ownership type)."
        status:
          type: string
          enum: [owned, pending_transfer, listed_for_sale, sold, transferred, in_probate, unknown]
          example: "owned"
        valuation_id:
          type:
            - string
            - "null"
          description: "Link to a real estate valuation record."
        institution_contact_id:
          type:
            - string
            - "null"
        notes:
          type:
            - string
            - "null"
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time

    RealEstatePropertyWrite:
      type: object
      required:
        - property_type
        - address
      properties:
        property_type:
          type: string
          enum: [primary_residence, vacation_home, investment_property, rental_property, vacant_land, commercial, farm_ranch, mixed_use, other]
        address:
          $ref: "#/components/schemas/Address"
        ownership_type:
          type: string
          enum: [sole_ownership, joint_tenancy, tenants_in_common, community_property, transfer_on_death_deed, lady_bird_deed, trust, life_estate, other]
        title_vesting:
          type: string
        co_owners:
          type: array
          items:
            type: object
            properties:
              name:
                type: string
              relationship:
                type: string
              ownership_share:
                type: number
                format: double
        estimated_value:
          type: number
          format: double
        outstanding_mortgage:
          type: number
          format: double
        mortgage_holder:
          type: string
        annual_property_tax:
          type: number
          format: double
        parcel_number:
          type: string
        deed_type:
          type: string
          enum: [warranty, quitclaim, grant, special_warranty, transfer_on_death, lady_bird]
        rental_income:
          type: number
          format: double
        is_homestead:
          type: boolean
        institution_contact_id:
          type: string
        notes:
          type: string

    # ---- Unclaimed Property Schemas ----
    UnclaimedProperty:
      type: object
      properties:
        id:
          type: string
          example: "01K9UP01AJ0T66HRYE78AN7UUU"
        case_id:
          type: string
        property_type:
          type: string
          enum: [dormant_bank_account, uncashed_check, insurance_proceeds, utility_deposit, rental_deposit, safe_deposit_box, stocks_bonds, retirement_account, gift_card, insurance_refund, mineral_rights, wages, refund, other]
          example: "dormant_bank_account"
        holder_name:
          type:
            - string
            - "null"
          description: "Institution or entity holding the property."
          example: "State of Illinois"
        state:
          type: string
          minLength: 2
          maxLength: 2
          description: "US state where the property is held."
          example: "IL"
        reported_amount:
          type:
            - number
            - "null"
          format: double
          example: 1250.00
        property_description:
          type:
            - string
            - "null"
          example: "Dormant checking account"
        owner_name_on_record:
          type:
            - string
            - "null"
          description: "Name as it appears in the unclaimed property database."
          example: "JANE M DOE"
        claim_status:
          type: string
          enum: [discovered, claim_filed, under_review, approved, paid, denied, expired]
          example: "discovered"
        claim_url:
          type:
            - string
            - "null"
          description: "Direct link to the state claim portal."
        claim_filed_date:
          type:
            - string
            - "null"
          format: date
        claim_approved_date:
          type:
            - string
            - "null"
          format: date
        claim_paid_amount:
          type:
            - number
            - "null"
          format: double
        required_documents:
          type: array
          items:
            type: string
            enum: [death_certificate, letters_testamentary, letters_of_administration, affidavit, government_id, proof_of_heirship]
          description: "Documents required to file the claim."
        document_ids:
          type: array
          items:
            type: string
          description: "Case document IDs submitted with the claim."
        notes:
          type:
            - string
            - "null"
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time

    UnclaimedPropertyWrite:
      type: object
      required:
        - property_type
        - state
      properties:
        property_type:
          type: string
          enum: [dormant_bank_account, uncashed_check, insurance_proceeds, utility_deposit, rental_deposit, safe_deposit_box, stocks_bonds, retirement_account, gift_card, insurance_refund, mineral_rights, wages, refund, other]
        holder_name:
          type: string
        state:
          type: string
          minLength: 2
          maxLength: 2
        reported_amount:
          type: number
          format: double
        property_description:
          type: string
        owner_name_on_record:
          type: string
        claim_url:
          type: string
        claim_status:
          type: string
          enum: [discovered, claim_filed, under_review, approved, paid, denied, expired]
        required_documents:
          type: array
          items:
            type: string
            enum: [death_certificate, letters_testamentary, letters_of_administration, affidavit, government_id, proof_of_heirship]
        document_ids:
          type: array
          items:
            type: string
        notes:
          type: string

    # ---- Vehicles Schemas ----
    Vehicle:
      type: object
      properties:
        id:
          type: string
          example: "01K9VH01AJ0T77HRYE78AN7VVV"
        case_id:
          type: string
        vehicle_type:
          type: string
          enum: [automobile, motorcycle, recreational_vehicle, boat, commercial_vehicle, classic_car, trailer, off_highway_vehicle, farm_equipment, aircraft, other]
          example: "automobile"
        year:
          type:
            - integer
            - "null"
          example: 2019
        make:
          type:
            - string
            - "null"
          example: "Toyota"
        model:
          type:
            - string
            - "null"
          example: "Camry"
        vin:
          type:
            - string
            - "null"
          description: "Vehicle Identification Number. Masked in responses (last 6 digits only)."
          example: "***ABC123"
        license_plate:
          type:
            - string
            - "null"
        registration_state:
          type:
            - string
            - "null"
          minLength: 2
          maxLength: 2
          example: "UT"
        title_status:
          type: string
          enum: [clean, salvage, rebuilt, lien_present, missing, unknown]
          example: "clean"
        ownership_type:
          type: string
          enum: [sole_owner, joint_owner, transfer_on_death, leased, other]
          example: "sole_owner"
        co_owner_name:
          type:
            - string
            - "null"
        estimated_value:
          type:
            - number
            - "null"
          format: double
          example: 18500.00
        valuation_source:
          type:
            - string
            - "null"
          enum: [kelley_blue_book, nada, edmunds, appraisal, owner_estimate, null]
        lien_holder:
          type:
            - string
            - "null"
          description: "Bank or finance company holding the lien."
        lien_payoff_amount:
          type:
            - number
            - "null"
          format: double
        equity_estimate:
          type:
            - number
            - "null"
          format: double
        mileage:
          type:
            - integer
            - "null"
          example: 45000
        condition:
          type:
            - string
            - "null"
          enum: [excellent, good, fair, poor, null]
        location:
          type:
            - string
            - "null"
          description: "Where the vehicle is currently located."
        disposition:
          type: string
          enum: [keep, transfer_to_heir, sell, donate, junk, pending_decision]
          example: "pending_decision"
        disposition_details:
          type:
            - object
            - "null"
          properties:
            transferred_to:
              type: string
            sale_price:
              type: number
              format: double
            sale_date:
              type: string
              format: date
            buyer_name:
              type: string
        title_transfer_status:
          type: string
          enum: [not_started, dmv_paperwork_filed, title_transferred, completed]
          example: "not_started"
        institution_contact_id:
          type:
            - string
            - "null"
        notes:
          type:
            - string
            - "null"
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time

    VehicleWrite:
      type: object
      required:
        - vehicle_type
      properties:
        vehicle_type:
          type: string
          enum: [automobile, motorcycle, recreational_vehicle, boat, commercial_vehicle, classic_car, trailer, off_highway_vehicle, farm_equipment, aircraft, other]
        year:
          type: integer
        make:
          type: string
        model:
          type: string
        vin:
          type: string
          description: "Full VIN."
        license_plate:
          type: string
        registration_state:
          type: string
          minLength: 2
          maxLength: 2
        title_status:
          type: string
          enum: [clean, salvage, rebuilt, lien_present, missing, unknown]
        ownership_type:
          type: string
          enum: [sole_owner, joint_owner, transfer_on_death, leased, other]
        co_owner_name:
          type: string
        estimated_value:
          type: number
          format: double
        valuation_source:
          type: string
          enum: [kelley_blue_book, nada, edmunds, appraisal, owner_estimate]
        lien_holder:
          type: string
        lien_payoff_amount:
          type: number
          format: double
        mileage:
          type: integer
        condition:
          type: string
          enum: [excellent, good, fair, poor]
        location:
          type: string
        disposition:
          type: string
          enum: [keep, transfer_to_heir, sell, donate, junk, pending_decision]
        institution_contact_id:
          type: string
        notes:
          type: string

    # ---- Business Ownership Schemas ----
    BusinessOwnership:
      type: object
      properties:
        id:
          type: string
          example: "01K9BO01AJ0T88HRYE78AN7BBB"
        case_id:
          type: string
        entity_type:
          type: string
          enum: [c_corp, s_corp, llc, general_partnership, limited_partnership, sole_proprietorship, dba_trade_name, franchise, professional_license, nonprofit, other]
          example: "llc"
        business_name:
          type: string
          example: "Doe Family Properties LLC"
        state_of_formation:
          type:
            - string
            - "null"
          minLength: 2
          maxLength: 2
          example: "UT"
        ein:
          type:
            - string
            - "null"
          description: "Employer Identification Number. Masked in responses."
          example: "**-***1234"
        status:
          type: string
          enum: [active, inactive, dissolved, merged, suspended, unknown]
          example: "active"
        deceased_role:
          type: string
          enum: [sole_owner, majority_owner, minority_owner, partner, officer, director, shareholder, member, manager, license_holder, other]
          example: "sole_owner"
        ownership_percentage:
          type:
            - number
            - "null"
          format: double
          description: "Deceased's ownership share as a percentage."
          example: 100.0
        estimated_value:
          type:
            - number
            - "null"
          format: double
          description: "Estimated value of the deceased's interest."
        co_owners:
          type: array
          items:
            type: object
            properties:
              name:
                type: string
              role:
                type: string
              ownership_percentage:
                type: number
                format: double
        has_operating_agreement:
          type: boolean
          description: "Whether an operating agreement or bylaws exist."
        has_buy_sell_agreement:
          type: boolean
          description: "Whether a buy-sell agreement exists."
        succession_plan:
          type:
            - string
            - "null"
          enum: [sell, transfer_to_heir, dissolve, continue_with_partners, pending_decision, null]
        professional_licenses:
          type: array
          items:
            type: object
            properties:
              license_type:
                type: string
                example: "Real Estate Broker"
              license_number:
                type: string
              issuing_state:
                type: string
              expiration_date:
                type:
                  - string
                  - "null"
                format: date
              status:
                type: string
                enum: [active, expired, suspended, revoked]
        registered_agent:
          type:
            - string
            - "null"
        annual_revenue:
          type:
            - number
            - "null"
          format: double
        employees:
          type:
            - integer
            - "null"
        institution_contact_id:
          type:
            - string
            - "null"
        notes:
          type:
            - string
            - "null"
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time

    BusinessOwnershipWrite:
      type: object
      required:
        - entity_type
        - business_name
      properties:
        entity_type:
          type: string
          enum: [c_corp, s_corp, llc, general_partnership, limited_partnership, sole_proprietorship, dba_trade_name, franchise, professional_license, nonprofit, other]
        business_name:
          type: string
        state_of_formation:
          type: string
          minLength: 2
          maxLength: 2
        ein:
          type: string
          description: "Full EIN."
        status:
          type: string
          enum: [active, inactive, dissolved, merged, suspended, unknown]
        deceased_role:
          type: string
          enum: [sole_owner, majority_owner, minority_owner, partner, officer, director, shareholder, member, manager, license_holder, other]
        ownership_percentage:
          type: number
          format: double
        estimated_value:
          type: number
          format: double
        co_owners:
          type: array
          items:
            type: object
            properties:
              name:
                type: string
              role:
                type: string
              ownership_percentage:
                type: number
                format: double
        has_operating_agreement:
          type: boolean
        has_buy_sell_agreement:
          type: boolean
        succession_plan:
          type: string
          enum: [sell, transfer_to_heir, dissolve, continue_with_partners, pending_decision]
        registered_agent:
          type: string
        institution_contact_id:
          type: string
        notes:
          type: string

    # ---- Probate Reference Schemas ----
    ProbateState:
      type: object
      properties:
        state_code:
          type: string
          example: "UT"
        state_name:
          type: string
          example: "Utah"
        probate_court_name:
          type: string
          description: "What the probate court is called in this state."
          example: "District Court"
        governing_statute:
          type: string
          example: "Utah Uniform Probate Code, Title 75"
        upc_adopted:
          type: boolean
          description: "Whether the state adopted the Uniform Probate Code."
          example: true
        community_property_state:
          type: boolean
          example: false
        probate_types:
          type: array
          items:
            type: string
            enum: [formal_probate, informal_probate, small_estate_affidavit, summary_administration, ancillary_probate, supervised_administration, unsupervised_administration, muniment_of_title]
          example: ["formal_probate", "informal_probate", "small_estate_affidavit"]
        small_estate_threshold:
          type:
            - number
            - "null"
          format: double
          description: "Dollar amount below which small estate affidavit is available."
          example: 100000
        real_property_small_estate_threshold:
          type:
            - number
            - "null"
          format: double
        personal_property_small_estate_threshold:
          type:
            - number
            - "null"
          format: double
        statute_of_limitations_to_file:
          type: string
          description: "Time limit to file probate after death."
          example: "3 years"
        creditor_claim_period:
          type: string
          description: "Time creditors have to file claims."
          example: "3 months from notice publication"
        notice_requirements:
          type: object
          properties:
            publication_required:
              type: boolean
              example: true
            publication_duration:
              type: string
              example: "3 consecutive weeks"
            direct_notice_to_creditors:
              type: boolean
              example: true
            direct_notice_to_heirs:
              type: boolean
              example: true
            notice_deadline_after_appointment:
              type:
                - integer
                - "null"
              description: "Days after appointment to send notice."
              example: 90
        bond_requirements:
          type: object
          properties:
            required_by_default:
              type: boolean
              example: true
            can_be_waived_by_will:
              type: boolean
              example: true
            waivable_by_court:
              type: boolean
              example: true
            bond_amount_basis:
              type: string
              example: "Value of personal property plus estimated annual income"
        executor_compensation:
          type: object
          properties:
            method:
              type: string
              enum: [statutory_percentage, reasonable_compensation, court_determined]
              example: "reasonable_compensation"
            statutory_rates:
              type:
                - array
                - "null"
              items:
                type: object
                properties:
                  up_to_amount:
                    type: number
                    format: double
                  percentage:
                    type: number
                    format: double
            notes:
              type:
                - string
                - "null"
              example: "Compensation must be approved by the court."
        spousal_rights:
          type: object
          properties:
            elective_share:
              type: boolean
              example: true
            elective_share_percentage:
              type:
                - number
                - "null"
              format: double
              example: 33.33
            homestead_exemption:
              type: boolean
              example: true
            homestead_exemption_amount:
              type:
                - number
                - "null"
              format: double
              example: 40000
            family_allowance:
              type: boolean
              example: true
            family_allowance_amount:
              type:
                - number
                - "null"
              format: double
              example: 27000
            family_allowance_duration:
              type:
                - string
                - "null"
              example: "12 months"
            exempt_property_allowance:
              type: boolean
              example: true
            exempt_property_allowance_amount:
              type:
                - number
                - "null"
              format: double
              example: 15000
            community_property_rights:
              type:
                - string
                - "null"
              description: "Applicable in community property states only."
        intestate_succession_rules:
          type: object
          properties:
            surviving_spouse_share:
              type: string
              example: "All if no descendants or parents; $75,000 + 50% of balance if descendants"
            children_share:
              type: string
              example: "Equal shares of remainder after spouse's share"
            parents_share:
              type: string
              example: "If no surviving spouse or descendants, equally to parents"
            siblings_share:
              type: string
              example: "If no surviving spouse, descendants, or parents"
            no_surviving_heirs:
              type: string
              example: "Escheats to the state"
        will_requirements:
          type: object
          properties:
            minimum_age:
              type: integer
              example: 18
            witnesses_required:
              type: integer
              example: 2
            notarization_required:
              type: boolean
              example: false
            holographic_wills_accepted:
              type: boolean
              description: "Handwritten, unwitnessed wills."
              example: true
            self_proving_affidavit_accepted:
              type: boolean
              example: true
            electronic_wills_accepted:
              type: boolean
              example: false
            nuncupative_oral_wills_accepted:
              type: boolean
              example: false
        tax_information:
          type: object
          properties:
            state_estate_tax:
              type: boolean
              example: false
            estate_tax_threshold:
              type:
                - number
                - "null"
              format: double
            state_inheritance_tax:
              type: boolean
              example: false
            inheritance_tax_rates:
              type:
                - string
                - "null"
            income_tax_on_estate:
              type: boolean
              example: true
            fiduciary_income_tax_return_required:
              type: boolean
              example: true
        special_rules:
          type: array
          items:
            type: string
          example: ["Utah allows informal probate without court hearing"]
        independent_administration_available:
          type: boolean
          example: true
        will_contest_deadline:
          type:
            - string
            - "null"
          example: "Within 12 months of probate filing"
        executor_residency_requirement:
          type:
            - string
            - "null"
          example: "No residency requirement"
        attorney_required:
          type: boolean
          description: "Whether an attorney is required for probate."
          example: false

    ProbateStateSummary:
      type: object
      description: "Abbreviated state info for list endpoints."
      properties:
        state_code:
          type: string
          example: "UT"
        state_name:
          type: string
          example: "Utah"
        probate_court_name:
          type: string
          example: "District Court"
        upc_adopted:
          type: boolean
        community_property_state:
          type: boolean
        small_estate_threshold:
          type:
            - number
            - "null"
          format: double
        attorney_required:
          type: boolean

    ProbateCounty:
      type: object
      properties:
        county_slug:
          type: string
          example: "cache-county"
        county_name:
          type: string
          example: "Cache County"
        state_code:
          type: string
          example: "UT"
        court_name:
          type: string
          example: "First District Court, Cache County"
        court_address:
          $ref: "#/components/schemas/Address"
        court_phone:
          type:
            - string
            - "null"
          example: "+11112223333"
        court_fax:
          type:
            - string
            - "null"
        court_email:
          type:
            - string
            - "null"
          format: email
        court_website:
          type:
            - string
            - "null"
          format: uri
          example: "https://www.utcourts.gov/court/dist/1"
        clerk_name:
          type:
            - string
            - "null"
        clerk_title:
          type:
            - string
            - "null"
          example: "Clerk of Court"
        court_hours:
          type: object
          properties:
            monday_friday:
              type: string
              example: "8:00 AM - 5:00 PM"
            saturday:
              type:
                - string
                - "null"
              example: null
            sunday:
              type:
                - string
                - "null"
              example: null
            notes:
              type:
                - string
                - "null"
              example: "Closed on state holidays"
        filing_fees:
          type: object
          properties:
            probate_petition:
              type:
                - number
                - "null"
              format: double
              example: 360.00
            small_estate_affidavit:
              type:
                - number
                - "null"
              format: double
              example: 75.00
            letters_testamentary:
              type:
                - number
                - "null"
              format: double
              example: 25.00
            letters_of_administration:
              type:
                - number
                - "null"
              format: double
              example: 25.00
            certified_copy:
              type:
                - number
                - "null"
              format: double
              example: 4.00
            will_filing:
              type:
                - number
                - "null"
              format: double
              example: 15.00
            bond_filing:
              type:
                - number
                - "null"
              format: double
            final_accounting:
              type:
                - number
                - "null"
              format: double
            additional_fees:
              type: array
              items:
                type: object
                properties:
                  description:
                    type: string
                  amount:
                    type: number
                    format: double
        accepted_payment_methods:
          type: array
          items:
            type: string
            enum: [cash, check, credit_card, money_order, online]
          example: ["cash", "check", "credit_card"]
        electronic_filing_available:
          type: boolean
          example: true
        electronic_filing_url:
          type:
            - string
            - "null"
          format: uri
        local_rules:
          type: array
          items:
            type: string
          example: ["All filings must include a cover sheet"]
        required_forms:
          type: array
          items:
            type: object
            properties:
              form_name:
                type: string
              form_number:
                type:
                  - string
                  - "null"
              form_url:
                type:
                  - string
                  - "null"
                format: uri
              description:
                type: string
              required_for:
                type: array
                items:
                  type: string
        average_processing_time:
          type:
            - string
            - "null"
          example: "6-12 months"
        hearing_scheduling:
          type: object
          properties:
            method:
              type: string
              enum: [in_person, virtual, hybrid]
              example: "hybrid"
            scheduling_url:
              type:
                - string
                - "null"
              format: uri
            typical_wait_time:
              type:
                - string
                - "null"
              example: "4-6 weeks"
        local_attorney_referral:
          type:
            - string
            - "null"
          example: "https://www.utahbar.org/lawyer-referral"
        notes:
          type:
            - string
            - "null"

    ProbateCountySummary:
      type: object
      description: "Abbreviated county info for list endpoints."
      properties:
        county_slug:
          type: string
        county_name:
          type: string
        state_code:
          type: string
        court_name:
          type: string
        electronic_filing_available:
          type: boolean
        average_processing_time:
          type:
            - string
            - "null"

    ProbateForm:
      type: object
      properties:
        id:
          type: string
          example: "01K7PF01GJ5T22HRYE78AN7HIJ"
        form_name:
          type: string
          example: "Petition for Formal Probate of Will"
        form_number:
          type:
            - string
            - "null"
          example: "OCAP-PROB-01"
        category:
          type: string
          enum: [petition, notice, inventory, accounting, distribution, bond, waiver, affidavit, letters, order, other]
          example: "petition"
        description:
          type: string
          example: "Petition to formally admit a will to probate and appoint a personal representative."
        instructions:
          type:
            - string
            - "null"
        required_for:
          type: array
          items:
            type: string
            enum: [formal_probate, informal_probate, small_estate_affidavit, summary_administration, ancillary_probate, supervised_administration, unsupervised_administration]
          example: ["formal_probate"]
        download_url:
          type:
            - string
            - "null"
          format: uri
          example: "https://www.utcourts.gov/forms/prob/petition.pdf"
        fillable:
          type: boolean
          example: true
        last_updated:
          type:
            - string
            - "null"
          format: date

    # ---- Probate Case Tracking Schemas ----
    ProbateCase:
      type: object
      properties:
        state_code:
          type: string
          example: "UT"
        county_slug:
          type: string
          example: "cache-county"
        probate_type:
          type: string
          enum: [formal, informal, small_estate, summary, ancillary, supervised, unsupervised]
          example: "informal"
        case_number:
          type:
            - string
            - "null"
          example: "2025-PR-00456"
        court_name:
          type:
            - string
            - "null"
          example: "First District Court, Cache County"
        judge_name:
          type:
            - string
            - "null"
          example: "Hon. John Johnson"
        filing_date:
          type:
            - string
            - "null"
          format: date
        hearing_date:
          type:
            - string
            - "null"
          format: date
        next_hearing_date:
          type:
            - string
            - "null"
          format: date
        status:
          type: string
          enum: [not_filed, filed, hearing_scheduled, letters_issued, inventory_due, creditor_period, accounting_due, distribution_pending, closed]
          example: "filed"
        executor_appointed_date:
          type:
            - string
            - "null"
          format: date
        letters_issued_date:
          type:
            - string
            - "null"
          format: date
        bond_amount:
          type:
            - number
            - "null"
          format: double
        bond_provider:
          type:
            - string
            - "null"
        bond_status:
          type:
            - string
            - "null"
          enum: [required, waived, filed, released, null]
        attorney_name:
          type:
            - string
            - "null"
        attorney_firm:
          type:
            - string
            - "null"
        attorney_phone:
          type:
            - string
            - "null"
        attorney_email:
          type:
            - string
            - "null"
          format: email
        attorney_bar_number:
          type:
            - string
            - "null"
        estate_value_at_filing:
          type:
            - number
            - "null"
          format: double
        will_admitted:
          type: boolean
          example: false
        will_admitted_date:
          type:
            - string
            - "null"
          format: date
        will_contested:
          type: boolean
          example: false
        contest_details:
          type:
            - string
            - "null"
        creditor_notice_published:
          type: boolean
          example: false
        creditor_notice_date:
          type:
            - string
            - "null"
          format: date
        creditor_claim_deadline:
          type:
            - string
            - "null"
          format: date
        inventory_filed:
          type: boolean
          example: false
        inventory_filed_date:
          type:
            - string
            - "null"
          format: date
        inventory_due_date:
          type:
            - string
            - "null"
          format: date
        final_accounting_filed:
          type: boolean
          example: false
        final_accounting_date:
          type:
            - string
            - "null"
          format: date
        distribution_complete:
          type: boolean
          example: false
        distribution_date:
          type:
            - string
            - "null"
          format: date
        case_closed_date:
          type:
            - string
            - "null"
          format: date
        notes:
          type:
            - string
            - "null"

    ProbateDeadline:
      type: object
      properties:
        id:
          type: string
          example: "01K7DL02HJ6T33HRYE78AN7KLM"
        title:
          type: string
          example: "File estate inventory"
        description:
          type:
            - string
            - "null"
          example: "Detailed inventory of all estate assets must be filed within 3 months."
        type:
          type: string
          enum: [filing, hearing, creditor_notice, inventory, accounting, distribution, tax_return, bond_renewal, other]
          example: "inventory"
        due_date:
          type: string
          format: date
          example: "2026-01-15"
        completed_date:
          type:
            - string
            - "null"
          format: date
        status:
          type: string
          enum: [upcoming, overdue, completed, waived]
          example: "upcoming"
        is_court_ordered:
          type: boolean
          example: true
        reminder_days_before:
          type: integer
          example: 14
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time

    ProbateDeadlineWrite:
      type: object
      required:
        - title
        - type
        - due_date
      properties:
        title:
          type: string
        description:
          type: string
        type:
          type: string
          enum: [filing, hearing, creditor_notice, inventory, accounting, distribution, tax_return, bond_renewal, other]
        due_date:
          type: string
          format: date
        completed_date:
          type: string
          format: date
        status:
          type: string
          enum: [upcoming, overdue, completed, waived]
        is_court_ordered:
          type: boolean
        reminder_days_before:
          type: integer

    ProbateFiling:
      type: object
      properties:
        id:
          type: string
          example: "01K7FL03IJ7T44HRYE78AN7NOP"
        filing_type:
          type: string
          enum: [petition, inventory, accounting, notice, motion, order, waiver, affidavit, deed, other]
          example: "petition"
        title:
          type: string
          example: "Petition for Informal Probate"
        description:
          type:
            - string
            - "null"
        filed_date:
          type:
            - string
            - "null"
          format: date
        filed_by:
          type:
            - string
            - "null"
          example: "John Doe (Executor)"
        court_response:
          type: string
          enum: [accepted, rejected, pending]
          example: "pending"
        court_response_date:
          type:
            - string
            - "null"
          format: date
        court_notes:
          type:
            - string
            - "null"
        document_id:
          type:
            - string
            - "null"
          description: "Reference to an uploaded document."
        fees_paid:
          type:
            - number
            - "null"
          format: double
          example: 360.00
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time

    ProbateFilingWrite:
      type: object
      required:
        - filing_type
        - title
      properties:
        filing_type:
          type: string
          enum: [petition, inventory, accounting, notice, motion, order, waiver, affidavit, deed, other]
        title:
          type: string
        description:
          type: string
        filed_date:
          type: string
          format: date
        filed_by:
          type: string
        court_response:
          type: string
          enum: [accepted, rejected, pending]
        court_response_date:
          type: string
          format: date
        court_notes:
          type: string
        document_id:
          type: string
        fees_paid:
          type: number
          format: double

    CreditorClaim:
      type: object
      properties:
        id:
          type: string
          example: "01K7CC04JJ8T55HRYE78AN7QRS"
        creditor_name:
          type: string
          example: "Springfield Medical Center"
        creditor_address:
          $ref: "#/components/schemas/Address"
        creditor_phone:
          type:
            - string
            - "null"
        creditor_email:
          type:
            - string
            - "null"
          format: email
        claim_amount:
          type: number
          format: double
          example: 12500.00
        claim_date:
          type: string
          format: date
        claim_type:
          type: string
          enum: [secured, unsecured, priority, contingent]
          example: "unsecured"
        debt_description:
          type: string
          example: "Outstanding medical bills for treatment in 2024-2025."
        account_number:
          type:
            - string
            - "null"
          description: "Masked in responses."
          example: "***4567"
        status:
          type: string
          enum: [filed, under_review, accepted, rejected, disputed, paid, partially_paid, expired]
          example: "filed"
        resolution_amount:
          type:
            - number
            - "null"
          format: double
        resolution_date:
          type:
            - string
            - "null"
          format: date
        resolution_notes:
          type:
            - string
            - "null"
        priority_order:
          type:
            - integer
            - "null"
          description: "Priority for distribution (lower = higher priority)."
        is_valid:
          type: boolean
          example: true
        statute_of_limitations_expires:
          type:
            - string
            - "null"
          format: date
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time

    CreditorClaimWrite:
      type: object
      required:
        - creditor_name
        - claim_amount
        - claim_date
        - claim_type
      properties:
        creditor_name:
          type: string
        creditor_address:
          $ref: "#/components/schemas/Address"
        creditor_phone:
          type: string
        creditor_email:
          type: string
          format: email
        claim_amount:
          type: number
          format: double
        claim_date:
          type: string
          format: date
        claim_type:
          type: string
          enum: [secured, unsecured, priority, contingent]
        debt_description:
          type: string
        account_number:
          type: string
        status:
          type: string
          enum: [filed, under_review, accepted, rejected, disputed, paid, partially_paid, expired]
        resolution_amount:
          type: number
          format: double
        resolution_date:
          type: string
          format: date
        resolution_notes:
          type: string
        priority_order:
          type: integer
        is_valid:
          type: boolean
        statute_of_limitations_expires:
          type: string
          format: date

    Distribution:
      type: object
      properties:
        id:
          type: string
          example: "01K7DS05KJ9T66HRYE78AN7TUV"
        person_id:
          type:
            - string
            - "null"
          description: "Reference to an interested person / beneficiary."
        recipient_name:
          type: string
          example: "John Jonas Johnson"
        relationship:
          type:
            - string
            - "null"
          example: "daughter"
        asset_description:
          type: string
          example: "Distribution from estate checking account"
        asset_type:
          type: string
          enum: [cash, real_property, personal_property, securities, vehicle, other]
          example: "cash"
        amount_or_value:
          type: number
          format: double
          example: 25000.00
        distribution_date:
          type:
            - string
            - "null"
          format: date
        method:
          type: string
          enum: [check, wire, deed_transfer, title_transfer, in_kind]
          example: "check"
        status:
          type: string
          enum: [pending, approved, completed, disputed]
          example: "pending"
        receipt_signed:
          type: boolean
          example: false
        receipt_date:
          type:
            - string
            - "null"
          format: date
        tax_reported:
          type: boolean
          example: false
        notes:
          type:
            - string
            - "null"
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time

    DistributionWrite:
      type: object
      required:
        - recipient_name
        - asset_type
        - amount_or_value
        - method
      properties:
        person_id:
          type: string
        recipient_name:
          type: string
        relationship:
          type: string
        asset_description:
          type: string
        asset_type:
          type: string
          enum: [cash, real_property, personal_property, securities, vehicle, other]
        amount_or_value:
          type: number
          format: double
        distribution_date:
          type: string
          format: date
        method:
          type: string
          enum: [check, wire, deed_transfer, title_transfer, in_kind]
        status:
          type: string
          enum: [pending, approved, completed, disputed]
        receipt_signed:
          type: boolean
        receipt_date:
          type: string
          format: date
        tax_reported:
          type: boolean
        notes:
          type: string

  parameters:
    CaseId:
      name: case_id
      in: path
      required: true
      schema:
        type: string
      description: "Unique case identifier (ULID format)."
      example: "01K5WF06MJ6T99HRYE78AN7XM8"
    Page:
      name: page
      in: query
      schema:
        type: integer
        default: 1
        minimum: 1
      description: "Page number for pagination."
    PerPage:
      name: per_page
      in: query
      schema:
        type: integer
        default: 25
        minimum: 1
        maximum: 100
      description: "Number of items per page."
    SortOrder:
      name: sort_order
      in: query
      schema:
        type: string
        enum: [asc, desc]
        default: desc
      description: "Sort direction."
    Cursor:
      name: cursor
      in: query
      schema:
        type: string
      description: "Opaque cursor for cursor-based pagination. Use the `next_cursor` value from the previous response. When provided, `page` is ignored."
    IdempotencyKey:
      name: Idempotency-Key
      in: header
      schema:
        type: string
        maxLength: 255
      description: "Unique key to ensure idempotent POST requests. If a request with the same key was already processed, the original response is returned. Keys expire after 24 hours."
      example: "idem_01K9IK01AJ0T88HRYE78AN7YYY"
    IfNoneMatch:
      name: If-None-Match
      in: header
      schema:
        type: string
      description: "ETag value from a previous GET response. If the resource has not changed, returns `304 Not Modified`."
    IfMatch:
      name: If-Match
      in: header
      schema:
        type: string
      description: "ETag value from a previous GET response. The request only proceeds if the resource's current ETag matches, preventing lost updates."

  headers:
    X-Request-Id:
      description: "Unique request identifier for tracing and debugging. Included on every response."
      schema:
        type: string
        example: "req_01K9RQ01AJ0T77HRYE78AN7ZZZ"
    X-RateLimit-Limit:
      description: "Maximum number of requests allowed in the current window."
      schema:
        type: integer
        example: 1000
    X-RateLimit-Remaining:
      description: "Number of requests remaining in the current window."
      schema:
        type: integer
        example: 987
    X-RateLimit-Reset:
      description: "Unix timestamp (seconds) when the rate limit window resets."
      schema:
        type: integer
        example: 1729012800
    ETag:
      description: "Entity tag for conditional requests. Use with `If-None-Match` (GET) or `If-Match` (PATCH/PUT/DELETE) headers."
      schema:
        type: string
        example: "\"a1b2c3d4e5f6\""

  responses:
    NotFound:
      description: Resource not found.
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/Error"
          example:
            error:
              code: "not_found"
              message: "The requested resource was not found."
    Forbidden:
      description: "Insufficient permissions for this case or resource."
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/Error"
          example:
            error:
              code: "forbidden"
              message: "You do not have permission to access this resource."
    ValidationError:
      description: Request validation failed.
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/Error"
          example:
            error:
              code: "validation_error"
              message: "The request body contains invalid fields."
              details:
                - field: "email"
                  message: "Must be a valid email address."
    Conflict:
      description: "Duplicate request detected via Idempotency-Key."
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/Error"
          example:
            error:
              code: "idempotency_conflict"
              message: "A different request body was sent with the same Idempotency-Key."
    RateLimitExceeded:
      description: "Rate limit exceeded. Retry after the reset time."
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/Error"
          example:
            error:
              code: "rate_limit_exceeded"
              message: "You have exceeded the rate limit. Please retry after the reset time."
    PreconditionFailed:
      description: "The resource has been modified since the provided ETag. Re-fetch and retry."
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/Error"
          example:
            error:
              code: "precondition_failed"
              message: "The resource has been modified. Please re-fetch and retry."

paths:
  # ==================== CASES ====================
  /cases:
    get:
      operationId: listCases
      tags: [Cases]
      summary: List cases
      description: Retrieve a paginated list of estate cases with optional filtering.
      parameters:
        - $ref: "#/components/parameters/Page"
        - $ref: "#/components/parameters/PerPage"
        - name: sort_by
          in: query
          schema:
            type: string
            enum: [created_at, updated_at, estate_value]
            default: created_at
        - $ref: "#/components/parameters/SortOrder"
        - name: queue_assignment
          in: query
          schema:
            type: string
          description: "Filter by queue assignment."
        - name: flow_position
          in: query
          schema:
            type: string
          description: "Filter by flow position."
        - name: possible_dispute
          in: query
          schema:
            type: string
            enum: [no_dispute_expected, possible_dispute, active_dispute]
        - name: search
          in: query
          schema:
            type: string
          description: "Full-text search across case metadata."
      responses:
        "200":
          description: List of cases.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/Case"
                  meta:
                    $ref: "#/components/schemas/PaginationMeta"
    post:
      operationId: createCase
      tags: [Cases]
      summary: Create a case
      description: Create a new estate case.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CaseCreate"
      responses:
        "201":
          description: Case created.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: "#/components/schemas/Case"
        "422":
          $ref: "#/components/responses/ValidationError"

  /cases/{case_id}:
    parameters:
      - $ref: "#/components/parameters/CaseId"
    get:
      operationId: getCase
      tags: [Cases]
      summary: Get a case
      description: Retrieve a single estate case by ID.
      responses:
        "200":
          description: Case details.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: "#/components/schemas/Case"
        "404":
          $ref: "#/components/responses/NotFound"
    patch:
      operationId: updateCase
      tags: [Cases]
      summary: Update a case
      description: Partially update an existing case.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CaseUpdate"
      responses:
        "200":
          description: Case updated.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: "#/components/schemas/Case"
        "404":
          $ref: "#/components/responses/NotFound"
        "422":
          $ref: "#/components/responses/ValidationError"
    delete:
      operationId: deleteCase
      tags: [Cases]
      summary: Delete a case
      description: Delete an estate case. This action is irreversible.
      responses:
        "204":
          description: Case deleted.
        "404":
          $ref: "#/components/responses/NotFound"

  # ==================== DECEASED ====================
  /cases/{case_id}/deceased:
    parameters:
      - $ref: "#/components/parameters/CaseId"
    get:
      operationId: getDeceased
      tags: [Deceased]
      summary: Get deceased info
      description: Retrieve the deceased person's information for a case. SSN is masked in the response.
      responses:
        "200":
          description: Deceased person details.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: "#/components/schemas/Deceased"
        "404":
          $ref: "#/components/responses/NotFound"
    put:
      operationId: setDeceased
      tags: [Deceased]
      summary: Set deceased info
      description: Create or replace the deceased person's information. Full SSN is accepted but will be masked in subsequent GET responses.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/DeceasedWrite"
      responses:
        "200":
          description: Deceased info set.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: "#/components/schemas/Deceased"
        "404":
          $ref: "#/components/responses/NotFound"
        "422":
          $ref: "#/components/responses/ValidationError"
    patch:
      operationId: updateDeceased
      tags: [Deceased]
      summary: Update deceased info
      description: Partially update the deceased person's information.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/DeceasedWrite"
      responses:
        "200":
          description: Deceased info updated.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: "#/components/schemas/Deceased"
        "404":
          $ref: "#/components/responses/NotFound"
        "422":
          $ref: "#/components/responses/ValidationError"
    delete:
      operationId: deleteDeceased
      tags: [Deceased]
      summary: Remove deceased info
      description: Remove the deceased person's information from a case.
      responses:
        "204":
          description: Deceased info removed.
        "404":
          $ref: "#/components/responses/NotFound"

  # ==================== EXECUTOR ====================
  /cases/{case_id}/executor:
    parameters:
      - $ref: "#/components/parameters/CaseId"
    get:
      operationId: getExecutor
      tags: [Executor]
      summary: Get executor info
      description: Retrieve the executor's information for a case.
      responses:
        "200":
          description: Executor details.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: "#/components/schemas/Executor"
        "404":
          $ref: "#/components/responses/NotFound"
    put:
      operationId: setExecutor
      tags: [Executor]
      summary: Set executor info
      description: Create or replace the executor's information.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/ExecutorWrite"
      responses:
        "200":
          description: Executor info set.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: "#/components/schemas/Executor"
        "404":
          $ref: "#/components/responses/NotFound"
        "422":
          $ref: "#/components/responses/ValidationError"
    patch:
      operationId: updateExecutor
      tags: [Executor]
      summary: Update executor info
      description: Partially update the executor's information.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/ExecutorWrite"
      responses:
        "200":
          description: Executor info updated.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: "#/components/schemas/Executor"
        "404":
          $ref: "#/components/responses/NotFound"
        "422":
          $ref: "#/components/responses/ValidationError"
    delete:
      operationId: deleteExecutor
      tags: [Executor]
      summary: Remove executor info
      description: Remove the executor's information from a case.
      responses:
        "204":
          description: Executor info removed.
        "404":
          $ref: "#/components/responses/NotFound"

  # ==================== AUTHORITY ====================
  /cases/{case_id}/authority:
    parameters:
      - $ref: "#/components/parameters/CaseId"
    get:
      operationId: getAuthority
      tags: [Authority]
      summary: Get authority verification
      description: Retrieve the authority verification details for a case.
      responses:
        "200":
          description: Authority verification details.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: "#/components/schemas/Authority"
        "404":
          $ref: "#/components/responses/NotFound"
    put:
      operationId: setAuthority
      tags: [Authority]
      summary: Set authority verification
      description: Create or replace authority verification.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/Authority"
      responses:
        "200":
          description: Authority verification set.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: "#/components/schemas/Authority"
        "404":
          $ref: "#/components/responses/NotFound"
        "422":
          $ref: "#/components/responses/ValidationError"
    patch:
      operationId: updateAuthority
      tags: [Authority]
      summary: Update authority verification
      description: Partially update authority verification.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/Authority"
      responses:
        "200":
          description: Authority verification updated.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: "#/components/schemas/Authority"
        "404":
          $ref: "#/components/responses/NotFound"
        "422":
          $ref: "#/components/responses/ValidationError"

  # ==================== EIN ====================
  /cases/{case_id}/ein:
    parameters:
      - $ref: "#/components/parameters/CaseId"
    get:
      operationId: getEIN
      tags: [EIN]
      summary: Get EIN info
      description: Retrieve the Employer Identification Number information for a case.
      responses:
        "200":
          description: EIN details.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: "#/components/schemas/EIN"
        "404":
          $ref: "#/components/responses/NotFound"
    put:
      operationId: setEIN
      tags: [EIN]
      summary: Set EIN info
      description: Create or replace EIN information.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/EIN"
      responses:
        "200":
          description: EIN info set.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: "#/components/schemas/EIN"
        "404":
          $ref: "#/components/responses/NotFound"
        "422":
          $ref: "#/components/responses/ValidationError"
    patch:
      operationId: updateEIN
      tags: [EIN]
      summary: Update EIN info
      description: Partially update EIN information.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/EIN"
      responses:
        "200":
          description: EIN info updated.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: "#/components/schemas/EIN"
        "404":
          $ref: "#/components/responses/NotFound"
        "422":
          $ref: "#/components/responses/ValidationError"
    delete:
      operationId: deleteEIN
      tags: [EIN]
      summary: Remove EIN info
      description: Remove the EIN information from a case.
      responses:
        "204":
          description: EIN info removed.
        "404":
          $ref: "#/components/responses/NotFound"

  # ==================== FINANCIAL ACCOUNTS ====================
  /cases/{case_id}/financial-accounts:
    parameters:
      - $ref: "#/components/parameters/CaseId"
    get:
      operationId: listFinancialAccounts
      tags: [Financial Accounts]
      summary: List financial accounts
      description: List all financial accounts and assets for a case.
      parameters:
        - $ref: "#/components/parameters/Page"
        - $ref: "#/components/parameters/PerPage"
        - name: type
          in: query
          schema:
            type: string
            enum: [bank_account, debt, insurance, investment, retirement, property, vehicle, business, unclaimed_money]
          description: "Filter by account type."
        - name: institution_name
          in: query
          schema:
            type: string
          description: "Partial match on institution name."
        - name: sort_by
          in: query
          schema:
            type: string
            enum: [balance, type, created_at]
            default: created_at
        - $ref: "#/components/parameters/SortOrder"
      responses:
        "200":
          description: List of financial accounts.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/FinancialAccount"
                  meta:
                    $ref: "#/components/schemas/PaginationMeta"
        "404":
          $ref: "#/components/responses/NotFound"

  /cases/{case_id}/financial-accounts/{account_id}:
    parameters:
      - $ref: "#/components/parameters/CaseId"
      - name: account_id
        in: path
        required: true
        schema:
          type: string
        description: "Financial account identifier."
    get:
      operationId: getFinancialAccount
      tags: [Financial Accounts]
      summary: Get a financial account
      description: Retrieve a single financial account by ID.
      responses:
        "200":
          description: Financial account details.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: "#/components/schemas/FinancialAccount"
        "404":
          $ref: "#/components/responses/NotFound"
    patch:
      operationId: updateFinancialAccount
      tags: [Financial Accounts]
      summary: Update a financial account
      description: Partially update a financial account.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/FinancialAccountWrite"
      responses:
        "200":
          description: Financial account updated.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: "#/components/schemas/FinancialAccount"
        "404":
          $ref: "#/components/responses/NotFound"
        "422":
          $ref: "#/components/responses/ValidationError"

  # ==================== DOCUMENTS ====================
  /cases/{case_id}/documents:
    parameters:
      - $ref: "#/components/parameters/CaseId"
    get:
      operationId: listDocuments
      tags: [Documents]
      summary: List documents
      description: List all documents for a case.
      parameters:
        - $ref: "#/components/parameters/Page"
        - $ref: "#/components/parameters/PerPage"
        - name: type
          in: query
          schema:
            type: string
            enum: [death_certificate, probate_document, bank_document, credit_report, birth_certificate, deceased_id, executor_id, property_report, will, trust_documents, other]
        - name: status
          in: query
          schema:
            type: string
            enum: [uploaded, skipped, pending, rejected]
      responses:
        "200":
          description: List of documents.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/Document"
                  meta:
                    $ref: "#/components/schemas/PaginationMeta"
        "404":
          $ref: "#/components/responses/NotFound"
    post:
      operationId: uploadDocument
      tags: [Documents]
      summary: Upload a document
      description: Upload a document file to a case.
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              required:
                - file
                - type
              properties:
                file:
                  type: string
                  format: binary
                  description: "The document file."
                type:
                  type: string
                  enum: [death_certificate, probate_document, bank_document, credit_report, birth_certificate, deceased_id, executor_id, property_report, will, trust_documents, other]
      responses:
        "201":
          description: Document uploaded.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: "#/components/schemas/Document"
        "404":
          $ref: "#/components/responses/NotFound"
        "422":
          $ref: "#/components/responses/ValidationError"

  /cases/{case_id}/documents/{document_id}:
    parameters:
      - $ref: "#/components/parameters/CaseId"
      - name: document_id
        in: path
        required: true
        schema:
          type: string
        description: "Document identifier."
    get:
      operationId: getDocument
      tags: [Documents]
      summary: Get document metadata
      description: Retrieve metadata for a single document.
      responses:
        "200":
          description: Document metadata.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: "#/components/schemas/Document"
        "404":
          $ref: "#/components/responses/NotFound"
    patch:
      operationId: updateDocument
      tags: [Documents]
      summary: Update document metadata
      description: Update document metadata such as type or status.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                type:
                  type: string
                  enum: [death_certificate, probate_document, bank_document, credit_report, birth_certificate, deceased_id, executor_id, property_report, will, trust_documents, other]
                status:
                  type: string
                  enum: [uploaded, skipped, pending, rejected]
      responses:
        "200":
          description: Document updated.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: "#/components/schemas/Document"
        "404":
          $ref: "#/components/responses/NotFound"
        "422":
          $ref: "#/components/responses/ValidationError"
    delete:
      operationId: deleteDocument
      tags: [Documents]
      summary: Delete a document
      description: Delete a document from a case.
      responses:
        "204":
          description: Document deleted.
        "404":
          $ref: "#/components/responses/NotFound"

  /cases/{case_id}/documents/{document_id}/download:
    parameters:
      - $ref: "#/components/parameters/CaseId"
      - name: document_id
        in: path
        required: true
        schema:
          type: string
    get:
      operationId: downloadDocument
      tags: [Documents]
      summary: Download a document
      description: Download the document file. Returns binary data with appropriate Content-Type and Content-Disposition headers.
      responses:
        "200":
          description: Document file.
          content:
            application/octet-stream:
              schema:
                type: string
                format: binary
        "404":
          $ref: "#/components/responses/NotFound"

  # ==================== SEARCHES ====================
  /cases/{case_id}/searches:
    parameters:
      - $ref: "#/components/parameters/CaseId"
    get:
      operationId: listSearches
      tags: [Searches]
      summary: List searches
      description: List all asset and background searches for a case.
      parameters:
        - $ref: "#/components/parameters/Page"
        - $ref: "#/components/parameters/PerPage"
        - name: type
          in: query
          schema:
            type: string
            enum: [real_estate, credit, investments, life_insurance, retirement, bank_accounts, businesses, vehicles, unclaimed_property]
        - name: status
          in: query
          schema:
            type: string
            enum: [pending, in_progress, completed, failed, cancelled]
      responses:
        "200":
          description: List of searches.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/Search"
                  meta:
                    $ref: "#/components/schemas/PaginationMeta"
        "404":
          $ref: "#/components/responses/NotFound"

  /cases/{case_id}/searches/{search_id}:
    parameters:
      - $ref: "#/components/parameters/CaseId"
      - name: search_id
        in: path
        required: true
        schema:
          type: string
        description: "Search identifier."
    get:
      operationId: getSearch
      tags: [Searches]
      summary: Get a search
      description: Retrieve a single search and its status.
      responses:
        "200":
          description: Search details.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: "#/components/schemas/Search"
        "404":
          $ref: "#/components/responses/NotFound"
    patch:
      operationId: updateSearch
      tags: [Searches]
      summary: Update search status
      description: Update the status of a search. Searches cannot be deleted (audit trail).
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                status:
                  type: string
                  enum: [pending, in_progress, completed, failed, cancelled]
                results_summary:
                  type: string
      responses:
        "200":
          description: Search updated.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: "#/components/schemas/Search"
        "404":
          $ref: "#/components/responses/NotFound"
        "422":
          $ref: "#/components/responses/ValidationError"

  # ==================== PERSONS ====================
  /cases/{case_id}/persons:
    parameters:
      - $ref: "#/components/parameters/CaseId"
    get:
      operationId: listPersons
      tags: [Persons]
      summary: List interested persons
      description: List all interested persons and beneficiaries for a case.
      parameters:
        - $ref: "#/components/parameters/Page"
        - $ref: "#/components/parameters/PerPage"
        - name: is_beneficiary
          in: query
          schema:
            type: boolean
        - name: possible_dispute
          in: query
          schema:
            type: boolean
        - name: is_deceased
          in: query
          schema:
            type: boolean
        - name: relationship
          in: query
          schema:
            type: string
      responses:
        "200":
          description: List of persons.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/Person"
                  meta:
                    $ref: "#/components/schemas/PaginationMeta"
        "404":
          $ref: "#/components/responses/NotFound"
    post:
      operationId: createPerson
      tags: [Persons]
      summary: Add a person
      description: Add an interested person or beneficiary to a case.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/PersonWrite"
      responses:
        "201":
          description: Person added.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: "#/components/schemas/Person"
        "404":
          $ref: "#/components/responses/NotFound"
        "422":
          $ref: "#/components/responses/ValidationError"

  /cases/{case_id}/persons/{person_id}:
    parameters:
      - $ref: "#/components/parameters/CaseId"
      - name: person_id
        in: path
        required: true
        schema:
          type: string
        description: "Person identifier."
    get:
      operationId: getPerson
      tags: [Persons]
      summary: Get a person
      description: Retrieve a single interested person.
      responses:
        "200":
          description: Person details.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: "#/components/schemas/Person"
        "404":
          $ref: "#/components/responses/NotFound"
    patch:
      operationId: updatePerson
      tags: [Persons]
      summary: Update a person
      description: Partially update a person's information.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/PersonWrite"
      responses:
        "200":
          description: Person updated.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: "#/components/schemas/Person"
        "404":
          $ref: "#/components/responses/NotFound"
        "422":
          $ref: "#/components/responses/ValidationError"
    delete:
      operationId: deletePerson
      tags: [Persons]
      summary: Delete a person
      description: Remove a person from a case.
      responses:
        "204":
          description: Person removed.
        "404":
          $ref: "#/components/responses/NotFound"

  # ==================== GOALS ====================
  /cases/{case_id}/goals:
    parameters:
      - $ref: "#/components/parameters/CaseId"
    get:
      operationId: listGoals
      tags: [Goals]
      summary: List goals
      description: List all estate management goals for a case.
      parameters:
        - $ref: "#/components/parameters/Page"
        - $ref: "#/components/parameters/PerPage"
        - name: status
          in: query
          schema:
            type: string
            enum: [pending, in_progress, completed]
      responses:
        "200":
          description: List of goals.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/Goal"
                  meta:
                    $ref: "#/components/schemas/PaginationMeta"
        "404":
          $ref: "#/components/responses/NotFound"

  /cases/{case_id}/goals/{goal_id}:
    parameters:
      - $ref: "#/components/parameters/CaseId"
      - name: goal_id
        in: path
        required: true
        schema:
          type: string
        description: "Goal identifier."
    get:
      operationId: getGoal
      tags: [Goals]
      summary: Get a goal
      description: Retrieve a single goal.
      responses:
        "200":
          description: Goal details.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: "#/components/schemas/Goal"
        "404":
          $ref: "#/components/responses/NotFound"
    patch:
      operationId: updateGoal
      tags: [Goals]
      summary: Update a goal
      description: Update a goal's status.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                status:
                  type: string
                  enum: [pending, in_progress, completed]
      responses:
        "200":
          description: Goal updated.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: "#/components/schemas/Goal"
        "404":
          $ref: "#/components/responses/NotFound"
        "422":
          $ref: "#/components/responses/ValidationError"

  # ==================== BANK ACCOUNTS ====================
  /cases/{case_id}/bank-accounts:
    parameters:
      - $ref: "#/components/parameters/CaseId"
    get:
      operationId: listBankAccounts
      tags: [Bank Accounts]
      summary: List bank accounts
      description: List all bank accounts for a case with optional filtering.
      parameters:
        - $ref: "#/components/parameters/Page"
        - $ref: "#/components/parameters/PerPage"
        - name: account_type
          in: query
          schema:
            type: string
            enum: [checking, savings, cd, money_market, hsa, trust_account, estate_account, joint_account]
        - name: status
          in: query
          schema:
            type: string
            enum: [open, closed, frozen, dormant, pending_closure, restricted]
        - name: ownership_type
          in: query
          schema:
            type: string
            enum: [individual, joint_tenants_wros, tenants_in_common, pod_payable_on_death, tod_transfer_on_death, trust, estate]
        - name: sort_by
          in: query
          schema:
            type: string
            enum: [current_balance, institution_name, account_type, created_at]
            default: created_at
        - $ref: "#/components/parameters/SortOrder"
      responses:
        "200":
          description: List of bank accounts.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/BankAccount"
                  meta:
                    $ref: "#/components/schemas/PaginationMeta"
        "404":
          $ref: "#/components/responses/NotFound"

  /cases/{case_id}/bank-accounts/{account_id}:
    parameters:
      - $ref: "#/components/parameters/CaseId"
      - name: account_id
        in: path
        required: true
        schema:
          type: string
        description: "Bank account identifier."
    get:
      operationId: getBankAccount
      tags: [Bank Accounts]
      summary: Get bank account details
      description: Retrieve a single bank account with full details.
      responses:
        "200":
          description: Bank account details.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: "#/components/schemas/BankAccount"
        "404":
          $ref: "#/components/responses/NotFound"
    patch:
      operationId: updateBankAccount
      tags: [Bank Accounts]
      summary: Update bank account
      description: Partially update a bank account.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/BankAccountWrite"
      responses:
        "200":
          description: Bank account updated.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: "#/components/schemas/BankAccount"
        "404":
          $ref: "#/components/responses/NotFound"
        "422":
          $ref: "#/components/responses/ValidationError"

  # ==================== SIGNERS ====================
  /cases/{case_id}/bank-accounts/{account_id}/signers:
    parameters:
      - $ref: "#/components/parameters/CaseId"
      - name: account_id
        in: path
        required: true
        schema:
          type: string
    get:
      operationId: listSigners
      tags: [Signers]
      summary: List account signers
      description: List all signers and account holders on a bank account.
      responses:
        "200":
          description: List of signers.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/Signer"
        "404":
          $ref: "#/components/responses/NotFound"

  /cases/{case_id}/bank-accounts/{account_id}/signers/{signer_id}:
    parameters:
      - $ref: "#/components/parameters/CaseId"
      - name: account_id
        in: path
        required: true
        schema:
          type: string
      - name: signer_id
        in: path
        required: true
        schema:
          type: string
    patch:
      operationId: updateSigner
      tags: [Signers]
      summary: Update a signer
      description: Update signer information.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/SignerWrite"
      responses:
        "200":
          description: Signer updated.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: "#/components/schemas/Signer"
        "404":
          $ref: "#/components/responses/NotFound"
        "422":
          $ref: "#/components/responses/ValidationError"

  # ==================== TRANSACTIONS ====================
  /cases/{case_id}/bank-accounts/{account_id}/transactions:
    parameters:
      - $ref: "#/components/parameters/CaseId"
      - name: account_id
        in: path
        required: true
        schema:
          type: string
    get:
      operationId: listTransactions
      tags: [Transactions]
      summary: List transactions
      description: List transactions for a bank account with date range and category filters.
      parameters:
        - $ref: "#/components/parameters/Page"
        - $ref: "#/components/parameters/PerPage"
        - name: date_from
          in: query
          schema:
            type: string
            format: date
          description: "Start date (inclusive)."
        - name: date_to
          in: query
          schema:
            type: string
            format: date
          description: "End date (inclusive)."
        - name: type
          in: query
          schema:
            type: string
            enum: [credit, debit, transfer_in, transfer_out, interest, fee, dividend, check, ach, wire, atm, pos, adjustment, estate_distribution]
        - name: category
          in: query
          schema:
            type: string
            enum: [income, bills, insurance_premium, medical, taxes, estate_expense, legal_fee, funeral_expense, beneficiary_distribution, other]
        - name: min_amount
          in: query
          schema:
            type: number
            format: double
        - name: max_amount
          in: query
          schema:
            type: number
            format: double
        - name: is_flagged
          in: query
          schema:
            type: boolean
        - name: is_recurring
          in: query
          schema:
            type: boolean
        - name: sort_by
          in: query
          schema:
            type: string
            enum: [date, amount, created_at]
            default: date
        - $ref: "#/components/parameters/SortOrder"
      responses:
        "200":
          description: List of transactions.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/Transaction"
                  meta:
                    $ref: "#/components/schemas/PaginationMeta"
        "404":
          $ref: "#/components/responses/NotFound"

  /cases/{case_id}/bank-accounts/{account_id}/transactions/{transaction_id}:
    parameters:
      - $ref: "#/components/parameters/CaseId"
      - name: account_id
        in: path
        required: true
        schema:
          type: string
      - name: transaction_id
        in: path
        required: true
        schema:
          type: string
    get:
      operationId: getTransaction
      tags: [Transactions]
      summary: Get transaction details
      description: Retrieve a single transaction.
      responses:
        "200":
          description: Transaction details.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: "#/components/schemas/Transaction"
        "404":
          $ref: "#/components/responses/NotFound"
    patch:
      operationId: updateTransaction
      tags: [Transactions]
      summary: Update transaction
      description: Update transaction notes, categorization, or flagging. Transactions cannot be deleted (audit trail).
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                category:
                  type: string
                  enum: [income, bills, insurance_premium, medical, taxes, estate_expense, legal_fee, funeral_expense, beneficiary_distribution, other]
                is_flagged:
                  type: boolean
                flag_reason:
                  type: string
                  enum: [suspicious, needs_review, disputed, estate_related]
                notes:
                  type: string
      responses:
        "200":
          description: Transaction updated.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: "#/components/schemas/Transaction"
        "404":
          $ref: "#/components/responses/NotFound"
        "422":
          $ref: "#/components/responses/ValidationError"

  # ==================== RECURRING PAYMENTS ====================
  /cases/{case_id}/bank-accounts/{account_id}/recurring-payments:
    parameters:
      - $ref: "#/components/parameters/CaseId"
      - name: account_id
        in: path
        required: true
        schema:
          type: string
    get:
      operationId: listRecurringPayments
      tags: [Recurring Payments]
      summary: List recurring payments
      description: List all recurring payments and deposits for a bank account.
      parameters:
        - $ref: "#/components/parameters/Page"
        - $ref: "#/components/parameters/PerPage"
        - name: status
          in: query
          schema:
            type: string
            enum: [active, cancelled, paused, transferred]
        - name: type
          in: query
          schema:
            type: string
            enum: [direct_deposit, autopay, subscription, loan_payment, insurance_premium, utility, pension, social_security, annuity]
      responses:
        "200":
          description: List of recurring payments.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/RecurringPayment"
                  meta:
                    $ref: "#/components/schemas/PaginationMeta"
        "404":
          $ref: "#/components/responses/NotFound"

  /cases/{case_id}/bank-accounts/{account_id}/recurring-payments/{payment_id}:
    parameters:
      - $ref: "#/components/parameters/CaseId"
      - name: account_id
        in: path
        required: true
        schema:
          type: string
      - name: payment_id
        in: path
        required: true
        schema:
          type: string
    patch:
      operationId: updateRecurringPayment
      tags: [Recurring Payments]
      summary: Update recurring payment
      description: Update a recurring payment (e.g., mark as cancelled).
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/RecurringPaymentWrite"
      responses:
        "200":
          description: Recurring payment updated.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: "#/components/schemas/RecurringPayment"
        "404":
          $ref: "#/components/responses/NotFound"
        "422":
          $ref: "#/components/responses/ValidationError"

  # ==================== ACCOUNT BENEFICIARIES ====================
  /cases/{case_id}/bank-accounts/{account_id}/beneficiaries:
    parameters:
      - $ref: "#/components/parameters/CaseId"
      - name: account_id
        in: path
        required: true
        schema:
          type: string
    get:
      operationId: listAccountBeneficiaries
      tags: [Account Beneficiaries]
      summary: List POD/TOD beneficiaries
      description: List all POD (Payable on Death) and TOD (Transfer on Death) beneficiary designations.
      responses:
        "200":
          description: List of beneficiaries.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/AccountBeneficiary"
        "404":
          $ref: "#/components/responses/NotFound"

  /cases/{case_id}/bank-accounts/{account_id}/beneficiaries/{beneficiary_id}:
    parameters:
      - $ref: "#/components/parameters/CaseId"
      - name: account_id
        in: path
        required: true
        schema:
          type: string
      - name: beneficiary_id
        in: path
        required: true
        schema:
          type: string
    patch:
      operationId: updateAccountBeneficiary
      tags: [Account Beneficiaries]
      summary: Update beneficiary
      description: Update a beneficiary designation.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/AccountBeneficiaryWrite"
      responses:
        "200":
          description: Beneficiary updated.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: "#/components/schemas/AccountBeneficiary"
        "404":
          $ref: "#/components/responses/NotFound"
        "422":
          $ref: "#/components/responses/ValidationError"

  # ==================== STATEMENTS ====================
  /cases/{case_id}/bank-accounts/{account_id}/statements:
    parameters:
      - $ref: "#/components/parameters/CaseId"
      - name: account_id
        in: path
        required: true
        schema:
          type: string
    get:
      operationId: listStatements
      tags: [Statements]
      summary: List statements
      description: List available bank statements for an account.
      parameters:
        - $ref: "#/components/parameters/Page"
        - $ref: "#/components/parameters/PerPage"
      responses:
        "200":
          description: List of statements.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/Statement"
                  meta:
                    $ref: "#/components/schemas/PaginationMeta"
        "404":
          $ref: "#/components/responses/NotFound"

  /cases/{case_id}/bank-accounts/{account_id}/statements/{statement_id}:
    parameters:
      - $ref: "#/components/parameters/CaseId"
      - name: account_id
        in: path
        required: true
        schema:
          type: string
      - name: statement_id
        in: path
        required: true
        schema:
          type: string
    get:
      operationId: getStatement
      tags: [Statements]
      summary: Get statement metadata
      description: Retrieve metadata for a bank statement.
      responses:
        "200":
          description: Statement metadata.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: "#/components/schemas/Statement"
        "404":
          $ref: "#/components/responses/NotFound"

  /cases/{case_id}/bank-accounts/{account_id}/statements/{statement_id}/download:
    parameters:
      - $ref: "#/components/parameters/CaseId"
      - name: account_id
        in: path
        required: true
        schema:
          type: string
      - name: statement_id
        in: path
        required: true
        schema:
          type: string
    get:
      operationId: downloadStatement
      tags: [Statements]
      summary: Download statement PDF
      description: Download the statement file.
      responses:
        "200":
          description: Statement file.
          content:
            application/pdf:
              schema:
                type: string
                format: binary
        "404":
          $ref: "#/components/responses/NotFound"

  # ==================== BALANCE HISTORY ====================
  /cases/{case_id}/bank-accounts/{account_id}/balance-history:
    parameters:
      - $ref: "#/components/parameters/CaseId"
      - name: account_id
        in: path
        required: true
        schema:
          type: string
    get:
      operationId: getBalanceHistory
      tags: [Balance History]
      summary: Get balance history
      description: Retrieve historical balance snapshots for a bank account.
      parameters:
        - name: date_from
          in: query
          schema:
            type: string
            format: date
          description: "Start date (inclusive)."
        - name: date_to
          in: query
          schema:
            type: string
            format: date
          description: "End date (inclusive)."
        - name: interval
          in: query
          schema:
            type: string
            enum: [daily, weekly, monthly]
            default: monthly
          description: "Granularity of snapshots."
      responses:
        "200":
          description: Balance history.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/BalanceSnapshot"
        "404":
          $ref: "#/components/responses/NotFound"

  # ==================== INSTANT INHERITANCE ====================
  /cases/{case_id}/transfers:
    parameters:
      - $ref: "#/components/parameters/CaseId"
    get:
      operationId: listTransfers
      tags: [Transfers]
      summary: List transfers
      description: List every Instant Inheritance transfer on a case, newest first.
      parameters:
        - $ref: "#/components/parameters/Page"
        - $ref: "#/components/parameters/PerPage"
        - $ref: "#/components/parameters/SortOrder"
        - name: status
          in: query
          schema:
            type: string
            enum: [requested, verifying, approved, submitted, in_transit, completed, returned, rejected, cancelled]
          description: "Filter by transfer status."
        - name: bank_account_id
          in: query
          schema:
            type: string
          description: "Only transfers pulling from this bank account."
      responses:
        "200":
          description: List of transfers.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/Transfer"
                  meta:
                    $ref: "#/components/schemas/PaginationMeta"
        "404":
          $ref: "#/components/responses/NotFound"
    post:
      operationId: createTransfer
      tags: [Transfers]
      summary: Request a transfer
      description: |
        Request an Instant Inheritance transfer from an eligible bank account into the case's estate account.

        The bank account must already be `eligible` — read the `instant_inheritance` summary on the
        bank account first. Requesting a transfer on an account that is not eligible returns `422`.

        Only one transfer may be in flight per bank account. Send an `Idempotency-Key` header so a retried
        request never moves money twice.
      parameters:
        - $ref: "#/components/parameters/IdempotencyKey"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/TransferCreate"
      responses:
        "201":
          description: Transfer requested.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: "#/components/schemas/Transfer"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
        "409":
          $ref: "#/components/responses/Conflict"
        "422":
          description: "The account is not eligible, the amount exceeds the confirmed balance, or a transfer is already in flight."
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
              example:
                error:
                  code: "transfer_not_eligible"
                  message: "This account is not approved for Instant Inheritance."

  /cases/{case_id}/transfers/{transfer_id}:
    parameters:
      - $ref: "#/components/parameters/CaseId"
      - name: transfer_id
        in: path
        required: true
        schema:
          type: string
        description: "Transfer identifier."
    get:
      operationId: getTransfer
      tags: [Transfers]
      summary: Get a transfer
      description: Retrieve a single transfer and its current status.
      parameters:
        - $ref: "#/components/parameters/IfNoneMatch"
      responses:
        "200":
          description: Transfer details.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: "#/components/schemas/Transfer"
        "304":
          description: Not modified.
        "404":
          $ref: "#/components/responses/NotFound"

  /cases/{case_id}/transfers/{transfer_id}/cancel:
    parameters:
      - $ref: "#/components/parameters/CaseId"
      - name: transfer_id
        in: path
        required: true
        schema:
          type: string
        description: "Transfer identifier."
    post:
      operationId: cancelTransfer
      tags: [Transfers]
      summary: Cancel a transfer
      description: |
        Cancel a transfer that has not yet been submitted to the ACH network. Transfers in
        `requested`, `verifying`, or `approved` may be cancelled; once the status is `submitted`
        the transfer can no longer be stopped.

        Transfers are not deleted. A cancelled transfer stays on the case for audit purposes.
      requestBody:
        required: false
        content:
          application/json:
            schema:
              type: object
              properties:
                reason:
                  type: string
                  example: "Executor asked us to hold until the sibling dispute is resolved."
      responses:
        "200":
          description: Transfer cancelled.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: "#/components/schemas/Transfer"
        "404":
          $ref: "#/components/responses/NotFound"
        "422":
          description: "The transfer has already been submitted and cannot be cancelled."
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
              example:
                error:
                  code: "transfer_not_cancellable"
                  message: "This transfer was submitted to the ACH network and can no longer be cancelled."

  # ==================== PROBATE REFERENCE: STATES ====================
  /probate/states:
    get:
      operationId: listProbateStates
      tags: [Probate Reference]
      summary: List states
      description: List all 50 states, DC, and US territories with probate summaries.
      parameters:
        - name: upc_adopted
          in: query
          schema:
            type: boolean
          description: "Filter by UPC adoption."
        - name: community_property_state
          in: query
          schema:
            type: boolean
        - name: attorney_required
          in: query
          schema:
            type: boolean
      responses:
        "200":
          description: List of states with probate summaries.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/ProbateStateSummary"

  /probate/states/{state_code}:
    parameters:
      - name: state_code
        in: path
        required: true
        schema:
          type: string
          minLength: 2
          maxLength: 2
        description: "Two-letter state code (e.g., UT, CA, NY)."
        example: "UT"
    get:
      operationId: getProbateState
      tags: [Probate Reference]
      summary: Get state probate details
      description: Retrieve comprehensive probate information for a state including laws, thresholds, requirements, tax info, and spousal rights.
      responses:
        "200":
          description: Full state probate details.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: "#/components/schemas/ProbateState"
        "404":
          $ref: "#/components/responses/NotFound"

  # ==================== PROBATE REFERENCE: COUNTIES ====================
  /probate/states/{state_code}/counties:
    parameters:
      - name: state_code
        in: path
        required: true
        schema:
          type: string
          minLength: 2
          maxLength: 2
        example: "UT"
    get:
      operationId: listProbateCounties
      tags: [Probate Reference]
      summary: List counties in a state
      description: List all counties in a state with probate court summaries.
      parameters:
        - $ref: "#/components/parameters/Page"
        - $ref: "#/components/parameters/PerPage"
        - name: electronic_filing_available
          in: query
          schema:
            type: boolean
      responses:
        "200":
          description: List of counties.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/ProbateCountySummary"
                  meta:
                    $ref: "#/components/schemas/PaginationMeta"
        "404":
          $ref: "#/components/responses/NotFound"

  /probate/states/{state_code}/counties/{county_slug}:
    parameters:
      - name: state_code
        in: path
        required: true
        schema:
          type: string
          minLength: 2
          maxLength: 2
        example: "UT"
      - name: county_slug
        in: path
        required: true
        schema:
          type: string
        description: "URL-friendly county name (e.g., cache-county)."
        example: "cache-county"
    get:
      operationId: getProbateCounty
      tags: [Probate Reference]
      summary: Get county probate details
      description: Retrieve full probate court details for a county including fees, forms, hours, and filing information.
      responses:
        "200":
          description: Full county probate details.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: "#/components/schemas/ProbateCounty"
        "404":
          $ref: "#/components/responses/NotFound"

  # ==================== PROBATE REFERENCE: FORMS ====================
  /probate/states/{state_code}/forms:
    parameters:
      - name: state_code
        in: path
        required: true
        schema:
          type: string
          minLength: 2
          maxLength: 2
        example: "UT"
    get:
      operationId: listProbateForms
      tags: [Probate Forms]
      summary: List state probate forms
      description: List all state-level probate forms.
      parameters:
        - $ref: "#/components/parameters/Page"
        - $ref: "#/components/parameters/PerPage"
        - name: category
          in: query
          schema:
            type: string
            enum: [petition, notice, inventory, accounting, distribution, bond, waiver, affidavit, letters, order, other]
        - name: required_for
          in: query
          schema:
            type: string
            enum: [formal_probate, informal_probate, small_estate_affidavit, summary_administration, ancillary_probate, supervised_administration, unsupervised_administration]
          description: "Filter forms required for a specific probate type."
      responses:
        "200":
          description: List of probate forms.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/ProbateForm"
                  meta:
                    $ref: "#/components/schemas/PaginationMeta"
        "404":
          $ref: "#/components/responses/NotFound"

  /probate/states/{state_code}/forms/{form_id}:
    parameters:
      - name: state_code
        in: path
        required: true
        schema:
          type: string
          minLength: 2
          maxLength: 2
        example: "UT"
      - name: form_id
        in: path
        required: true
        schema:
          type: string
    get:
      operationId: getProbateForm
      tags: [Probate Forms]
      summary: Get form details
      description: Retrieve details and download link for a probate form.
      responses:
        "200":
          description: Form details.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: "#/components/schemas/ProbateForm"
        "404":
          $ref: "#/components/responses/NotFound"

  # ==================== PROBATE CASE TRACKING ====================
  /cases/{case_id}/probate:
    parameters:
      - $ref: "#/components/parameters/CaseId"
    get:
      operationId: getProbateCase
      tags: [Probate Case]
      summary: Get probate case details
      description: Retrieve probate case tracking details for an estate case.
      responses:
        "200":
          description: Probate case details.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: "#/components/schemas/ProbateCase"
        "404":
          $ref: "#/components/responses/NotFound"
    put:
      operationId: setProbateCase
      tags: [Probate Case]
      summary: Set probate case info
      description: Create or replace probate case tracking information.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/ProbateCase"
      responses:
        "200":
          description: Probate case info set.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: "#/components/schemas/ProbateCase"
        "404":
          $ref: "#/components/responses/NotFound"
        "422":
          $ref: "#/components/responses/ValidationError"
    patch:
      operationId: updateProbateCase
      tags: [Probate Case]
      summary: Update probate case info
      description: Partially update probate case tracking information.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/ProbateCase"
      responses:
        "200":
          description: Probate case info updated.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: "#/components/schemas/ProbateCase"
        "404":
          $ref: "#/components/responses/NotFound"
        "422":
          $ref: "#/components/responses/ValidationError"

  # ==================== PROBATE DEADLINES ====================
  /cases/{case_id}/probate/deadlines:
    parameters:
      - $ref: "#/components/parameters/CaseId"
    get:
      operationId: listProbateDeadlines
      tags: [Probate Deadlines]
      summary: List probate deadlines
      description: List all probate deadlines and due dates for a case.
      parameters:
        - $ref: "#/components/parameters/Page"
        - $ref: "#/components/parameters/PerPage"
        - name: status
          in: query
          schema:
            type: string
            enum: [upcoming, overdue, completed, waived]
        - name: type
          in: query
          schema:
            type: string
            enum: [filing, hearing, creditor_notice, inventory, accounting, distribution, tax_return, bond_renewal, other]
      responses:
        "200":
          description: List of deadlines.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/ProbateDeadline"
                  meta:
                    $ref: "#/components/schemas/PaginationMeta"
        "404":
          $ref: "#/components/responses/NotFound"

  /cases/{case_id}/probate/deadlines/{deadline_id}:
    parameters:
      - $ref: "#/components/parameters/CaseId"
      - name: deadline_id
        in: path
        required: true
        schema:
          type: string
    patch:
      operationId: updateProbateDeadline
      tags: [Probate Deadlines]
      summary: Update a deadline
      description: Update a deadline (mark complete, reschedule, etc.).
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/ProbateDeadlineWrite"
      responses:
        "200":
          description: Deadline updated.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: "#/components/schemas/ProbateDeadline"
        "404":
          $ref: "#/components/responses/NotFound"
        "422":
          $ref: "#/components/responses/ValidationError"

  # ==================== PROBATE FILINGS ====================
  /cases/{case_id}/probate/filings:
    parameters:
      - $ref: "#/components/parameters/CaseId"
    get:
      operationId: listProbateFilings
      tags: [Probate Filings]
      summary: List court filings
      description: List all court filings for a case.
      parameters:
        - $ref: "#/components/parameters/Page"
        - $ref: "#/components/parameters/PerPage"
        - name: filing_type
          in: query
          schema:
            type: string
            enum: [petition, inventory, accounting, notice, motion, order, waiver, affidavit, deed, other]
        - name: court_response
          in: query
          schema:
            type: string
            enum: [accepted, rejected, pending]
      responses:
        "200":
          description: List of filings.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/ProbateFiling"
                  meta:
                    $ref: "#/components/schemas/PaginationMeta"
        "404":
          $ref: "#/components/responses/NotFound"

  /cases/{case_id}/probate/filings/{filing_id}:
    parameters:
      - $ref: "#/components/parameters/CaseId"
      - name: filing_id
        in: path
        required: true
        schema:
          type: string
    get:
      operationId: getProbateFiling
      tags: [Probate Filings]
      summary: Get filing details
      description: Retrieve details of a court filing.
      responses:
        "200":
          description: Filing details.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: "#/components/schemas/ProbateFiling"
        "404":
          $ref: "#/components/responses/NotFound"
    patch:
      operationId: updateProbateFiling
      tags: [Probate Filings]
      summary: Update filing
      description: Update a court filing record.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/ProbateFilingWrite"
      responses:
        "200":
          description: Filing updated.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: "#/components/schemas/ProbateFiling"
        "404":
          $ref: "#/components/responses/NotFound"
        "422":
          $ref: "#/components/responses/ValidationError"

  # ==================== CREDITOR CLAIMS ====================
  /cases/{case_id}/probate/creditor-claims:
    parameters:
      - $ref: "#/components/parameters/CaseId"
    get:
      operationId: listCreditorClaims
      tags: [Creditor Claims]
      summary: List creditor claims
      description: List all creditor claims against an estate.
      parameters:
        - $ref: "#/components/parameters/Page"
        - $ref: "#/components/parameters/PerPage"
        - name: status
          in: query
          schema:
            type: string
            enum: [filed, under_review, accepted, rejected, disputed, paid, partially_paid, expired]
        - name: claim_type
          in: query
          schema:
            type: string
            enum: [secured, unsecured, priority, contingent]
      responses:
        "200":
          description: List of creditor claims.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/CreditorClaim"
                  meta:
                    $ref: "#/components/schemas/PaginationMeta"
        "404":
          $ref: "#/components/responses/NotFound"

  /cases/{case_id}/probate/creditor-claims/{claim_id}:
    parameters:
      - $ref: "#/components/parameters/CaseId"
      - name: claim_id
        in: path
        required: true
        schema:
          type: string
    get:
      operationId: getCreditorClaim
      tags: [Creditor Claims]
      summary: Get claim details
      description: Retrieve details of a creditor claim.
      responses:
        "200":
          description: Claim details.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: "#/components/schemas/CreditorClaim"
        "404":
          $ref: "#/components/responses/NotFound"
    patch:
      operationId: updateCreditorClaim
      tags: [Creditor Claims]
      summary: Update claim status
      description: Update a creditor claim (e.g., accept, reject, mark as paid).
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreditorClaimWrite"
      responses:
        "200":
          description: Claim updated.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: "#/components/schemas/CreditorClaim"
        "404":
          $ref: "#/components/responses/NotFound"
        "422":
          $ref: "#/components/responses/ValidationError"

  # ==================== DISTRIBUTIONS ====================
  /cases/{case_id}/probate/distributions:
    parameters:
      - $ref: "#/components/parameters/CaseId"
    get:
      operationId: listDistributions
      tags: [Distributions]
      summary: List distributions
      description: List all distributions to beneficiaries for a case.
      parameters:
        - $ref: "#/components/parameters/Page"
        - $ref: "#/components/parameters/PerPage"
        - name: status
          in: query
          schema:
            type: string
            enum: [pending, approved, completed, disputed]
        - name: asset_type
          in: query
          schema:
            type: string
            enum: [cash, real_property, personal_property, securities, vehicle, other]
      responses:
        "200":
          description: List of distributions.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/Distribution"
                  meta:
                    $ref: "#/components/schemas/PaginationMeta"
        "404":
          $ref: "#/components/responses/NotFound"

  /cases/{case_id}/probate/distributions/{distribution_id}:
    parameters:
      - $ref: "#/components/parameters/CaseId"
      - name: distribution_id
        in: path
        required: true
        schema:
          type: string
    get:
      operationId: getDistribution
      tags: [Distributions]
      summary: Get distribution details
      description: Retrieve details of a distribution.
      responses:
        "200":
          description: Distribution details.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: "#/components/schemas/Distribution"
        "404":
          $ref: "#/components/responses/NotFound"
    patch:
      operationId: updateDistribution
      tags: [Distributions]
      summary: Update distribution
      description: Update a distribution record.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/DistributionWrite"
      responses:
        "200":
          description: Distribution updated.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: "#/components/schemas/Distribution"
        "404":
          $ref: "#/components/responses/NotFound"
        "422":
          $ref: "#/components/responses/ValidationError"

  # ==================== PRO USERS ====================
  /users/me:
    get:
      operationId: getCurrentUser
      tags: [Pro Users]
      summary: Get current user profile
      description: Retrieve the current user's profile, plan details, and case count.
      responses:
        "200":
          description: User profile.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: "#/components/schemas/ProUser"
    patch:
      operationId: updateCurrentUser
      tags: [Pro Users]
      summary: Update current user profile
      description: Update the current user's profile information.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/ProUserUpdate"
      responses:
        "200":
          description: User profile updated.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: "#/components/schemas/ProUser"
        "422":
          $ref: "#/components/responses/ValidationError"

  /users/me/cases:
    get:
      operationId: listUserCases
      tags: [Pro Users]
      summary: List all cases for current user
      description: List all estate cases the current user has access to, including cases shared with them by other users. Pro users can manage multiple estates simultaneously.
      parameters:
        - $ref: "#/components/parameters/Page"
        - $ref: "#/components/parameters/PerPage"
        - name: role
          in: query
          schema:
            type: string
            enum: [owner, editor, viewer]
          description: "Filter by user's role on the case."
        - name: sort_by
          in: query
          schema:
            type: string
            enum: [created_at, updated_at, deceased_name]
            default: updated_at
        - $ref: "#/components/parameters/SortOrder"
        - name: search
          in: query
          schema:
            type: string
          description: "Search by deceased name or case metadata."
      responses:
        "200":
          description: List of cases accessible to the user.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/ProUserCaseSummary"
                  meta:
                    $ref: "#/components/schemas/PaginationMeta"

  # ==================== COLLABORATORS ====================
  /cases/{case_id}/collaborators:
    parameters:
      - $ref: "#/components/parameters/CaseId"
    get:
      operationId: listCollaborators
      tags: [Collaborators]
      summary: List collaborators
      description: List all users who have been invited to or have access to this case.
      parameters:
        - name: status
          in: query
          schema:
            type: string
            enum: [pending, accepted, declined, revoked]
        - name: role
          in: query
          schema:
            type: string
            enum: [owner, editor, viewer]
      responses:
        "200":
          description: List of collaborators.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/Collaborator"
        "404":
          $ref: "#/components/responses/NotFound"

  /cases/{case_id}/collaborators/{collaborator_id}:
    parameters:
      - $ref: "#/components/parameters/CaseId"
      - name: collaborator_id
        in: path
        required: true
        schema:
          type: string
    get:
      operationId: getCollaborator
      tags: [Collaborators]
      summary: Get collaborator details
      description: Retrieve details for a specific collaborator.
      responses:
        "200":
          description: Collaborator details.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: "#/components/schemas/Collaborator"
        "404":
          $ref: "#/components/responses/NotFound"
    patch:
      operationId: updateCollaborator
      tags: [Collaborators]
      summary: Update collaborator
      description: Update a collaborator's role or permissions.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CollaboratorUpdate"
      responses:
        "200":
          description: Collaborator updated.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: "#/components/schemas/Collaborator"
        "404":
          $ref: "#/components/responses/NotFound"
        "422":
          $ref: "#/components/responses/ValidationError"

  # ==================== CLOSURE ====================
  /cases/{case_id}/closure:
    parameters:
      - $ref: "#/components/parameters/CaseId"
    get:
      operationId: getClosureStatus
      tags: [Closure]
      summary: Get closure status
      description: Retrieve the overall closure status and all closure steps for a case. Steps are returned in order with dependency information.
      responses:
        "200":
          description: Closure status with all steps.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: "#/components/schemas/ClosureStatus"
        "404":
          $ref: "#/components/responses/NotFound"

  /cases/{case_id}/closure/steps/{step_id}:
    parameters:
      - $ref: "#/components/parameters/CaseId"
      - name: step_id
        in: path
        required: true
        schema:
          type: string
    get:
      operationId: getClosureStep
      tags: [Closure]
      summary: Get closure step details
      description: Retrieve details of a specific closure step including sub-tasks.
      responses:
        "200":
          description: Closure step details.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: "#/components/schemas/ClosureStep"
        "404":
          $ref: "#/components/responses/NotFound"
    patch:
      operationId: updateClosureStep
      tags: [Closure]
      summary: Update closure step
      description: Update a closure step's status, assignment, due date, or notes.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/ClosureStepUpdate"
      responses:
        "200":
          description: Closure step updated.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: "#/components/schemas/ClosureStep"
        "404":
          $ref: "#/components/responses/NotFound"
        "422":
          $ref: "#/components/responses/ValidationError"

  /cases/{case_id}/closure/steps/{step_id}/sub-tasks/{sub_task_id}:
    parameters:
      - $ref: "#/components/parameters/CaseId"
      - name: step_id
        in: path
        required: true
        schema:
          type: string
      - name: sub_task_id
        in: path
        required: true
        schema:
          type: string
    patch:
      operationId: updateClosureSubTask
      tags: [Closure]
      summary: Update a sub-task
      description: Update a sub-task (e.g., mark as completed).
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                title:
                  type: string
                completed:
                  type: boolean
                institution_contact_id:
                  type: string
      responses:
        "200":
          description: Sub-task updated.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: "#/components/schemas/ClosureStep"
        "404":
          $ref: "#/components/responses/NotFound"
        "422":
          $ref: "#/components/responses/ValidationError"

  # ==================== INSTITUTION CONTACTS ====================
  /cases/{case_id}/institution-contacts:
    parameters:
      - $ref: "#/components/parameters/CaseId"
    get:
      operationId: listInstitutionContacts
      tags: [Institution Contacts]
      summary: List institution contacts
      description: List all financial institution contact records for a case. Includes department-level contacts with account type routing.
      parameters:
        - $ref: "#/components/parameters/Page"
        - $ref: "#/components/parameters/PerPage"
        - name: institution_name
          in: query
          schema:
            type: string
          description: "Filter by institution name (partial match)."
        - name: account_type
          in: query
          schema:
            type: string
            enum: [bank, debt, investment, retirement, insurance]
          description: "Filter contacts that handle this account type."
        - name: is_default_contact
          in: query
          schema:
            type: boolean
      responses:
        "200":
          description: List of institution contacts.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/InstitutionContact"
                  meta:
                    $ref: "#/components/schemas/PaginationMeta"
        "404":
          $ref: "#/components/responses/NotFound"

  /cases/{case_id}/institution-contacts/{contact_id}:
    parameters:
      - $ref: "#/components/parameters/CaseId"
      - name: contact_id
        in: path
        required: true
        schema:
          type: string
    get:
      operationId: getInstitutionContact
      tags: [Institution Contacts]
      summary: Get institution contact
      description: Retrieve a specific institution contact.
      responses:
        "200":
          description: Contact details.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: "#/components/schemas/InstitutionContact"
        "404":
          $ref: "#/components/responses/NotFound"
    patch:
      operationId: updateInstitutionContact
      tags: [Institution Contacts]
      summary: Update institution contact
      description: Update an institution contact's department info, contact methods, or account type routing.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/InstitutionContactWrite"
      responses:
        "200":
          description: Contact updated.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: "#/components/schemas/InstitutionContact"
        "404":
          $ref: "#/components/responses/NotFound"
        "422":
          $ref: "#/components/responses/ValidationError"

  # ==================== PHONE CALLS ====================
  /cases/{case_id}/phone-calls:
    parameters:
      - $ref: "#/components/parameters/CaseId"
    get:
      operationId: listPhoneCalls
      tags: [Phone Calls]
      summary: List phone calls
      description: List all phone calls made for a case, including recordings and AI-generated summaries.
      parameters:
        - $ref: "#/components/parameters/Page"
        - $ref: "#/components/parameters/PerPage"
        - name: status
          in: query
          schema:
            type: string
            enum: [initiated, ringing, in_progress, completed, failed, no_answer, busy, cancelled]
        - name: institution_contact_id
          in: query
          schema:
            type: string
          description: "Filter calls to a specific institution contact."
        - name: sort_by
          in: query
          schema:
            type: string
            enum: [created_at, duration_seconds]
            default: created_at
        - $ref: "#/components/parameters/SortOrder"
      responses:
        "200":
          description: List of phone calls.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/PhoneCall"
                  meta:
                    $ref: "#/components/schemas/PaginationMeta"
        "404":
          $ref: "#/components/responses/NotFound"

  /cases/{case_id}/phone-calls/{call_id}:
    parameters:
      - $ref: "#/components/parameters/CaseId"
      - name: call_id
        in: path
        required: true
        schema:
          type: string
    get:
      operationId: getPhoneCall
      tags: [Phone Calls]
      summary: Get phone call details
      description: Retrieve details of a phone call including recording URL, transcript, AI summary, and action items.
      responses:
        "200":
          description: Phone call details.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: "#/components/schemas/PhoneCall"
        "404":
          $ref: "#/components/responses/NotFound"
    patch:
      operationId: updatePhoneCall
      tags: [Phone Calls]
      summary: Update phone call
      description: Update phone call notes or action item completion status.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                notes:
                  type: string
                action_items:
                  type: array
                  items:
                    type: object
                    properties:
                      description:
                        type: string
                      completed:
                        type: boolean
      responses:
        "200":
          description: Phone call updated.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: "#/components/schemas/PhoneCall"
        "404":
          $ref: "#/components/responses/NotFound"
        "422":
          $ref: "#/components/responses/ValidationError"

  /cases/{case_id}/phone-calls/{call_id}/recording:
    parameters:
      - $ref: "#/components/parameters/CaseId"
      - name: call_id
        in: path
        required: true
        schema:
          type: string
    get:
      operationId: getPhoneCallRecording
      tags: [Phone Calls]
      summary: Download call recording
      description: Download the audio recording of a phone call.
      responses:
        "200":
          description: Recording audio file.
          content:
            audio/mpeg:
              schema:
                type: string
                format: binary
        "404":
          $ref: "#/components/responses/NotFound"

  # ==================== EMAILS ====================
  /cases/{case_id}/emails:
    parameters:
      - $ref: "#/components/parameters/CaseId"
    get:
      operationId: listEmails
      tags: [Emails]
      summary: List emails
      description: List all emails sent for a case, including delivery status and receipts.
      parameters:
        - $ref: "#/components/parameters/Page"
        - $ref: "#/components/parameters/PerPage"
        - name: status
          in: query
          schema:
            type: string
            enum: [draft, queued, sent, delivered, bounced, failed]
        - name: institution_contact_id
          in: query
          schema:
            type: string
        - name: sort_by
          in: query
          schema:
            type: string
            enum: [created_at, sent_at]
            default: created_at
        - $ref: "#/components/parameters/SortOrder"
      responses:
        "200":
          description: List of emails.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/Email"
                  meta:
                    $ref: "#/components/schemas/PaginationMeta"
        "404":
          $ref: "#/components/responses/NotFound"

  /cases/{case_id}/emails/{email_id}:
    parameters:
      - $ref: "#/components/parameters/CaseId"
      - name: email_id
        in: path
        required: true
        schema:
          type: string
    get:
      operationId: getEmail
      tags: [Emails]
      summary: Get email details
      description: Retrieve email details including delivery receipt, open tracking, and attachment info.
      responses:
        "200":
          description: Email details.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: "#/components/schemas/Email"
        "404":
          $ref: "#/components/responses/NotFound"

  /cases/{case_id}/emails/{email_id}/receipt:
    parameters:
      - $ref: "#/components/parameters/CaseId"
      - name: email_id
        in: path
        required: true
        schema:
          type: string
    get:
      operationId: getEmailReceipt
      tags: [Emails]
      summary: Get email delivery receipt
      description: Retrieve the delivery receipt for an email, including provider status and timestamps.
      responses:
        "200":
          description: Email receipt.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      email_id:
                        type: string
                      message_id:
                        type: string
                      provider:
                        type: string
                      status:
                        type: string
                        enum: [accepted, delivered, bounced, deferred]
                      status_detail:
                        type:
                          - string
                          - "null"
                      sent_at:
                        type: string
                        format: date-time
                      delivered_at:
                        type:
                          - string
                          - "null"
                        format: date-time
                      opened_at:
                        type:
                          - string
                          - "null"
                        format: date-time
        "404":
          $ref: "#/components/responses/NotFound"

  # ==================== NOTARIZATION ====================
  /cases/{case_id}/notarizations:
    parameters:
      - $ref: "#/components/parameters/CaseId"
    get:
      operationId: listNotarizations
      tags: [Notarization]
      summary: List notarizations
      description: List all notarization requests for a case.
      parameters:
        - $ref: "#/components/parameters/Page"
        - $ref: "#/components/parameters/PerPage"
        - name: status
          in: query
          schema:
            type: string
            enum: [draft, pending_signer, pending_notary, in_session, completed, declined, expired, failed]
      responses:
        "200":
          description: List of notarizations.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/Notarization"
                  meta:
                    $ref: "#/components/schemas/PaginationMeta"
        "404":
          $ref: "#/components/responses/NotFound"

  /cases/{case_id}/notarizations/{notarization_id}:
    parameters:
      - $ref: "#/components/parameters/CaseId"
      - name: notarization_id
        in: path
        required: true
        schema:
          type: string
    get:
      operationId: getNotarization
      tags: [Notarization]
      summary: Get notarization details
      description: Retrieve notarization details including signer status, notary info, and download link for the notarized document.
      responses:
        "200":
          description: Notarization details.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: "#/components/schemas/Notarization"
        "404":
          $ref: "#/components/responses/NotFound"

  /cases/{case_id}/notarizations/{notarization_id}/download:
    parameters:
      - $ref: "#/components/parameters/CaseId"
      - name: notarization_id
        in: path
        required: true
        schema:
          type: string
    get:
      operationId: downloadNotarizedDocument
      tags: [Notarization]
      summary: Download notarized document
      description: Download the completed notarized document PDF.
      responses:
        "200":
          description: Notarized document file.
          content:
            application/pdf:
              schema:
                type: string
                format: binary
        "404":
          $ref: "#/components/responses/NotFound"

  # ==================== FAXES ====================
  /cases/{case_id}/faxes:
    parameters:
      - $ref: "#/components/parameters/CaseId"
    get:
      operationId: listFaxes
      tags: [Faxes]
      summary: List faxes
      description: List all faxes sent for a case, including delivery receipts.
      parameters:
        - $ref: "#/components/parameters/Page"
        - $ref: "#/components/parameters/PerPage"
        - name: status
          in: query
          schema:
            type: string
            enum: [queued, sending, delivered, failed, cancelled]
        - name: institution_contact_id
          in: query
          schema:
            type: string
      responses:
        "200":
          description: List of faxes.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/Fax"
                  meta:
                    $ref: "#/components/schemas/PaginationMeta"
        "404":
          $ref: "#/components/responses/NotFound"

  /cases/{case_id}/faxes/{fax_id}:
    parameters:
      - $ref: "#/components/parameters/CaseId"
      - name: fax_id
        in: path
        required: true
        schema:
          type: string
    get:
      operationId: getFax
      tags: [Faxes]
      summary: Get fax details
      description: Retrieve fax details including delivery receipt with confirmation number and page count.
      responses:
        "200":
          description: Fax details.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: "#/components/schemas/Fax"
        "404":
          $ref: "#/components/responses/NotFound"

  /cases/{case_id}/faxes/{fax_id}/receipt:
    parameters:
      - $ref: "#/components/parameters/CaseId"
      - name: fax_id
        in: path
        required: true
        schema:
          type: string
    get:
      operationId: getFaxReceipt
      tags: [Faxes]
      summary: Get fax delivery receipt
      description: Retrieve the delivery receipt for a fax including confirmation number, pages sent, and duration.
      responses:
        "200":
          description: Fax receipt.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      fax_id:
                        type: string
                      confirmation_number:
                        type: string
                      pages_sent:
                        type: integer
                      duration_seconds:
                        type: integer
                      status:
                        type: string
                        enum: [confirmed, partial, failed]
                      remote_station_id:
                        type:
                          - string
                          - "null"
                      timestamp:
                        type: string
                        format: date-time
        "404":
          $ref: "#/components/responses/NotFound"

  # ==================== IDENTITY VERIFICATION ====================
  /cases/{case_id}/identity-verifications:
    parameters:
      - $ref: "#/components/parameters/CaseId"
    get:
      operationId: listIdentityVerifications
      tags: [Identity Verification]
      summary: List identity verifications
      description: List all identity verification checks for the deceased and executor on this case.
      parameters:
        - name: subject_type
          in: query
          schema:
            type: string
            enum: [deceased, executor]
          description: "Filter by subject type."
        - name: status
          in: query
          schema:
            type: string
            enum: [not_started, pending, in_progress, verified, failed, expired, requires_manual_review]
      responses:
        "200":
          description: List of identity verifications.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/IdentityVerification"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"

  /cases/{case_id}/identity-verifications/{verification_id}:
    parameters:
      - $ref: "#/components/parameters/CaseId"
      - name: verification_id
        in: path
        required: true
        schema:
          type: string
    get:
      operationId: getIdentityVerification
      tags: [Identity Verification]
      summary: Get verification details
      description: Retrieve detailed identity verification results including individual check statuses and any failure reasons.
      responses:
        "200":
          description: Verification details.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: "#/components/schemas/IdentityVerification"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
    patch:
      operationId: updateIdentityVerification
      tags: [Identity Verification]
      summary: Update verification
      description: Update verification notes or attach additional documents. Cannot change the verification status directly — status transitions happen automatically based on check results.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                document_ids:
                  type: array
                  items:
                    type: string
                  description: "Additional document IDs to attach."
                notes:
                  type: string
      responses:
        "200":
          description: Verification updated.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: "#/components/schemas/IdentityVerification"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
        "422":
          $ref: "#/components/responses/ValidationError"

  # ==================== REAL ESTATE VALUATIONS ====================
  /cases/{case_id}/real-estate-valuations:
    parameters:
      - $ref: "#/components/parameters/CaseId"
    get:
      operationId: listRealEstateValuations
      tags: [Real Estate Valuations]
      summary: List real estate valuations
      description: List all property valuations for a case, including automated AVM results, tax assessments, and appraisal records.
      parameters:
        - $ref: "#/components/parameters/Page"
        - $ref: "#/components/parameters/PerPage"
        - name: status
          in: query
          schema:
            type: string
            enum: [pending, completed, failed, stale]
        - name: property_type
          in: query
          schema:
            type: string
            enum: [single_family, multi_family, condo, townhouse, mobile_home, vacant_land, commercial, farm_ranch, mixed_use, other]
      responses:
        "200":
          description: List of valuations.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/RealEstateValuation"
                  meta:
                    $ref: "#/components/schemas/PaginationMeta"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"

  /cases/{case_id}/real-estate-valuations/{valuation_id}:
    parameters:
      - $ref: "#/components/parameters/CaseId"
      - name: valuation_id
        in: path
        required: true
        schema:
          type: string
    get:
      operationId: getRealEstateValuation
      tags: [Real Estate Valuations]
      summary: Get valuation details
      description: Retrieve detailed property valuation including comparable sales, tax assessment data, lien information, and equity estimate.
      responses:
        "200":
          description: Valuation details.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: "#/components/schemas/RealEstateValuation"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
    patch:
      operationId: updateRealEstateValuation
      tags: [Real Estate Valuations]
      summary: Update valuation
      description: Update property details, mortgage balance, or notes on a valuation. The equity estimate is recalculated automatically when mortgage balance changes.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                property_type:
                  type: string
                  enum: [single_family, multi_family, condo, townhouse, mobile_home, vacant_land, commercial, farm_ranch, mixed_use, other]
                mortgage_balance:
                  type: number
                  format: double
                notes:
                  type: string
                liens:
                  type: array
                  items:
                    type: object
                    properties:
                      lien_type:
                        type: string
                        enum: [mortgage, home_equity, tax_lien, mechanics_lien, judgment_lien, hoa_lien, other]
                      holder:
                        type: string
                      amount:
                        type: number
                        format: double
                      recorded_date:
                        type: string
                        format: date
      responses:
        "200":
          description: Valuation updated.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: "#/components/schemas/RealEstateValuation"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
        "422":
          $ref: "#/components/responses/ValidationError"

  # ==================== LIFE INSURANCE ====================
  /cases/{case_id}/life-insurance:
    parameters:
      - $ref: "#/components/parameters/CaseId"
    get:
      operationId: listLifeInsurancePolicies
      tags: [Life Insurance]
      summary: List life insurance policies
      description: List all life insurance policies discovered for a case, including term, whole, universal, group, and government policies.
      parameters:
        - $ref: "#/components/parameters/Page"
        - $ref: "#/components/parameters/PerPage"
        - name: policy_type
          in: query
          schema:
            type: string
            enum: [term_life, whole_life, universal_life, variable_life, group_employer, group_government, supplemental, accidental_death, annuity_with_death_benefit]
        - name: claim_status
          in: query
          schema:
            type: string
            enum: [not_filed, filed, under_review, approved, paid, denied]
      responses:
        "200":
          description: List of policies.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/LifeInsurancePolicy"
                  meta:
                    $ref: "#/components/schemas/PaginationMeta"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
  /cases/{case_id}/life-insurance/{policy_id}:
    parameters:
      - $ref: "#/components/parameters/CaseId"
      - name: policy_id
        in: path
        required: true
        schema:
          type: string
    get:
      operationId: getLifeInsurancePolicy
      tags: [Life Insurance]
      summary: Get policy details
      responses:
        "200":
          description: Policy details.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: "#/components/schemas/LifeInsurancePolicy"
        "404":
          $ref: "#/components/responses/NotFound"
    patch:
      operationId: updateLifeInsurancePolicy
      tags: [Life Insurance]
      summary: Update policy
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/LifeInsurancePolicyWrite"
      responses:
        "200":
          description: Policy updated.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: "#/components/schemas/LifeInsurancePolicy"
        "404":
          $ref: "#/components/responses/NotFound"
        "422":
          $ref: "#/components/responses/ValidationError"

  # ==================== CREDIT CARDS & DEBTS ====================
  /cases/{case_id}/debts:
    parameters:
      - $ref: "#/components/parameters/CaseId"
    get:
      operationId: listDebts
      tags: [Credit Cards & Debts]
      summary: List debts
      description: List all credit cards, loans, and debts for a case.
      parameters:
        - $ref: "#/components/parameters/Page"
        - $ref: "#/components/parameters/PerPage"
        - name: debt_type
          in: query
          schema:
            type: string
            enum: [AGR, AUL, AUT, AO, ATY, BCC, BMP, BPG, BUS, "C/C", "C/G", "C/M", "C/S", CCP, CEL, CGA, CHG, CIL, CKG, CLC, CLS, COL, CON, COS, CRC, CSA, CSL, "D/C", DCS, DEP, EDU, EXM, "F/C", "F/S", FCO, FHA, FMH, FSC, "G/B", "G/F", "G/G", GEA, GFS, GMD, GOP, "H+O", "H/E", HEI, "H/I", HHG, "I/L", INS, ISC, LBP, LEA, LPI, LIC, "M/H", MED, MRI, NCS, NTE, "P/S", PHG, PPI, "R/C", "R/E", "R/F", "R/O", "R/S", "R/V", RCK, REC, REN, RES, "S/S", SCC, SAA, SC0, SDL, SEC, SGL, SHI, SMP, SUM, TSL, UDL, UGL, UNK, UNS, UTI, ZZZ, "7B", "3A", "00", "95", "8A", "85", "9B", "10", "15", "98", "6B", "93", "37", "4D", "6C", "07", G1, "96", "7A", "47", "48", "91", "14", "18", "5C", "0F", "43", "34", "8B", "12", "33", "16", "50", "0C", "05", "2C", "75", "71", "69", "73", "72", "74", "70", "23", "89", "6D", "04", "22", "78", "49", "06", "1B", "13", "1A", "3C", "17", "90", "86", "21", "20", "03", "1C", "83", "26", "08", "19", "27", "5B", "25", "77", "11", "29", "5A", "94", "2A", "7C", "09", "68", "02", "66", "9A", "87", "30", "0A", "67", "65", "31", "01", "92", ZZ, "0G"]
        - name: condition
          in: query
          schema:
            type: string
            enum: [DECEASED, CHARGEOFF, BANKRUPTCY, TRANSFER, REPOSSESSION, CLOSED, BANKRUPTCYPET, COLLECTIONS, DELINQUENT120, DELINQUENT90, DELINQUENT60, DELINQUENT30, REFINANCED, LOST, OPEN, PAID, UNKNOWN]
        - name: responsibility
          in: query
          schema:
            type: string
            enum: ["1", B, I, "8", C, "5", S, "2", J, "4", P, "3", A, "7", M, "0", O, U, "9", T, X]
        - name: notification_status
          in: query
          schema:
            type: string
            enum: [not_notified, notified, acknowledged, resolved]
      responses:
        "200":
          description: List of debts.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/CreditCardDebt"
                  meta:
                    $ref: "#/components/schemas/PaginationMeta"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
  /cases/{case_id}/debts/{debt_id}:
    parameters:
      - $ref: "#/components/parameters/CaseId"
      - name: debt_id
        in: path
        required: true
        schema:
          type: string
    get:
      operationId: getDebt
      tags: [Credit Cards & Debts]
      summary: Get debt details
      responses:
        "200":
          description: Debt details.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: "#/components/schemas/CreditCardDebt"
        "404":
          $ref: "#/components/responses/NotFound"
    patch:
      operationId: updateDebt
      tags: [Credit Cards & Debts]
      summary: Update debt
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreditCardDebtWrite"
      responses:
        "200":
          description: Debt updated.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: "#/components/schemas/CreditCardDebt"
        "404":
          $ref: "#/components/responses/NotFound"
        "422":
          $ref: "#/components/responses/ValidationError"

  # -------------------- Debts by Type Category --------------------
  /cases/{case_id}/debts/type/credit-cards:
    parameters:
      - $ref: "#/components/parameters/CaseId"
    get:
      operationId: listCreditCardDebts
      tags: [Credit Cards & Debts]
      summary: List credit card debts
      description: "Returns debts filtered to credit card types: CRC (Credit card), FSC (Credit card), CHG (Revolving charge account), SCC (Secured credit card), 18 (Credit card), 2A (Secured credit card), 07 (Revolving charge account), 0G (Flexible spending credit card)."
      parameters:
        - $ref: "#/components/parameters/Page"
        - $ref: "#/components/parameters/PerPage"
        - name: condition
          in: query
          schema:
            type: string
            enum: [DECEASED, CHARGEOFF, BANKRUPTCY, TRANSFER, REPOSSESSION, CLOSED, BANKRUPTCYPET, COLLECTIONS, DELINQUENT120, DELINQUENT90, DELINQUENT60, DELINQUENT30, REFINANCED, LOST, OPEN, PAID, UNKNOWN]
        - name: responsibility
          in: query
          schema:
            type: string
            enum: ["1", B, I, "8", C, "5", S, "2", J, "4", P, "3", A, "7", M, "0", O, U, "9", T, X]
      responses:
        "200":
          description: List of credit card debts.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/CreditCardDebt"
                  meta:
                    $ref: "#/components/schemas/PaginationMeta"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"

  /cases/{case_id}/debts/type/auto-vehicle:
    parameters:
      - $ref: "#/components/parameters/CaseId"
    get:
      operationId: listAutoVehicleDebts
      tags: [Credit Cards & Debts]
      summary: List auto/vehicle debts
      description: "Returns debts filtered to auto/vehicle types: AUT, AO, AUL, 00, 3A."
      parameters:
        - $ref: "#/components/parameters/Page"
        - $ref: "#/components/parameters/PerPage"
        - name: condition
          in: query
          schema:
            type: string
            enum: [DECEASED, CHARGEOFF, BANKRUPTCY, TRANSFER, REPOSSESSION, CLOSED, BANKRUPTCYPET, COLLECTIONS, DELINQUENT120, DELINQUENT90, DELINQUENT60, DELINQUENT30, REFINANCED, LOST, OPEN, PAID, UNKNOWN]
        - name: responsibility
          in: query
          schema:
            type: string
            enum: ["1", B, I, "8", C, "5", S, "2", J, "4", P, "3", A, "7", M, "0", O, U, "9", T, X]
      responses:
        "200":
          description: List of auto/vehicle debts.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/CreditCardDebt"
                  meta:
                    $ref: "#/components/schemas/PaginationMeta"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"

  /cases/{case_id}/debts/type/real-estate:
    parameters:
      - $ref: "#/components/parameters/CaseId"
    get:
      operationId: listRealEstateDebts
      tags: [Credit Cards & Debts]
      summary: List real estate debts
      description: "Returns debts filtered to real estate types: R/C, R/E, R/F, R/O, R/S, R/V, MRI, FHA, FMH, C/M, BMP, SMP, EXM, CSL, M/H, 26, 08, 19, 27, 5B, 25, 86, 05, 2C, 6B, 85, 87, 33, 0F, 17."
      parameters:
        - $ref: "#/components/parameters/Page"
        - $ref: "#/components/parameters/PerPage"
        - name: condition
          in: query
          schema:
            type: string
            enum: [DECEASED, CHARGEOFF, BANKRUPTCY, TRANSFER, REPOSSESSION, CLOSED, BANKRUPTCYPET, COLLECTIONS, DELINQUENT120, DELINQUENT90, DELINQUENT60, DELINQUENT30, REFINANCED, LOST, OPEN, PAID, UNKNOWN]
        - name: responsibility
          in: query
          schema:
            type: string
            enum: ["1", B, I, "8", C, "5", S, "2", J, "4", P, "3", A, "7", M, "0", O, U, "9", T, X]
      responses:
        "200":
          description: List of real estate debts.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/CreditCardDebt"
                  meta:
                    $ref: "#/components/schemas/PaginationMeta"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"

  /cases/{case_id}/debts/type/home-equity:
    parameters:
      - $ref: "#/components/parameters/CaseId"
    get:
      operationId: listHomeEquityDebts
      tags: [Credit Cards & Debts]
      summary: List home equity debts
      description: "Returns debts filtered to home equity types: H/E, HEI, H/I, SHI, 89, 6D, 04, 9A."
      parameters:
        - $ref: "#/components/parameters/Page"
        - $ref: "#/components/parameters/PerPage"
        - name: condition
          in: query
          schema:
            type: string
            enum: [DECEASED, CHARGEOFF, BANKRUPTCY, TRANSFER, REPOSSESSION, CLOSED, BANKRUPTCYPET, COLLECTIONS, DELINQUENT120, DELINQUENT90, DELINQUENT60, DELINQUENT30, REFINANCED, LOST, OPEN, PAID, UNKNOWN]
        - name: responsibility
          in: query
          schema:
            type: string
            enum: ["1", B, I, "8", C, "5", S, "2", J, "4", P, "3", A, "7", M, "0", O, U, "9", T, X]
      responses:
        "200":
          description: List of home equity debts.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/CreditCardDebt"
                  meta:
                    $ref: "#/components/schemas/PaginationMeta"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"

  /cases/{case_id}/debts/type/personal-loans:
    parameters:
      - $ref: "#/components/parameters/CaseId"
    get:
      operationId: listPersonalLoanDebts
      tags: [Credit Cards & Debts]
      summary: List personal loan debts
      description: "Returns debts filtered to personal loan types: I/L, NTE, NCS, SEC, UNS, P/S, ISC, 78, 20, 21, 02, 01, 03, 06."
      parameters:
        - $ref: "#/components/parameters/Page"
        - $ref: "#/components/parameters/PerPage"
        - name: condition
          in: query
          schema:
            type: string
            enum: [DECEASED, CHARGEOFF, BANKRUPTCY, TRANSFER, REPOSSESSION, CLOSED, BANKRUPTCYPET, COLLECTIONS, DELINQUENT120, DELINQUENT90, DELINQUENT60, DELINQUENT30, REFINANCED, LOST, OPEN, PAID, UNKNOWN]
        - name: responsibility
          in: query
          schema:
            type: string
            enum: ["1", B, I, "8", C, "5", S, "2", J, "4", P, "3", A, "7", M, "0", O, U, "9", T, X]
      responses:
        "200":
          description: List of personal loan debts.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/CreditCardDebt"
                  meta:
                    $ref: "#/components/schemas/PaginationMeta"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"

  /cases/{case_id}/debts/type/education:
    parameters:
      - $ref: "#/components/parameters/CaseId"
    get:
      operationId: listEducationDebts
      tags: [Credit Cards & Debts]
      summary: List education debts
      description: "Returns debts filtered to education types: EDU, 12."
      parameters:
        - $ref: "#/components/parameters/Page"
        - $ref: "#/components/parameters/PerPage"
        - name: condition
          in: query
          schema:
            type: string
            enum: [DECEASED, CHARGEOFF, BANKRUPTCY, TRANSFER, REPOSSESSION, CLOSED, BANKRUPTCYPET, COLLECTIONS, DELINQUENT120, DELINQUENT90, DELINQUENT60, DELINQUENT30, REFINANCED, LOST, OPEN, PAID, UNKNOWN]
        - name: responsibility
          in: query
          schema:
            type: string
            enum: ["1", B, I, "8", C, "5", S, "2", J, "4", P, "3", A, "7", M, "0", O, U, "9", T, X]
      responses:
        "200":
          description: List of education debts.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/CreditCardDebt"
                  meta:
                    $ref: "#/components/schemas/PaginationMeta"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"

  /cases/{case_id}/debts/type/medical:
    parameters:
      - $ref: "#/components/parameters/CaseId"
    get:
      operationId: listMedicalDebts
      tags: [Credit Cards & Debts]
      summary: List medical debts
      description: "Returns debts filtered to medical types: MED, 90."
      parameters:
        - $ref: "#/components/parameters/Page"
        - $ref: "#/components/parameters/PerPage"
        - name: condition
          in: query
          schema:
            type: string
            enum: [DECEASED, CHARGEOFF, BANKRUPTCY, TRANSFER, REPOSSESSION, CLOSED, BANKRUPTCYPET, COLLECTIONS, DELINQUENT120, DELINQUENT90, DELINQUENT60, DELINQUENT30, REFINANCED, LOST, OPEN, PAID, UNKNOWN]
        - name: responsibility
          in: query
          schema:
            type: string
            enum: ["1", B, I, "8", C, "5", S, "2", J, "4", P, "3", A, "7", M, "0", O, U, "9", T, X]
      responses:
        "200":
          description: List of medical debts.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/CreditCardDebt"
                  meta:
                    $ref: "#/components/schemas/PaginationMeta"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"

  /cases/{case_id}/debts/type/business:
    parameters:
      - $ref: "#/components/parameters/CaseId"
    get:
      operationId: listBusinessDebts
      tags: [Credit Cards & Debts]
      summary: List business debts
      description: "Returns debts filtered to business types: BUS, BCC, BPG, CIL, CLC, LBP, 10, 8A, 9B, G1, 7A, 1B."
      parameters:
        - $ref: "#/components/parameters/Page"
        - $ref: "#/components/parameters/PerPage"
        - name: condition
          in: query
          schema:
            type: string
            enum: [DECEASED, CHARGEOFF, BANKRUPTCY, TRANSFER, REPOSSESSION, CLOSED, BANKRUPTCYPET, COLLECTIONS, DELINQUENT120, DELINQUENT90, DELINQUENT60, DELINQUENT30, REFINANCED, LOST, OPEN, PAID, UNKNOWN]
        - name: responsibility
          in: query
          schema:
            type: string
            enum: ["1", B, I, "8", C, "5", S, "2", J, "4", P, "3", A, "7", M, "0", O, U, "9", T, X]
      responses:
        "200":
          description: List of business debts.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/CreditCardDebt"
                  meta:
                    $ref: "#/components/schemas/PaginationMeta"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"

  /cases/{case_id}/debts/type/government:
    parameters:
      - $ref: "#/components/parameters/CaseId"
    get:
      operationId: listGovernmentDebts
      tags: [Credit Cards & Debts]
      summary: List government debts
      description: "Returns debts filtered to government types: G/B, G/F, G/G, GEA, GFS, GMD, GOP, SDL, SGL, UDL, UGL, 75, 71, 69, 73, 72, 74, 70, 68, 66, 67, 65."
      parameters:
        - $ref: "#/components/parameters/Page"
        - $ref: "#/components/parameters/PerPage"
        - name: condition
          in: query
          schema:
            type: string
            enum: [DECEASED, CHARGEOFF, BANKRUPTCY, TRANSFER, REPOSSESSION, CLOSED, BANKRUPTCYPET, COLLECTIONS, DELINQUENT120, DELINQUENT90, DELINQUENT60, DELINQUENT30, REFINANCED, LOST, OPEN, PAID, UNKNOWN]
        - name: responsibility
          in: query
          schema:
            type: string
            enum: ["1", B, I, "8", C, "5", S, "2", J, "4", P, "3", A, "7", M, "0", O, U, "9", T, X]
      responses:
        "200":
          description: List of government debts.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/CreditCardDebt"
                  meta:
                    $ref: "#/components/schemas/PaginationMeta"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"

  /cases/{case_id}/debts/type/collections:
    parameters:
      - $ref: "#/components/parameters/CaseId"
    get:
      operationId: listCollectionsDebts
      tags: [Credit Cards & Debts]
      summary: List collections debts
      description: "Returns debts filtered to collections types: COL, 48."
      parameters:
        - $ref: "#/components/parameters/Page"
        - $ref: "#/components/parameters/PerPage"
        - name: condition
          in: query
          schema:
            type: string
            enum: [DECEASED, CHARGEOFF, BANKRUPTCY, TRANSFER, REPOSSESSION, CLOSED, BANKRUPTCYPET, COLLECTIONS, DELINQUENT120, DELINQUENT90, DELINQUENT60, DELINQUENT30, REFINANCED, LOST, OPEN, PAID, UNKNOWN]
        - name: responsibility
          in: query
          schema:
            type: string
            enum: ["1", B, I, "8", C, "5", S, "2", J, "4", P, "3", A, "7", M, "0", O, U, "9", T, X]
      responses:
        "200":
          description: List of collections debts.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/CreditCardDebt"
                  meta:
                    $ref: "#/components/schemas/PaginationMeta"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"

  /cases/{case_id}/debts/type/line-of-credit:
    parameters:
      - $ref: "#/components/parameters/CaseId"
    get:
      operationId: listLineOfCreditDebts
      tags: [Credit Cards & Debts]
      summary: List line of credit debts
      description: "Returns debts filtered to line of credit types: C/C, C/G, CGA, CCP, CLS, CKG, CSA, 15, 98, 6C, 37, 47, 96, 5C."
      parameters:
        - $ref: "#/components/parameters/Page"
        - $ref: "#/components/parameters/PerPage"
        - name: condition
          in: query
          schema:
            type: string
            enum: [DECEASED, CHARGEOFF, BANKRUPTCY, TRANSFER, REPOSSESSION, CLOSED, BANKRUPTCYPET, COLLECTIONS, DELINQUENT120, DELINQUENT90, DELINQUENT60, DELINQUENT30, REFINANCED, LOST, OPEN, PAID, UNKNOWN]
        - name: responsibility
          in: query
          schema:
            type: string
            enum: ["1", B, I, "8", C, "5", S, "2", J, "4", P, "3", A, "7", M, "0", O, U, "9", T, X]
      responses:
        "200":
          description: List of line of credit debts.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/CreditCardDebt"
                  meta:
                    $ref: "#/components/schemas/PaginationMeta"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"

  /cases/{case_id}/debts/type/banking:
    parameters:
      - $ref: "#/components/parameters/CaseId"
    get:
      operationId: listBankingDebts
      tags: [Credit Cards & Debts]
      summary: List banking debts
      description: "Returns debts filtered to banking/deposit types: DEP, D/C, RCK, 8B, 43, 77."
      parameters:
        - $ref: "#/components/parameters/Page"
        - $ref: "#/components/parameters/PerPage"
        - name: condition
          in: query
          schema:
            type: string
            enum: [DECEASED, CHARGEOFF, BANKRUPTCY, TRANSFER, REPOSSESSION, CLOSED, BANKRUPTCYPET, COLLECTIONS, DELINQUENT120, DELINQUENT90, DELINQUENT60, DELINQUENT30, REFINANCED, LOST, OPEN, PAID, UNKNOWN]
        - name: responsibility
          in: query
          schema:
            type: string
            enum: ["1", B, I, "8", C, "5", S, "2", J, "4", P, "3", A, "7", M, "0", O, U, "9", T, X]
      responses:
        "200":
          description: List of banking debts.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/CreditCardDebt"
                  meta:
                    $ref: "#/components/schemas/PaginationMeta"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"

  /cases/{case_id}/debts/type/household-goods:
    parameters:
      - $ref: "#/components/parameters/CaseId"
    get:
      operationId: listHouseholdGoodsDebts
      tags: [Credit Cards & Debts]
      summary: List household goods debts
      description: "Returns debts filtered to household goods types: H+O, HHG, PHG, REC, 23, 22, 1C, 11."
      parameters:
        - $ref: "#/components/parameters/Page"
        - $ref: "#/components/parameters/PerPage"
        - name: condition
          in: query
          schema:
            type: string
            enum: [DECEASED, CHARGEOFF, BANKRUPTCY, TRANSFER, REPOSSESSION, CLOSED, BANKRUPTCYPET, COLLECTIONS, DELINQUENT120, DELINQUENT90, DELINQUENT60, DELINQUENT30, REFINANCED, LOST, OPEN, PAID, UNKNOWN]
        - name: responsibility
          in: query
          schema:
            type: string
            enum: ["1", B, I, "8", C, "5", S, "2", J, "4", P, "3", A, "7", M, "0", O, U, "9", T, X]
      responses:
        "200":
          description: List of household goods debts.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/CreditCardDebt"
                  meta:
                    $ref: "#/components/schemas/PaginationMeta"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"

  /cases/{case_id}/debts/type/insurance:
    parameters:
      - $ref: "#/components/parameters/CaseId"
    get:
      operationId: listInsuranceDebts
      tags: [Credit Cards & Debts]
      summary: List insurance debts
      description: "Returns debts filtered to insurance types: INS, LPI, 49, 1A."
      parameters:
        - $ref: "#/components/parameters/Page"
        - $ref: "#/components/parameters/PerPage"
        - name: condition
          in: query
          schema:
            type: string
            enum: [DECEASED, CHARGEOFF, BANKRUPTCY, TRANSFER, REPOSSESSION, CLOSED, BANKRUPTCYPET, COLLECTIONS, DELINQUENT120, DELINQUENT90, DELINQUENT60, DELINQUENT30, REFINANCED, LOST, OPEN, PAID, UNKNOWN]
        - name: responsibility
          in: query
          schema:
            type: string
            enum: ["1", B, I, "8", C, "5", S, "2", J, "4", P, "3", A, "7", M, "0", O, U, "9", T, X]
      responses:
        "200":
          description: List of insurance debts.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/CreditCardDebt"
                  meta:
                    $ref: "#/components/schemas/PaginationMeta"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"

  /cases/{case_id}/debts/type/utility-service:
    parameters:
      - $ref: "#/components/parameters/CaseId"
    get:
      operationId: listUtilityServiceDebts
      tags: [Credit Cards & Debts]
      summary: List utility/service debts
      description: "Returns debts filtered to utility/service types: UTI, CEL, SAA, LEA, REN, LIC, 92, 4D, 7C, 13, 29, 3C."
      parameters:
        - $ref: "#/components/parameters/Page"
        - $ref: "#/components/parameters/PerPage"
        - name: condition
          in: query
          schema:
            type: string
            enum: [DECEASED, CHARGEOFF, BANKRUPTCY, TRANSFER, REPOSSESSION, CLOSED, BANKRUPTCYPET, COLLECTIONS, DELINQUENT120, DELINQUENT90, DELINQUENT60, DELINQUENT30, REFINANCED, LOST, OPEN, PAID, UNKNOWN]
        - name: responsibility
          in: query
          schema:
            type: string
            enum: ["1", B, I, "8", C, "5", S, "2", J, "4", P, "3", A, "7", M, "0", O, U, "9", T, X]
      responses:
        "200":
          description: List of utility/service debts.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/CreditCardDebt"
                  meta:
                    $ref: "#/components/schemas/PaginationMeta"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"

  /cases/{case_id}/debts/type/support-legal:
    parameters:
      - $ref: "#/components/parameters/CaseId"
    get:
      operationId: listSupportLegalDebts
      tags: [Credit Cards & Debts]
      summary: List support/legal debts
      description: "Returns debts filtered to support/legal types: C/S, F/S, S/S, ATY, 93, 50, 94, 95."
      parameters:
        - $ref: "#/components/parameters/Page"
        - $ref: "#/components/parameters/PerPage"
        - name: condition
          in: query
          schema:
            type: string
            enum: [DECEASED, CHARGEOFF, BANKRUPTCY, TRANSFER, REPOSSESSION, CLOSED, BANKRUPTCYPET, COLLECTIONS, DELINQUENT120, DELINQUENT90, DELINQUENT60, DELINQUENT30, REFINANCED, LOST, OPEN, PAID, UNKNOWN]
        - name: responsibility
          in: query
          schema:
            type: string
            enum: ["1", B, I, "8", C, "5", S, "2", J, "4", P, "3", A, "7", M, "0", O, U, "9", T, X]
      responses:
        "200":
          description: List of support/legal debts.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/CreditCardDebt"
                  meta:
                    $ref: "#/components/schemas/PaginationMeta"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"

  /cases/{case_id}/debts/type/cosigned:
    parameters:
      - $ref: "#/components/parameters/CaseId"
    get:
      operationId: listCosignedDebts
      tags: [Credit Cards & Debts]
      summary: List cosigned debts
      description: "Returns debts filtered to cosigned types: COS, F/C, SC0, NCS, 14, 16, 09, 21."
      parameters:
        - $ref: "#/components/parameters/Page"
        - $ref: "#/components/parameters/PerPage"
        - name: condition
          in: query
          schema:
            type: string
            enum: [DECEASED, CHARGEOFF, BANKRUPTCY, TRANSFER, REPOSSESSION, CLOSED, BANKRUPTCYPET, COLLECTIONS, DELINQUENT120, DELINQUENT90, DELINQUENT60, DELINQUENT30, REFINANCED, LOST, OPEN, PAID, UNKNOWN]
        - name: responsibility
          in: query
          schema:
            type: string
            enum: ["1", B, I, "8", C, "5", S, "2", J, "4", P, "3", A, "7", M, "0", O, U, "9", T, X]
      responses:
        "200":
          description: List of cosigned debts.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/CreditCardDebt"
                  meta:
                    $ref: "#/components/schemas/PaginationMeta"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"

  /cases/{case_id}/debts/type/other:
    parameters:
      - $ref: "#/components/parameters/CaseId"
    get:
      operationId: listOtherDebts
      tags: [Credit Cards & Debts]
      summary: List other/miscellaneous debts
      description: "Returns debts filtered to other/miscellaneous types: AGR, CON, DCS, FCO, PPI, SUM, TSL, UNK, ZZZ, 7B, 91, 34, 0C, 83, 30, 0A, 31, ZZ."
      parameters:
        - $ref: "#/components/parameters/Page"
        - $ref: "#/components/parameters/PerPage"
        - name: condition
          in: query
          schema:
            type: string
            enum: [DECEASED, CHARGEOFF, BANKRUPTCY, TRANSFER, REPOSSESSION, CLOSED, BANKRUPTCYPET, COLLECTIONS, DELINQUENT120, DELINQUENT90, DELINQUENT60, DELINQUENT30, REFINANCED, LOST, OPEN, PAID, UNKNOWN]
        - name: responsibility
          in: query
          schema:
            type: string
            enum: ["1", B, I, "8", C, "5", S, "2", J, "4", P, "3", A, "7", M, "0", O, U, "9", T, X]
      responses:
        "200":
          description: List of other/miscellaneous debts.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/CreditCardDebt"
                  meta:
                    $ref: "#/components/schemas/PaginationMeta"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"

  # ==================== RETIREMENT ACCOUNTS ====================
  /cases/{case_id}/retirement-accounts:
    parameters:
      - $ref: "#/components/parameters/CaseId"
    get:
      operationId: listRetirementAccounts
      tags: [Retirement Accounts]
      summary: List retirement accounts
      parameters:
        - $ref: "#/components/parameters/Page"
        - $ref: "#/components/parameters/PerPage"
        - name: account_type
          in: query
          schema:
            type: string
            enum: [traditional_ira, roth_ira, "401k", "403b", "457", sep_ira, simple_ira, keogh, pension, tsp, military_pension, fegli, inherited_ira, other]
        - name: distribution_status
          in: query
          schema:
            type: string
            enum: [not_started, in_progress, completed, pending_beneficiary_docs]
      responses:
        "200":
          description: List of retirement accounts.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/RetirementAccount"
                  meta:
                    $ref: "#/components/schemas/PaginationMeta"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
  /cases/{case_id}/retirement-accounts/{account_id}:
    parameters:
      - $ref: "#/components/parameters/CaseId"
      - name: account_id
        in: path
        required: true
        schema:
          type: string
    get:
      operationId: getRetirementAccount
      tags: [Retirement Accounts]
      summary: Get retirement account details
      responses:
        "200":
          description: Account details.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: "#/components/schemas/RetirementAccount"
        "404":
          $ref: "#/components/responses/NotFound"
    patch:
      operationId: updateRetirementAccount
      tags: [Retirement Accounts]
      summary: Update retirement account
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/RetirementAccountWrite"
      responses:
        "200":
          description: Account updated.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: "#/components/schemas/RetirementAccount"
        "404":
          $ref: "#/components/responses/NotFound"
        "422":
          $ref: "#/components/responses/ValidationError"

  # ==================== INVESTMENT ACCOUNTS ====================
  /cases/{case_id}/investment-accounts:
    parameters:
      - $ref: "#/components/parameters/CaseId"
    get:
      operationId: listInvestmentAccounts
      tags: [Investment Accounts]
      summary: List investment accounts
      parameters:
        - $ref: "#/components/parameters/Page"
        - $ref: "#/components/parameters/PerPage"
        - name: account_type
          in: query
          schema:
            type: string
            enum: [brokerage, mutual_fund, etf, individual_stocks, individual_bonds, index_fund, managed_account, "529_plan", drip, private_equity, alternative_investment, hsa, msa, cryptocurrency, other]
        - name: transfer_status
          in: query
          schema:
            type: string
            enum: [not_started, paperwork_submitted, in_review, transferred, liquidated]
      responses:
        "200":
          description: List of investment accounts.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/InvestmentAccount"
                  meta:
                    $ref: "#/components/schemas/PaginationMeta"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
  /cases/{case_id}/investment-accounts/{account_id}:
    parameters:
      - $ref: "#/components/parameters/CaseId"
      - name: account_id
        in: path
        required: true
        schema:
          type: string
    get:
      operationId: getInvestmentAccount
      tags: [Investment Accounts]
      summary: Get investment account details
      responses:
        "200":
          description: Account details.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: "#/components/schemas/InvestmentAccount"
        "404":
          $ref: "#/components/responses/NotFound"
    patch:
      operationId: updateInvestmentAccount
      tags: [Investment Accounts]
      summary: Update investment account
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/InvestmentAccountWrite"
      responses:
        "200":
          description: Account updated.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: "#/components/schemas/InvestmentAccount"
        "404":
          $ref: "#/components/responses/NotFound"
        "422":
          $ref: "#/components/responses/ValidationError"

  # ==================== REAL ESTATE PROPERTIES ====================
  /cases/{case_id}/properties:
    parameters:
      - $ref: "#/components/parameters/CaseId"
    get:
      operationId: listProperties
      tags: [Real Estate Properties]
      summary: List properties
      parameters:
        - $ref: "#/components/parameters/Page"
        - $ref: "#/components/parameters/PerPage"
        - name: property_type
          in: query
          schema:
            type: string
            enum: [primary_residence, vacation_home, investment_property, rental_property, vacant_land, commercial, farm_ranch, mixed_use, other]
        - name: status
          in: query
          schema:
            type: string
            enum: [owned, pending_transfer, listed_for_sale, sold, transferred, in_probate, unknown]
      responses:
        "200":
          description: List of properties.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/RealEstateProperty"
                  meta:
                    $ref: "#/components/schemas/PaginationMeta"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"

  /cases/{case_id}/properties/{property_id}:
    parameters:
      - $ref: "#/components/parameters/CaseId"
      - name: property_id
        in: path
        required: true
        schema:
          type: string
    get:
      operationId: getProperty
      tags: [Real Estate Properties]
      summary: Get property details
      responses:
        "200":
          description: Property details.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: "#/components/schemas/RealEstateProperty"
        "404":
          $ref: "#/components/responses/NotFound"
    patch:
      operationId: updateProperty
      tags: [Real Estate Properties]
      summary: Update property
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/RealEstatePropertyWrite"
      responses:
        "200":
          description: Property updated.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: "#/components/schemas/RealEstateProperty"
        "404":
          $ref: "#/components/responses/NotFound"
        "422":
          $ref: "#/components/responses/ValidationError"

  # ==================== UNCLAIMED PROPERTY ====================
  /cases/{case_id}/unclaimed-property:
    parameters:
      - $ref: "#/components/parameters/CaseId"
    get:
      operationId: listUnclaimedProperty
      tags: [Unclaimed Property]
      summary: List unclaimed property
      parameters:
        - $ref: "#/components/parameters/Page"
        - $ref: "#/components/parameters/PerPage"
        - name: state
          in: query
          schema:
            type: string
        - name: claim_status
          in: query
          schema:
            type: string
            enum: [discovered, claim_filed, under_review, approved, paid, denied, expired]
      responses:
        "200":
          description: List of unclaimed property.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/UnclaimedProperty"
                  meta:
                    $ref: "#/components/schemas/PaginationMeta"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"

  /cases/{case_id}/unclaimed-property/{property_id}:
    parameters:
      - $ref: "#/components/parameters/CaseId"
      - name: property_id
        in: path
        required: true
        schema:
          type: string
    get:
      operationId: getUnclaimedProperty
      tags: [Unclaimed Property]
      summary: Get unclaimed property details
      responses:
        "200":
          description: Property details.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: "#/components/schemas/UnclaimedProperty"
        "404":
          $ref: "#/components/responses/NotFound"
    patch:
      operationId: updateUnclaimedProperty
      tags: [Unclaimed Property]
      summary: Update unclaimed property
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/UnclaimedPropertyWrite"
      responses:
        "200":
          description: Record updated.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: "#/components/schemas/UnclaimedProperty"
        "404":
          $ref: "#/components/responses/NotFound"
        "422":
          $ref: "#/components/responses/ValidationError"

  # ==================== VEHICLES ====================
  /cases/{case_id}/vehicles:
    parameters:
      - $ref: "#/components/parameters/CaseId"
    get:
      operationId: listVehicles
      tags: [Vehicles]
      summary: List vehicles
      parameters:
        - $ref: "#/components/parameters/Page"
        - $ref: "#/components/parameters/PerPage"
        - name: vehicle_type
          in: query
          schema:
            type: string
            enum: [automobile, motorcycle, recreational_vehicle, boat, commercial_vehicle, classic_car, trailer, off_highway_vehicle, farm_equipment, aircraft, other]
        - name: disposition
          in: query
          schema:
            type: string
            enum: [keep, transfer_to_heir, sell, donate, junk, pending_decision]
      responses:
        "200":
          description: List of vehicles.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/Vehicle"
                  meta:
                    $ref: "#/components/schemas/PaginationMeta"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"

  /cases/{case_id}/vehicles/{vehicle_id}:
    parameters:
      - $ref: "#/components/parameters/CaseId"
      - name: vehicle_id
        in: path
        required: true
        schema:
          type: string
    get:
      operationId: getVehicle
      tags: [Vehicles]
      summary: Get vehicle details
      responses:
        "200":
          description: Vehicle details.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: "#/components/schemas/Vehicle"
        "404":
          $ref: "#/components/responses/NotFound"
    patch:
      operationId: updateVehicle
      tags: [Vehicles]
      summary: Update vehicle
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/VehicleWrite"
      responses:
        "200":
          description: Vehicle updated.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: "#/components/schemas/Vehicle"
        "404":
          $ref: "#/components/responses/NotFound"
        "422":
          $ref: "#/components/responses/ValidationError"

  # ==================== BUSINESS OWNERSHIP ====================
  /cases/{case_id}/businesses:
    parameters:
      - $ref: "#/components/parameters/CaseId"
    get:
      operationId: listBusinesses
      tags: [Business Ownership]
      summary: List businesses
      parameters:
        - $ref: "#/components/parameters/Page"
        - $ref: "#/components/parameters/PerPage"
        - name: entity_type
          in: query
          schema:
            type: string
            enum: [c_corp, s_corp, llc, general_partnership, limited_partnership, sole_proprietorship, dba_trade_name, franchise, professional_license, nonprofit, other]
        - name: status
          in: query
          schema:
            type: string
            enum: [active, inactive, dissolved, merged, suspended, unknown]
      responses:
        "200":
          description: List of businesses.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/BusinessOwnership"
                  meta:
                    $ref: "#/components/schemas/PaginationMeta"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"

  /cases/{case_id}/businesses/{business_id}:
    parameters:
      - $ref: "#/components/parameters/CaseId"
      - name: business_id
        in: path
        required: true
        schema:
          type: string
    get:
      operationId: getBusiness
      tags: [Business Ownership]
      summary: Get business details
      responses:
        "200":
          description: Business details.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: "#/components/schemas/BusinessOwnership"
        "404":
          $ref: "#/components/responses/NotFound"
    patch:
      operationId: updateBusiness
      tags: [Business Ownership]
      summary: Update business
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/BusinessOwnershipWrite"
      responses:
        "200":
          description: Business updated.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: "#/components/schemas/BusinessOwnership"
        "404":
          $ref: "#/components/responses/NotFound"
        "422":
          $ref: "#/components/responses/ValidationError"
