{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/cubi-estate/json-schema/cubi-estate-agent-alert-subscribe-request-schema.json",
  "title": "AgentAlertSubscribeRequest",
  "x-generated": "2026-11-04",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/cubi-estate-openapi.yml#/components/schemas/AgentAlertSubscribeRequest",
  "properties": {
    "email": {
      "type": "string",
      "title": "Email",
      "description": "Delivery address (the CTA is opt-in — pressing it IS consent)."
    },
    "query": {
      "type": "string",
      "maxLength": 500,
      "minLength": 2,
      "title": "Query",
      "description": "The search that returned zero results, re-run when new listings land."
    },
    "extracted_filter": {
      "anyOf": [
        {
          "additionalProperties": true,
          "type": "object"
        },
        {
          "type": "null"
        }
      ],
      "title": "Extracted Filter",
      "description": "Structured PropertyFilter captured at zero-result time; the notifier re-runs it verbatim."
    },
    "lang": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Lang",
      "description": "ISO 639-1 language for the notification email.",
      "default": "en"
    },
    "user_id": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "User Id",
      "description": "Web identity: raw Supabase/anon UUID."
    },
    "user_uuid": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "User Uuid",
      "description": "Web identity alias (takes precedence over user_id)."
    },
    "channel": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Channel",
      "description": "'web' | 'telegram' | 'whatsapp'. Defaults to 'web'.",
      "default": "web"
    },
    "chat_id": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "title": "Chat Id",
      "description": "Chat id — required for telegram/whatsapp (derives UUIDv5)."
    },
    "baseline": {
      "type": "boolean",
      "title": "Baseline",
      "description": "§42 save-search: TRUE when saving a SUCCESSFUL search the user already saw. Marks the current matches as seen so only NEW inventory ever emails (never re-emails what they just viewed). Omit/false for a zero-result save (first run should email).",
      "default": false
    },
    "consent_text": {
      "anyOf": [
        {
          "type": "string",
          "maxLength": 1000
        },
        {
          "type": "null"
        }
      ],
      "title": "Consent Text",
      "description": "§55c: the EXACT visible consent wording, in the user's locale (Art 7 demonstrability — mirror the newsletter path). Omitted → the row's wording stays unrecorded/unchanged."
    },
    "consent_version": {
      "anyOf": [
        {
          "type": "string",
          "maxLength": 60
        },
        {
          "type": "null"
        }
      ],
      "title": "Consent Version",
      "description": "Version tag of the consent copy (bump when the wording changes materially)."
    }
  },
  "type": "object",
  "required": [
    "email",
    "query"
  ]
}