{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/latitude-so/json-schema/latitude-so-experiment-schema.json",
  "title": "Experiment",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/latitude-so-experiments-api-openapi.yml#/components/schemas/Experiment",
  "type": "object",
  "properties": {
    "id": {
      "type": "string",
      "minLength": 24,
      "maxLength": 24,
      "description": "Stable experiment identifier."
    },
    "organizationId": {
      "type": "string",
      "minLength": 24,
      "maxLength": 24,
      "description": "Organization that owns this experiment."
    },
    "projectId": {
      "type": "string",
      "minLength": 24,
      "maxLength": 24,
      "description": "Project this experiment belongs to."
    },
    "slug": {
      "type": "string",
      "description": "URL-safe slug derived from `name`. Unique within the project."
    },
    "name": {
      "type": "string",
      "description": "Human-readable name."
    },
    "description": {
      "type": "string",
      "description": "Free-form description. Empty string when not set."
    },
    "variants": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/ExperimentVariant"
      },
      "description": "Ordered variants. Exactly one carries the baseline flag when the list is non-empty."
    },
    "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",
    "description",
    "variants",
    "createdAt",
    "updatedAt"
  ],
  "$defs": {
    "AbsoluteVariantTimeRange": {
      "type": "object",
      "properties": {
        "type": {
          "type": "string",
          "enum": [
            "absolute"
          ],
          "description": "A fixed window between two instants."
        },
        "fromIso": {
          "type": "string",
          "description": "ISO-8601 start of the window (inclusive)."
        },
        "toIso": {
          "type": "string",
          "description": "ISO-8601 end of the window (inclusive)."
        }
      },
      "required": [
        "type",
        "fromIso",
        "toIso"
      ]
    },
    "ExperimentVariant": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "minLength": 24,
          "maxLength": 24,
          "description": "Stable variant identifier, unique within the experiment."
        },
        "name": {
          "type": "string",
          "description": "Human-readable variant name (e.g. \"Variant A\"). Unique within the experiment."
        },
        "baseline": {
          "type": "boolean",
          "description": "`true` for the single baseline variant that every other variant is compared against."
        },
        "filterSet": {
          "allOf": [
            {
              "$ref": "#/$defs/FilterSet"
            },
            {
              "description": "Session filters selecting this variant's population."
            }
          ]
        },
        "query": {
          "type": [
            "string",
            "null"
          ],
          "description": "Free-text / semantic search applied to the population, or `null`."
        },
        "timeRange": {
          "$ref": "#/$defs/VariantTimeRange"
        }
      },
      "required": [
        "id",
        "name",
        "baseline",
        "filterSet",
        "query",
        "timeRange"
      ]
    },
    "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."
    },
    "RelativeVariantTimeRange": {
      "type": "object",
      "properties": {
        "type": {
          "type": "string",
          "enum": [
            "relative"
          ],
          "description": "A live window ending now, spanning the last `seconds`."
        },
        "seconds": {
          "type": "integer",
          "minimum": 0,
          "exclusiveMinimum": true,
          "description": "Length of the live window in seconds (e.g. 2592000 for the last 30 days)."
        }
      },
      "required": [
        "type",
        "seconds"
      ]
    },
    "VariantTimeRange": {
      "oneOf": [
        {
          "$ref": "#/$defs/RelativeVariantTimeRange"
        },
        {
          "$ref": "#/$defs/AbsoluteVariantTimeRange"
        },
        {
          "nullable": true
        }
      ],
      "description": "Time window the variant is measured over. `null` uses the default last-30-days window."
    }
  }
}