{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/coldrig-dev/json-schema/coldrig-dev-webhook-detail-schema.json",
  "title": "WebhookDetail",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/coldrig-dev-webhooks-api-openapi.yml#/components/schemas/WebhookDetail",
  "type": "object",
  "required": [
    "subscription",
    "recentDeliveries",
    "recentAttempts"
  ],
  "properties": {
    "subscription": {
      "$ref": "#/$defs/WebhookSummary"
    },
    "recentDeliveries": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/WebhookDeliveryView"
      }
    },
    "recentAttempts": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/WebhookAttemptView"
      }
    }
  },
  "$defs": {
    "WebhookAttemptView": {
      "type": "object",
      "required": [
        "deliveryId",
        "attemptNo",
        "ok",
        "statusCode",
        "error",
        "ts"
      ],
      "properties": {
        "deliveryId": {
          "type": "string"
        },
        "attemptNo": {
          "type": "integer"
        },
        "ok": {
          "type": "boolean"
        },
        "statusCode": {
          "type": [
            "integer",
            "null"
          ]
        },
        "error": {
          "type": [
            "string",
            "null"
          ]
        },
        "ts": {
          "type": "integer"
        }
      }
    },
    "WebhookDeliveryView": {
      "type": "object",
      "required": [
        "id",
        "eventId",
        "eventType",
        "status",
        "attempts",
        "lastStatusCode",
        "lastError",
        "nextAttemptAt",
        "createdAt",
        "lastAttemptAt",
        "deliveredAt"
      ],
      "properties": {
        "id": {
          "type": "string"
        },
        "eventId": {
          "type": "string"
        },
        "eventType": {
          "type": "string"
        },
        "status": {
          "type": "string"
        },
        "attempts": {
          "type": "integer"
        },
        "lastStatusCode": {
          "type": [
            "integer",
            "null"
          ]
        },
        "lastError": {
          "type": [
            "string",
            "null"
          ]
        },
        "nextAttemptAt": {
          "type": "integer"
        },
        "createdAt": {
          "type": "integer"
        },
        "lastAttemptAt": {
          "type": [
            "integer",
            "null"
          ]
        },
        "deliveredAt": {
          "type": [
            "integer",
            "null"
          ]
        }
      }
    },
    "WebhookEventType": {
      "type": "string",
      "enum": [
        "reply",
        "bounce",
        "soft_bounce",
        "complaint",
        "unsubscribe"
      ],
      "description": "reply = genuine reply; bounce = HARD (permanent) bounce; soft_bounce = transient bounce; complaint = spam complaint; unsubscribe = typed unsubscribe-link click."
    },
    "WebhookSummary": {
      "type": "object",
      "required": [
        "id",
        "url",
        "eventTypes",
        "active",
        "status",
        "disabledReason",
        "consecutiveFailures",
        "createdAt",
        "updatedAt"
      ],
      "properties": {
        "id": {
          "type": "string"
        },
        "url": {
          "type": "string"
        },
        "eventTypes": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/WebhookEventType"
          }
        },
        "active": {
          "type": "boolean"
        },
        "status": {
          "type": "string",
          "enum": [
            "active",
            "disabled"
          ]
        },
        "disabledReason": {
          "type": [
            "string",
            "null"
          ]
        },
        "consecutiveFailures": {
          "type": "integer"
        },
        "createdAt": {
          "type": "integer"
        },
        "updatedAt": {
          "type": "integer"
        }
      }
    }
  }
}