{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/logbrew/json-schema/logbrew-alert-rule-response-schema.json",
  "title": "AlertRuleResponse",
  "description": "One alert rule.",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/logbrew-alerts-api-openapi.yml#/components/schemas/AlertRuleResponse",
  "properties": {
    "created_at": {
      "description": "When it was created.",
      "format": "date-time",
      "type": "string"
    },
    "environment": {
      "description": "The environment it watches; `null` for all.",
      "type": [
        "string",
        "null"
      ]
    },
    "factor": {
      "description": "Escalation factor; `null` for other kinds.",
      "format": "uint32",
      "minimum": 0,
      "type": [
        "integer",
        "null"
      ]
    },
    "id": {
      "description": "Rule ID.",
      "format": "uuid",
      "type": "string"
    },
    "issue_id": {
      "description": "The issue an event count counts; `null` for all.",
      "format": "uuid",
      "type": [
        "string",
        "null"
      ]
    },
    "kind": {
      "$ref": "#/$defs/AlertRuleKind",
      "description": "What it watches."
    },
    "last_fired_at": {
      "description": "When it last fired; `null` when it never did.",
      "format": "date-time",
      "type": [
        "string",
        "null"
      ]
    },
    "level": {
      "anyOf": [
        {
          "$ref": "#/$defs/AlertRuleLevel"
        },
        {
          "type": "null"
        }
      ],
      "description": "The lowest level an event count counts; `null` for all or another kind."
    },
    "muted": {
      "description": "Whether it is muted.",
      "type": "boolean"
    },
    "name": {
      "description": "Name; empty for none.",
      "type": "string"
    },
    "project_id": {
      "description": "The project it watches.",
      "format": "uuid",
      "type": "string"
    },
    "recipients": {
      "$ref": "#/$defs/AlertRuleRecipients",
      "description": "Who it alerts."
    },
    "service": {
      "description": "The service an event count counts or a quiet period watches; `null` for all.",
      "type": [
        "string",
        "null"
      ]
    },
    "snoozed_until": {
      "description": "When a snooze ends; `null` when not snoozed.",
      "format": "date-time",
      "type": [
        "string",
        "null"
      ]
    },
    "threshold": {
      "description": "Event count or escalation threshold; `null` for other kinds.",
      "format": "uint64",
      "minimum": 0,
      "type": [
        "integer",
        "null"
      ]
    },
    "updated_at": {
      "description": "When it last changed.",
      "format": "date-time",
      "type": "string"
    },
    "window_minutes": {
      "description": "Window length in minutes; `null` for new issue and regression rules.",
      "format": "uint32",
      "minimum": 0,
      "type": [
        "integer",
        "null"
      ]
    }
  },
  "required": [
    "id",
    "project_id",
    "name",
    "kind",
    "environment",
    "level",
    "service",
    "issue_id",
    "threshold",
    "factor",
    "window_minutes",
    "recipients",
    "muted",
    "snoozed_until",
    "last_fired_at",
    "created_at",
    "updated_at"
  ],
  "type": "object",
  "$defs": {
    "AlertRuleKind": {
      "description": "What a rule watches.",
      "oneOf": [
        {
          "const": "new_issue",
          "description": "An issue appears for the first time, in the rule's environment when it has one.",
          "type": "string"
        },
        {
          "const": "regression",
          "description": "A resolved issue happens again.",
          "type": "string"
        },
        {
          "const": "escalation",
          "description": "An issue's event rate in the window reaches `factor` times its rate over the day before.",
          "type": "string"
        },
        {
          "const": "event_count",
          "description": "The window holds at least `threshold` matching events.",
          "type": "string"
        },
        {
          "const": "quiet_period",
          "description": "A service sends nothing for the whole window, like a missed heartbeat.",
          "type": "string"
        }
      ]
    },
    "AlertRuleLevel": {
      "description": "The lowest event level an event count counts; higher levels count too.",
      "oneOf": [
        {
          "const": "info",
          "description": "Info and above.",
          "type": "string"
        },
        {
          "const": "warning",
          "description": "Warning and above.",
          "type": "string"
        },
        {
          "const": "error",
          "description": "Error and above.",
          "type": "string"
        },
        {
          "const": "critical",
          "description": "Critical only.",
          "type": "string"
        }
      ]
    },
    "AlertRuleRecipients": {
      "additionalProperties": false,
      "description": "Who a rule alerts. A recipient gets an alert only while they can read the project.",
      "properties": {
        "members": {
          "default": [],
          "description": "Account IDs.",
          "items": {
            "format": "uuid",
            "type": "string"
          },
          "type": "array"
        },
        "project_members": {
          "default": false,
          "description": "Everyone who can read the project.",
          "type": "boolean"
        },
        "teams": {
          "default": [],
          "description": "Organization team IDs; their members when the rule fires.",
          "items": {
            "format": "uuid",
            "type": "string"
          },
          "type": "array"
        }
      },
      "required": [
        "project_members",
        "members",
        "teams"
      ],
      "type": "object"
    }
  }
}