{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/propraven-com/json-schema/propraven-com-webhook-schema.json",
  "title": "Webhook",
  "description": "One webhook endpoint, as returned by GET /webhooks (each item) and GET /webhooks/{id}.",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/propraven-com-webhooks-api-openapi.yml#/components/schemas/Webhook",
  "type": "object",
  "properties": {
    "id": {
      "type": "string",
      "format": "uuid"
    },
    "url": {
      "type": "string",
      "format": "uri",
      "description": "Customer endpoint. Must be https://."
    },
    "secret_prefix": {
      "type": "string",
      "description": "First 14 characters of the secret (`whsec_` + 8 hex). Identifies the endpoint; the full secret is shown only in the create response."
    },
    "event_types": {
      "type": "array",
      "items": {
        "type": "string",
        "enum": [
          "parcel.sold",
          "parcel.permit_filed",
          "parcel.owner_changed"
        ]
      }
    },
    "filter_kind": {
      "type": "string",
      "enum": [
        "parcel_ids",
        "state_fips",
        "county_fips"
      ]
    },
    "filter_value": {
      "$ref": "#/$defs/WebhookFilter"
    },
    "description": {
      "type": [
        "string",
        "null"
      ],
      "maxLength": 200
    },
    "is_active": {
      "type": "boolean",
      "description": "false after DELETE (a soft disable)."
    },
    "created_at": {
      "type": "string",
      "format": "date-time"
    },
    "disabled_at": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "disabled_reason": {
      "type": [
        "string",
        "null"
      ],
      "description": "`user` when disabled with DELETE; null while active."
    },
    "deliveries_attempted": {
      "type": "integer"
    },
    "deliveries_succeeded": {
      "type": "integer"
    },
    "last_delivery_at": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "last_success_at": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "identity_status": {
      "type": "string",
      "enum": [
        "canonical",
        "legacy_bare_parcel_ids"
      ],
      "description": "parcel_ids endpoints only. `legacy_bare_parcel_ids`: the endpoint was created before 2026-09-22 with bare parcel numbers, and those that do not name exactly one parcel are not matched; recreate it with canonical ids."
    }
  },
  "$defs": {
    "WebhookFilter": {
      "oneOf": [
        {
          "type": "object",
          "required": [
            "parcel_ids"
          ],
          "properties": {
            "parcel_ids": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "minItems": 1,
              "maxItems": 1000,
              "description": "Parcels to subscribe to, 1–1000: canonical ids `state_fips:county_fips:parcel_id` (preferred; the `canonical_id` other endpoints return), legacy `SSCCC:parcel_id`, parcel UUIDs, or a bare parcel_id that names exactly ONE served parcel. parcel_id is county-scoped, so a bare id that names several parcels is refused with 422 `parcel_identity_unresolved` listing the candidate canonical ids. Stored and matched on the full identity; deliveries carry `canonical_id`."
            }
          }
        },
        {
          "type": "object",
          "required": [
            "state_fips"
          ],
          "properties": {
            "state_fips": {
              "type": "string",
              "pattern": "^[0-9]{2}$",
              "description": "2-digit state FIPS — subscribe to all parcels in this state."
            }
          }
        },
        {
          "type": "object",
          "required": [
            "state_fips",
            "county_fips"
          ],
          "properties": {
            "state_fips": {
              "type": "string",
              "pattern": "^[0-9]{2}$"
            },
            "county_fips": {
              "type": "string",
              "pattern": "^[0-9]{3}$",
              "description": "3-digit county FIPS (within the state) — subscribe to all parcels in this county."
            }
          }
        }
      ],
      "description": "Shape varies with filter_kind. parcel_ids: explicit list. state_fips: all parcels in a state. county_fips: all parcels in a county within a state."
    }
  }
}