{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://raw.githubusercontent.com/api-evangelist/honeycomb/main/json-schema/honeycomb-trigger-create-request-schema.json",
  "title": "TriggerCreateRequest",
  "x-generated": "2026-10-03",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/honeycomb-triggers-api-openapi.yml#/components/schemas/TriggerCreateRequest",
  "type": "object",
  "required": [
    "name",
    "query",
    "threshold",
    "recipients"
  ],
  "properties": {
    "name": {
      "type": "string",
      "description": "The display name for the trigger."
    },
    "description": {
      "type": "string",
      "description": "An optional description for the trigger."
    },
    "disabled": {
      "type": "boolean",
      "description": "Whether the trigger should be disabled upon creation."
    },
    "query": {
      "$ref": "#/$defs/QuerySpec"
    },
    "threshold": {
      "type": "object",
      "required": [
        "op",
        "value"
      ],
      "properties": {
        "op": {
          "type": "string",
          "enum": [
            ">",
            ">=",
            "<",
            "<="
          ]
        },
        "value": {
          "type": "number"
        }
      }
    },
    "frequency": {
      "type": "integer",
      "description": "How frequently in seconds to evaluate the trigger."
    },
    "recipients": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/RecipientRef"
      }
    }
  },
  "$defs": {
    "QuerySpec": {
      "type": "object",
      "description": "A query specification defining what data to retrieve and how to aggregate it.",
      "properties": {
        "calculations": {
          "type": "array",
          "description": "The calculations to perform on the query data.",
          "items": {
            "type": "object",
            "properties": {
              "op": {
                "type": "string",
                "description": "The aggregation operation.",
                "enum": [
                  "COUNT",
                  "SUM",
                  "AVG",
                  "COUNT_DISTINCT",
                  "MAX",
                  "MIN",
                  "P001",
                  "P01",
                  "P05",
                  "P10",
                  "P25",
                  "P50",
                  "P75",
                  "P90",
                  "P95",
                  "P99",
                  "P999",
                  "HEATMAP",
                  "RATE_AVG",
                  "RATE_SUM",
                  "RATE_MAX"
                ]
              },
              "column": {
                "type": "string",
                "description": "The column to perform the calculation on."
              }
            }
          }
        },
        "filters": {
          "type": "array",
          "description": "Filters to apply to the query.",
          "items": {
            "type": "object",
            "properties": {
              "column": {
                "type": "string",
                "description": "The column to filter on."
              },
              "op": {
                "type": "string",
                "description": "The filter operator.",
                "enum": [
                  "=",
                  "!=",
                  ">",
                  ">=",
                  "<",
                  "<=",
                  "starts-with",
                  "does-not-start-with",
                  "contains",
                  "does-not-contain",
                  "exists",
                  "does-not-exist",
                  "in",
                  "not-in"
                ]
              },
              "value": {
                "description": "The value to compare against."
              }
            }
          }
        },
        "breakdowns": {
          "type": "array",
          "description": "Columns to group results by.",
          "items": {
            "type": "string"
          }
        },
        "orders": {
          "type": "array",
          "description": "Ordering for the results.",
          "items": {
            "type": "object",
            "properties": {
              "column": {
                "type": "string"
              },
              "op": {
                "type": "string"
              },
              "order": {
                "type": "string",
                "enum": [
                  "ascending",
                  "descending"
                ]
              }
            }
          }
        },
        "time_range": {
          "type": "integer",
          "description": "The time range in seconds to query over."
        },
        "start_time": {
          "type": "integer",
          "description": "Unix timestamp for the query start time."
        },
        "end_time": {
          "type": "integer",
          "description": "Unix timestamp for the query end time."
        },
        "granularity": {
          "type": "integer",
          "description": "The granularity of results in seconds."
        },
        "limit": {
          "type": "integer",
          "description": "The maximum number of results to return."
        }
      }
    },
    "RecipientRef": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "description": "The ID of the recipient to notify."
        }
      }
    }
  }
}