{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/agentanalytics-sh/json-schema/agentanalytics-sh-funnel-request-schema.json",
  "title": "FunnelRequest",
  "x-generated": "2026-11-01",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/_original/agentanalytics-sh-api-openapi.yml#/components/schemas/FunnelRequest",
  "type": "object",
  "required": [
    "project",
    "steps"
  ],
  "properties": {
    "project": {
      "type": "string",
      "description": "Project name"
    },
    "steps": {
      "type": "array",
      "description": "Funnel steps (2-8). Each step has an event name and optional property filters.",
      "minItems": 2,
      "maxItems": 8,
      "items": {
        "type": "object",
        "required": [
          "event"
        ],
        "properties": {
          "event": {
            "type": "string",
            "description": "Event name for this step"
          },
          "filters": {
            "type": "array",
            "description": "Optional property filters for this step",
            "items": {
              "type": "object",
              "required": [
                "property",
                "op",
                "value"
              ],
              "properties": {
                "property": {
                  "type": "string",
                  "description": "Property key (alphanumeric + underscores, max 128 chars)"
                },
                "op": {
                  "type": "string",
                  "enum": [
                    "eq",
                    "neq",
                    "contains"
                  ],
                  "description": "Filter operator"
                },
                "value": {
                  "type": "string",
                  "description": "Filter value"
                }
              }
            }
          }
        }
      }
    },
    "conversion_window_hours": {
      "type": "number",
      "description": "Max hours from step 1 entry to final step (1-8760, default 168 = 7 days)",
      "default": 168,
      "minimum": 1,
      "maximum": 8760
    },
    "since": {
      "type": "string",
      "description": "Lookback period (ISO date or shorthand like '30d'). Default: 30d",
      "default": "30d"
    },
    "count_by": {
      "type": "string",
      "enum": [
        "user_id",
        "session_id"
      ],
      "default": "user_id",
      "description": "Count by unique users or sessions"
    },
    "breakdown": {
      "type": "string",
      "description": "Optional property key to segment funnel by (e.g. 'variant', 'country'). Extracted from step 1 events only."
    },
    "breakdown_limit": {
      "type": "number",
      "description": "Max breakdown groups, ordered by step 1 users descending (1-50, default 10)",
      "default": 10,
      "minimum": 1,
      "maximum": 50
    }
  }
}