{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/peppolstatus-com/json-schema/peppolstatus-com-host-view-schema.json",
  "title": "HostView",
  "description": "A host's current (or point-in-time) state.",
  "x-generated": "2026-11-21",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/peppolstatus-com-hosts-api-openapi.yml#/components/schemas/HostView",
  "type": "object",
  "required": [
    "hostname",
    "role",
    "verdict",
    "network",
    "cert"
  ],
  "properties": {
    "hostname": {
      "type": "string"
    },
    "role": {
      "type": [
        "string",
        "null"
      ],
      "enum": [
        "SMP",
        "AP",
        null
      ]
    },
    "verdict": {
      "$ref": "#/$defs/HostState"
    },
    "network": {
      "oneOf": [
        {
          "$ref": "#/$defs/HostNetwork"
        },
        {
          "type": "null"
        }
      ]
    },
    "cert": {
      "$ref": "#/$defs/HostCert"
    },
    "provider": {
      "$ref": "#/$defs/HostProviderInfo"
    },
    "profile": {
      "oneOf": [
        {
          "$ref": "#/$defs/HostProfileView"
        },
        {
          "type": "null"
        }
      ]
    },
    "seats": {
      "type": "array",
      "description": "The Seat(s) this host currently operates (from seat sightings). Each seat's `seat_id` is the participant.ap_seat_id value linking the host to the participants it serves.",
      "items": {
        "$ref": "#/$defs/HostSeat"
      }
    }
  },
  "$defs": {
    "HostCert": {
      "type": [
        "object",
        "null"
      ],
      "required": [
        "fingerprint",
        "subject",
        "issuer",
        "not_before",
        "not_after"
      ],
      "properties": {
        "fingerprint": {
          "type": "string"
        },
        "subject": {
          "type": "string"
        },
        "issuer": {
          "type": "string"
        },
        "not_before": {
          "type": "string",
          "format": "date-time"
        },
        "not_after": {
          "type": "string",
          "format": "date-time"
        },
        "days_to_expiry": {
          "type": "integer",
          "description": "Whole days from the response instant to `not_after`, floored; negative once the certificate has expired (issue #519). Derived server-side."
        },
        "expiry_status": {
          "type": "string",
          "enum": [
            "ok",
            "expiring",
            "expired"
          ],
          "description": "Derived TLS-expiry state (issue #519): `expired` once `not_after` is past, `expiring` within 30 days of now, else `ok`. A tighter near-term window additionally raises a `host_tls_cert_expiring`/`host_tls_cert_expired` anomaly."
        }
      }
    },
    "HostNetwork": {
      "type": "object",
      "required": [
        "ips",
        "ptr"
      ],
      "properties": {
        "ips": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "ptr": {
          "type": [
            "string",
            "null"
          ]
        }
      }
    },
    "HostProfileView": {
      "type": "object",
      "description": "Crawled software identity of the host's registrable domain (eTLD+1), so every `smp.acme.com` / `ap.acme.com` shares one profile. Only rows that pass the surfacing rule appear: a curator confirmed the identity (`curated: true`), or extraction confidence reached 0.8 — then the row is AUTO-GENERATED and UNVERIFIED and must be labelled as such.",
      "required": [
        "domain",
        "status",
        "company_name",
        "product_name",
        "tagline",
        "category",
        "confidence",
        "curated",
        "screenshot_url",
        "crawled_at"
      ],
      "properties": {
        "domain": {
          "type": "string",
          "description": "The registrable domain the profile describes."
        },
        "status": {
          "type": "string",
          "enum": [
            "identified",
            "infrastructure"
          ],
          "description": "`identified` — the domain's own company/product. `infrastructure` — a multi-tenant platform the host RUNS ON (read it as \"runs on X\", never \"is X\")."
        },
        "company_name": {
          "type": [
            "string",
            "null"
          ]
        },
        "product_name": {
          "type": [
            "string",
            "null"
          ]
        },
        "tagline": {
          "type": [
            "string",
            "null"
          ]
        },
        "category": {
          "type": [
            "string",
            "null"
          ]
        },
        "confidence": {
          "type": [
            "number",
            "null"
          ],
          "description": "Extraction confidence 0..1; null for a curated row with no stored score."
        },
        "curated": {
          "type": "boolean",
          "description": "True when a curator confirmed the identity. False means auto-generated and unverified — annotate, never assert."
        },
        "screenshot_url": {
          "type": [
            "string",
            "null"
          ],
          "description": "Same-origin path to the homepage screenshot (`/v1/hosts/asset/{domain}/screenshot.jpg`, free tier); null when none captured."
        },
        "crawled_at": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time"
        }
      }
    },
    "HostProviderInfo": {
      "type": [
        "object",
        "null"
      ],
      "required": [
        "key",
        "trade_name",
        "legal_name",
        "country"
      ],
      "properties": {
        "key": {
          "type": "string"
        },
        "trade_name": {
          "type": "string"
        },
        "legal_name": {
          "type": [
            "string",
            "null"
          ]
        },
        "country": {
          "type": [
            "string",
            "null"
          ]
        },
        "ap_key": {
          "type": [
            "string",
            "null"
          ],
          "description": "The provider's access-point directory key for the console's /providers/{key} link (the `key` field above is the natural key, which that route does not resolve); null when no seat of the provider is a member of any directory entry. Optional: an edge-cached /v1/hosts response minted before this field existed omits it."
        }
      }
    },
    "HostRole": {
      "type": "string",
      "enum": [
        "SMP",
        "AP"
      ]
    },
    "HostSeat": {
      "type": "object",
      "description": "A Seat a host currently operates, with its embedded provider.",
      "required": [
        "seat_id",
        "role",
        "provider"
      ],
      "properties": {
        "seat_id": {
          "type": "string"
        },
        "role": {
          "$ref": "#/$defs/HostRole"
        },
        "provider": {
          "$ref": "#/$defs/SeatProvider"
        }
      }
    },
    "HostState": {
      "type": [
        "string",
        "null"
      ],
      "enum": [
        "up",
        "degraded",
        "down",
        "unresolvable",
        null
      ],
      "description": "Rolled-up host state (issue #310): a per-location `Verdict` (`up`/`degraded`/`down`) plus the derived `unresolvable` — a hostname that has NEVER resolved in DNS. `unresolvable` is neutral/informational, NOT an outage. null when unknown."
    },
    "SeatProvider": {
      "type": "object",
      "description": "Embedded provider for a seat, verified mapping or unverified CN fallback.",
      "required": [
        "slug",
        "name",
        "country",
        "verified"
      ],
      "properties": {
        "slug": {
          "type": [
            "string",
            "null"
          ]
        },
        "name": {
          "type": [
            "string",
            "null"
          ]
        },
        "country": {
          "type": [
            "string",
            "null"
          ]
        },
        "verified": {
          "type": "boolean"
        },
        "key": {
          "type": [
            "string",
            "null"
          ],
          "description": "The curated provider's OpenPeppol registry natural key, when the mapping carries one. It decides whether the seat's operator and a host's owner are the same party; it is not a /v1/aps route key and not the slug. Optional: absent on a cached response minted before the field shipped."
        }
      }
    }
  }
}