{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/companydata-dk/json-schema/companydata-dk-webhook-with-secret-schema.json",
  "title": "WebhookWithSecret",
  "description": "A webhook configuration including the secret. Only returned on creation.",
  "x-generated": "2026-11-04",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/companydata-dk-openapi.yml#/components/schemas/WebhookWithSecret",
  "properties": {
    "webhook_id": {
      "type": "string",
      "title": "Webhook Id",
      "description": "Unique identifier for this webhook."
    },
    "name": {
      "type": "string",
      "title": "Name",
      "description": "Human-readable label."
    },
    "url": {
      "type": "string",
      "title": "Url",
      "description": "HTTPS endpoint that receives deliveries."
    },
    "active": {
      "type": "boolean",
      "title": "Active",
      "description": "Whether this webhook is currently delivering events."
    },
    "event_types": {
      "items": {
        "$ref": "#/$defs/EventType"
      },
      "type": "array",
      "title": "Event Types",
      "description": "Event types this webhook receives."
    },
    "headers": {
      "additionalProperties": {
        "type": "string"
      },
      "type": "object",
      "title": "Headers",
      "description": "Custom headers added to every delivery."
    },
    "last_success_at": {
      "anyOf": [
        {
          "type": "string",
          "format": "date-time"
        },
        {
          "type": "null"
        }
      ],
      "title": "Last Success At",
      "description": "Timestamp of the most recent successful (2xx) delivery."
    },
    "last_failure_at": {
      "anyOf": [
        {
          "type": "string",
          "format": "date-time"
        },
        {
          "type": "null"
        }
      ],
      "title": "Last Failure At",
      "description": "Timestamp of the most recent failed delivery attempt."
    },
    "consecutive_failures": {
      "type": "integer",
      "title": "Consecutive Failures",
      "description": "Number of consecutive failed deliveries. Reset to 0 on the next 2xx response. Reaching 10 auto-disables the webhook.",
      "default": 0
    },
    "disabled_reason": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Disabled Reason",
      "description": "Set when the webhook is auto-disabled. `null` otherwise."
    },
    "created_at": {
      "type": "string",
      "format": "date-time",
      "title": "Created At",
      "description": "When the webhook was created."
    },
    "secret": {
      "type": "string",
      "title": "Secret",
      "description": "HMAC-SHA256 signing secret. Used to verify the `X-Companydata-Signature` header on every incoming delivery. **Store this immediately — it is never returned again.**"
    }
  },
  "type": "object",
  "required": [
    "webhook_id",
    "name",
    "url",
    "active",
    "event_types",
    "headers",
    "created_at",
    "secret"
  ],
  "$defs": {
    "EventType": {
      "type": "string",
      "enum": [
        "company_status",
        "ownership",
        "board",
        "director",
        "financial",
        "announcement",
        "address",
        "contact",
        "financial_distress",
        "corporate_announcement",
        "property_ownership",
        "tender_award",
        "new_company",
        "press_release",
        "media_mention",
        "court_hearing",
        "screen_entered",
        "screen_left"
      ],
      "title": "EventType",
      "description": "Types of change events that can trigger notifications."
    }
  }
}