{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/logbrew/json-schema/logbrew-webhook-delivery-response-schema.json",
  "title": "WebhookDeliveryResponse",
  "description": "One delivery of one event to a webhook.",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/logbrew-alerts-api-openapi.yml#/components/schemas/WebhookDeliveryResponse",
  "properties": {
    "attempts": {
      "description": "Attempts made, at most 6.",
      "format": "uint8",
      "maximum": 255,
      "minimum": 0,
      "type": "integer"
    },
    "created_at": {
      "description": "When the delivery was queued.",
      "format": "date-time",
      "type": "string"
    },
    "error": {
      "anyOf": [
        {
          "$ref": "#/$defs/WebhookDeliveryError"
        },
        {
          "type": "null"
        }
      ],
      "description": "Why the last attempt failed, if it did."
    },
    "event": {
      "$ref": "#/$defs/WebhookEvent",
      "description": "The event."
    },
    "id": {
      "description": "Delivery ID, also sent as the `webhook-id` header and the generic payload's `id`; it stays\nthe same across retries.",
      "format": "uuid",
      "type": "string"
    },
    "issue_id": {
      "description": "The issue, if the event is about one.",
      "format": "uuid",
      "type": [
        "string",
        "null"
      ]
    },
    "last_attempt_at": {
      "description": "When the last attempt was made.",
      "format": "date-time",
      "type": [
        "string",
        "null"
      ]
    },
    "next_attempt_at": {
      "description": "When the next attempt is due, while pending.",
      "format": "date-time",
      "type": [
        "string",
        "null"
      ]
    },
    "occurred_at": {
      "description": "When the event happened.",
      "format": "date-time",
      "type": "string"
    },
    "rule_id": {
      "description": "The alert rule, for an alert rule event.",
      "format": "uuid",
      "type": [
        "string",
        "null"
      ]
    },
    "state": {
      "$ref": "#/$defs/WebhookDeliveryState",
      "description": "Where it is."
    },
    "status_code": {
      "description": "HTTP status of the last attempt, if the URL answered.",
      "format": "uint16",
      "maximum": 65535,
      "minimum": 0,
      "type": [
        "integer",
        "null"
      ]
    }
  },
  "required": [
    "id",
    "event",
    "issue_id",
    "rule_id",
    "state",
    "attempts",
    "status_code",
    "error",
    "occurred_at",
    "created_at",
    "last_attempt_at",
    "next_attempt_at"
  ],
  "type": "object",
  "$defs": {
    "WebhookDeliveryError": {
      "description": "Why a delivery attempt failed.",
      "oneOf": [
        {
          "const": "timeout",
          "description": "The URL did not answer within 10 seconds.",
          "type": "string"
        },
        {
          "const": "connection",
          "description": "The connection or TLS handshake failed, or the host was not found.",
          "type": "string"
        },
        {
          "const": "blocked_address",
          "description": "The host resolved to a private, loopback, link-local, or other non-public address.",
          "type": "string"
        },
        {
          "const": "redirect",
          "description": "The URL answered with a redirect, which deliveries never follow.",
          "type": "string"
        },
        {
          "const": "http_status",
          "description": "The URL answered with a status outside 2xx; see `status_code`.",
          "type": "string"
        }
      ]
    },
    "WebhookDeliveryState": {
      "description": "Where a delivery is.",
      "oneOf": [
        {
          "const": "pending",
          "description": "Waiting for its next attempt.",
          "type": "string"
        },
        {
          "const": "delivered",
          "description": "The URL answered with a 2xx status.",
          "type": "string"
        },
        {
          "const": "failed",
          "description": "Its last attempt failed.",
          "type": "string"
        },
        {
          "const": "skipped",
          "description": "Not sent: the webhook was paused, turned off, or removed, or no longer takes the event.",
          "type": "string"
        }
      ]
    },
    "WebhookEvent": {
      "description": "An event a webhook can take, and the event of a test delivery.",
      "oneOf": [
        {
          "const": "new_issue",
          "description": "A new issue appeared.",
          "type": "string"
        },
        {
          "const": "regressed_issue",
          "description": "A resolved issue happened again.",
          "type": "string"
        },
        {
          "const": "reopened_issue",
          "description": "A resolved or archived issue opened again.",
          "type": "string"
        },
        {
          "const": "assigned_issue",
          "description": "An issue was assigned.",
          "type": "string"
        },
        {
          "const": "alert_rule",
          "description": "One of the project's alert rules fired.",
          "type": "string"
        },
        {
          "const": "usage_warning",
          "description": "The project owner's account used 80% of a plan limit.",
          "type": "string"
        },
        {
          "const": "usage_limit",
          "description": "The project owner's account reached a plan limit.",
          "type": "string"
        },
        {
          "const": "test",
          "description": "A test sent on request; a webhook cannot subscribe to it.",
          "type": "string"
        }
      ]
    }
  }
}