{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "WebhookEndpoint.json",
  "title": "Webhook endpoint",
  "description": "A URL that receives events.",
  "type": "object",
  "properties": {
    "id": {
      "type": "integer",
      "format": "int32",
      "description": "Endpoint id."
    },
    "url": {
      "type": "string",
      "description": "Where events are sent."
    },
    "description": {
      "type": [
        "string",
        "null"
      ],
      "description": "Your label."
    },
    "events": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "Event types it receives, or [\"*\"] for all."
    },
    "active": {
      "type": "boolean",
      "description": "Whether it receives events."
    },
    "disabledReason": {
      "type": [
        "string",
        "null"
      ],
      "description": "Why Flux switched it off, if it did."
    },
    "consecutiveFailures": {
      "type": "integer",
      "format": "int32",
      "description": "Failed delivery attempts in a row. At 50, Flux switches the endpoint off."
    },
    "createdAt": {
      "type": "string",
      "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?$",
      "description": "When it was created. UTC, no offset."
    },
    "secret": {
      "type": [
        "string",
        "null"
      ],
      "description": "The signing secret, whsec_…. Only on create and rotate, shown once; null otherwise."
    }
  },
  "required": [
    "id",
    "url",
    "description",
    "events",
    "active",
    "disabledReason",
    "consecutiveFailures",
    "createdAt",
    "secret"
  ],
  "examples": [
    {
      "id": 3,
      "url": "https://hooks.example.com/flux",
      "description": "Billing sync",
      "events": [
        "invoice.paid",
        "receipt.issued"
      ],
      "active": true,
      "disabledReason": null,
      "consecutiveFailures": 0,
      "createdAt": "2026-11-01T10:00:00",
      "secret": "whsec_Xq3vT8mKp2Lr7Ns1Wd5Yb9Hc4Fj6Ga0Z"
    }
  ]
}
