{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/abmeter-ai/json-schema/abmeter-ai-event-type-schema.json",
  "title": "EventType",
  "description": "Defines a category of events that can be tracked, with optional custom fields for additional data",
  "x-generated": "2026-10-31",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/abmeter-ai-openapi.yml#/components/schemas/EventType",
  "type": "object",
  "properties": {
    "slug": {
      "$ref": "#/$defs/Slug"
    },
    "description": {
      "type": [
        "string",
        "null"
      ],
      "description": "Optional description of the event type"
    },
    "custom_fields": {
      "type": "object",
      "additionalProperties": {
        "type": "string",
        "enum": [
          "String",
          "Boolean",
          "Integer",
          "Float"
        ]
      },
      "description": "Custom field definitions with their data types"
    },
    "measures": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/Measure"
      },
      "readOnly": true,
      "description": "Available measures derived from this event type (auto-generated based on custom fields)"
    },
    "created_at": {
      "type": "string",
      "format": "date-time",
      "readOnly": true
    },
    "updated_at": {
      "type": "string",
      "format": "date-time",
      "readOnly": true
    }
  },
  "required": [
    "slug"
  ],
  "$defs": {
    "Measure": {
      "type": "object",
      "description": "Atomic aggregation derived from an event type. Measures are automatically generated based on event type custom fields.",
      "properties": {
        "event_type_slug": {
          "$ref": "#/$defs/Slug"
        },
        "measure_method": {
          "type": "string",
          "enum": [
            "count",
            "count_distinct",
            "count_null",
            "min",
            "max",
            "avg",
            "sum"
          ],
          "description": "How to aggregate the data"
        },
        "custom_field_name": {
          "type": [
            "string",
            "null"
          ],
          "description": "Custom field to measure (null for event-level measures like count)"
        },
        "display_name": {
          "type": "string",
          "readOnly": true,
          "description": "Human-readable measure name (e.g., \"count(purchase)\", \"sum(purchase.amount)\")"
        }
      },
      "required": [
        "event_type_slug",
        "measure_method"
      ]
    },
    "Slug": {
      "type": "string",
      "description": "Standardized identifier for entities used across the API. Recommended format: each entity type has its own prefix pattern followed by a short alphanumeric identifier (e.g., parameter-ab4c, space-main, audience-control)."
    }
  }
}