{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/logbrew/json-schema/logbrew-sdk-product-analytics-retention-request-schema.json",
  "title": "SdkProductAnalyticsRetentionRequest",
  "description": "Bounded retention request for one owned project.",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/logbrew-product-analytics-api-openapi.yml#/components/schemas/SdkProductAnalyticsRetentionRequest",
  "additionalProperties": false,
  "properties": {
    "cohort_mode": {
      "anyOf": [
        {
          "$ref": "#/$defs/SdkProductAnalyticsRetentionCohortMode"
        },
        {
          "type": "null"
        }
      ],
      "description": "Anchor mode; version 1 supports first-in-range cohorts only."
    },
    "environment": {
      "description": "Optional exact environment filter.",
      "type": [
        "string",
        "null"
      ]
    },
    "interval": {
      "anyOf": [
        {
          "$ref": "#/$defs/SdkProductAnalyticsFixedInterval"
        },
        {
          "type": "null"
        }
      ],
      "description": "Fixed retention period width; defaults according to the selected query range."
    },
    "interval_count": {
      "description": "Number of zero-based periods to evaluate; defaults to ten.",
      "format": "uint8",
      "maximum": 255,
      "minimum": 0,
      "type": [
        "integer",
        "null"
      ]
    },
    "mode": {
      "anyOf": [
        {
          "$ref": "#/$defs/SdkProductAnalyticsRetentionMode"
        },
        {
          "type": "null"
        }
      ],
      "description": "Exact-period or rolling retention; defaults to exact-period retention."
    },
    "project_id": {
      "description": "Required project scope, optional only for actionable validation.",
      "format": "uuid",
      "type": "string"
    },
    "release": {
      "description": "Optional exact release filter.",
      "type": [
        "string",
        "null"
      ]
    },
    "response_version": {
      "description": "Optional response schema; version 2 enables automatic classified-activity analysis, and\nversion 3 adds previous-period change and example users with or without exact selectors.",
      "format": "uint8",
      "maximum": 255,
      "minimum": 0,
      "type": [
        "integer",
        "null"
      ]
    },
    "return_event": {
      "anyOf": [
        {
          "$ref": "#/$defs/SdkProductAnalyticsEventRequest"
        },
        {
          "type": "null"
        }
      ],
      "description": "Exact event that qualifies a return after the anchor."
    },
    "service_name": {
      "description": "Optional exact service filter.",
      "type": [
        "string",
        "null"
      ]
    },
    "since": {
      "description": "Required inclusive lower bound, as a duration or RFC 3339 timestamp.",
      "type": "string"
    },
    "start_event": {
      "anyOf": [
        {
          "$ref": "#/$defs/SdkProductAnalyticsEventRequest"
        },
        {
          "type": "null"
        }
      ],
      "description": "Exact event that anchors each subject."
    },
    "until": {
      "description": "Optional exclusive RFC 3339 upper bound; defaults to request time.",
      "type": [
        "string",
        "null"
      ]
    }
  },
  "required": [
    "project_id",
    "since"
  ],
  "type": "object",
  "$defs": {
    "SdkProductAnalyticsEventKind": {
      "description": "Supported version-1 classified product-event kind.",
      "oneOf": [
        {
          "const": "page_view",
          "description": "Browser route view.",
          "type": "string"
        },
        {
          "const": "screen_view",
          "description": "Application-owned screen view.",
          "type": "string"
        },
        {
          "const": "interaction",
          "description": "Explicit application product action.",
          "type": "string"
        }
      ]
    },
    "SdkProductAnalyticsEventRequest": {
      "additionalProperties": false,
      "description": "One exact classified product-event selector.",
      "properties": {
        "event_name": {
          "description": "Stable route template, screen name, or bounded action name.",
          "type": "string"
        },
        "kind": {
          "$ref": "#/$defs/SdkProductAnalyticsEventKind",
          "description": "Supported classified event kind."
        }
      },
      "required": [
        "kind",
        "event_name"
      ],
      "type": "object"
    },
    "SdkProductAnalyticsFixedInterval": {
      "description": "Fixed product-analytics period width.",
      "oneOf": [
        {
          "const": "hour",
          "description": "One hour.",
          "type": "string"
        },
        {
          "const": "day",
          "description": "One fixed 24-hour day.",
          "type": "string"
        },
        {
          "const": "week",
          "description": "One fixed seven-day week.",
          "type": "string"
        },
        {
          "const": "thirty_day",
          "description": "One fixed 30-day period; this is not a calendar month.",
          "type": "string"
        }
      ]
    },
    "SdkProductAnalyticsRetentionCohortMode": {
      "description": "How each subject receives a cohort anchor.",
      "oneOf": [
        {
          "const": "first_in_range",
          "description": "Use the subject's first matching start event inside the selected query range.",
          "type": "string"
        }
      ]
    },
    "SdkProductAnalyticsRetentionMode": {
      "description": "How a return qualifies for each requested period.",
      "oneOf": [
        {
          "const": "return_on",
          "description": "Return inside that exact subject-relative period.",
          "type": "string"
        },
        {
          "const": "return_on_or_after",
          "description": "Return at or after that period's subject-relative threshold.",
          "type": "string"
        }
      ]
    }
  }
}