{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/latitude-so/json-schema/latitude-so-saved-search-schema.json",
  "title": "SavedSearch",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/latitude-so-saved-searches-api-openapi.yml#/components/schemas/SavedSearch",
  "type": "object",
  "properties": {
    "id": {
      "type": "string",
      "minLength": 24,
      "maxLength": 24,
      "description": "Stable saved-search identifier."
    },
    "organizationId": {
      "type": "string",
      "minLength": 24,
      "maxLength": 24,
      "description": "Organization that owns this saved search."
    },
    "projectId": {
      "type": "string",
      "minLength": 24,
      "maxLength": 24,
      "description": "Project this saved search belongs to."
    },
    "slug": {
      "type": "string",
      "description": "URL-safe slug derived from `name`. Regenerated when the name changes in a way that affects the slug."
    },
    "name": {
      "type": "string",
      "description": "Human-readable name."
    },
    "query": {
      "type": [
        "string",
        "null"
      ],
      "description": "Free-text semantic query applied alongside `filters`. `null` when the search is filter-only. At least one of `query` or `filters` must be set."
    },
    "filters": {
      "allOf": [
        {
          "$ref": "#/$defs/FilterSet"
        },
        {
          "description": "Structured filter set applied alongside `query`. Empty object means filter-free. At least one of `query` or `filters` must be set."
        }
      ]
    },
    "deletedAt": {
      "type": [
        "string",
        "null"
      ],
      "description": "ISO-8601 timestamp at which the search was deleted. `null` while active."
    },
    "createdAt": {
      "type": "string",
      "description": "ISO-8601 timestamp of creation."
    },
    "updatedAt": {
      "type": "string",
      "description": "ISO-8601 timestamp of the last update."
    }
  },
  "required": [
    "id",
    "organizationId",
    "projectId",
    "slug",
    "name",
    "query",
    "filters",
    "deletedAt",
    "createdAt",
    "updatedAt"
  ],
  "$defs": {
    "FilterCondition": {
      "type": "object",
      "properties": {
        "op": {
          "type": "string",
          "enum": [
            "eq",
            "neq",
            "gt",
            "gte",
            "lt",
            "lte",
            "in",
            "notIn",
            "contains",
            "notContains",
            "gtePercentile"
          ],
          "description": "Comparison operator applied to the field's value (e.g. `eq`, `neq`, `in`). The full operator list lives in the API reference."
        },
        "value": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "number"
            },
            {
              "type": "boolean"
            },
            {
              "type": "array",
              "items": {
                "anyOf": [
                  {
                    "type": "string"
                  },
                  {
                    "type": "number"
                  }
                ]
              }
            }
          ],
          "description": "Right-hand value compared against the field. Arrays are required for `in` / `notIn`-style operators."
        }
      },
      "required": [
        "op",
        "value"
      ]
    },
    "FilterSet": {
      "type": "object",
      "additionalProperties": {
        "type": "array",
        "items": {
          "$ref": "#/$defs/FilterCondition"
        }
      },
      "description": "Filter set keyed by field name. Each entry holds an array of conditions ANDed together for that field; field-level groups are also ANDed across the set."
    }
  }
}