{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://raw.githubusercontent.com/api-evangelist/okareo/main/json-schema/okareo-datapoint-filter-item-schema.json",
  "title": "DatapointFilterItem",
  "x-generated": "2026-10-18",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/okareo-openapi.json#/components/schemas/DatapointFilterItem",
  "properties": {
    "filters": {
      "items": {
        "$ref": "#/$defs/FilterCondition"
      },
      "type": "array",
      "title": "Filters",
      "description": "List of filter conditions to apply"
    },
    "name": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Name",
      "description": "Optional name describing this filter"
    },
    "description": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Description",
      "description": "Optional description for this filter"
    },
    "checks": {
      "anyOf": [
        {
          "items": {
            "type": "string"
          },
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "title": "Checks",
      "description": "Checks to apply to datapoints in the filter."
    },
    "project_id": {
      "anyOf": [
        {
          "type": "string",
          "format": "uuid"
        },
        {
          "type": "null"
        }
      ],
      "title": "Project Id",
      "description": "Project ID these filters belong to"
    },
    "filter_group_id": {
      "anyOf": [
        {
          "type": "string",
          "format": "uuid"
        },
        {
          "type": "null"
        }
      ],
      "title": "Filter Group Id",
      "description": "Group ID for filter"
    },
    "latest_test_run": {
      "anyOf": [
        {
          "additionalProperties": true,
          "type": "object"
        },
        {
          "type": "null"
        }
      ],
      "title": "Latest Test Run",
      "description": "Group ID for filter"
    },
    "datapoint_count": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "title": "Datapoint Count",
      "description": "Group ID for filter"
    },
    "issue_count": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "title": "Issue Count",
      "description": "Count of issues for this filter"
    },
    "error_count": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "title": "Error Count",
      "description": "Count of errors for this filter"
    },
    "average_metrics": {
      "anyOf": [
        {
          "additionalProperties": {
            "type": "number"
          },
          "type": "object"
        },
        {
          "type": "null"
        }
      ],
      "title": "Average Metrics",
      "description": "Metrics for checks in this filter"
    },
    "failed_checks": {
      "items": {
        "type": "string"
      },
      "type": "array",
      "title": "Failed Checks",
      "description": "Array of failed check names"
    },
    "avg_latency": {
      "anyOf": [
        {
          "type": "number"
        },
        {
          "type": "null"
        }
      ],
      "title": "Avg Latency",
      "description": "Average latency for completions"
    },
    "total_cost": {
      "anyOf": [
        {
          "type": "number"
        },
        {
          "type": "null"
        }
      ],
      "title": "Total Cost",
      "description": "Total dollar cost of all completions"
    },
    "avg_num_turns": {
      "anyOf": [
        {
          "type": "number"
        },
        {
          "type": "null"
        }
      ],
      "title": "Avg Num Turns",
      "description": "Average number of turns for completions"
    },
    "slack_enabled": {
      "anyOf": [
        {
          "type": "boolean"
        },
        {
          "type": "null"
        }
      ],
      "title": "Slack Enabled",
      "description": "Whether Slack notifications are enabled for this filter group"
    },
    "email_enabled": {
      "anyOf": [
        {
          "type": "boolean"
        },
        {
          "type": "null"
        }
      ],
      "title": "Email Enabled",
      "description": "Whether Email notifications are enabled for this filter group"
    },
    "time_created": {
      "anyOf": [
        {
          "type": "string",
          "format": "date-time"
        },
        {
          "type": "null"
        }
      ],
      "title": "Time Created",
      "description": "Created datetime for this filter group"
    },
    "time_updated": {
      "anyOf": [
        {
          "type": "string",
          "format": "date-time"
        },
        {
          "type": "null"
        }
      ],
      "title": "Time Updated",
      "description": "Last updated datetime for this filter group"
    }
  },
  "type": "object",
  "required": [
    "filters"
  ],
  "$defs": {
    "ComparisonOperator": {
      "type": "string",
      "enum": [
        "equal",
        "not_equal",
        "contains",
        "not_contains",
        "greater_than",
        "greater_than_or_equal",
        "less_than",
        "less_than_or_equal",
        "is_set",
        "not_set"
      ],
      "title": "ComparisonOperator"
    },
    "DatapointField": {
      "type": "string",
      "enum": [
        "id",
        "input",
        "input_datetime",
        "result",
        "result_datetime",
        "feedback",
        "error_message",
        "error_code",
        "error_type",
        "context_token",
        "time_created",
        "model_metadata",
        "latency",
        "input_tokens",
        "output_tokens",
        "source",
        "temperature",
        "provider",
        "request_model_name",
        "response_model_name",
        "tags",
        "cost",
        "input_tools",
        "result_tool_calls",
        "test_run_id",
        "test_data_point_id",
        "user_metadata",
        "issue_type"
      ],
      "title": "DatapointField"
    },
    "FilterCondition": {
      "properties": {
        "field": {
          "$ref": "#/$defs/DatapointField",
          "description": "Field to filter on"
        },
        "field_key": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Field Key",
          "description": "Key of the User Metadata field to filter on. Ignored for other 'field' values"
        },
        "operator": {
          "$ref": "#/$defs/ComparisonOperator",
          "description": "Comparison operator to use"
        },
        "value": {
          "type": "string",
          "title": "Value",
          "description": "Value to compare against"
        }
      },
      "type": "object",
      "required": [
        "field",
        "operator",
        "value"
      ],
      "title": "FilterCondition"
    }
  }
}