{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://www.firstmilelabs.com/schemas/webhooks/screening.completed.v1.json",
  "title": "FirstMileLabs Outbound Webhook — screening.completed (v1)",
  "description": "Emitted when a sanctions / PEP / adverse media screening run finishes for a case.",
  "type": "object",
  "additionalProperties": true,
  "required": [
    "event",
    "eventId",
    "eventVersion",
    "timestamp",
    "orgId",
    "caseId",
    "screened",
    "summary"
  ],
  "properties": {
    "event": { "type": "string", "const": "screening.completed" },
    "eventId": { "type": "string", "format": "uuid" },
    "eventVersion": { "type": "integer", "const": 1 },
    "timestamp": { "type": "string", "format": "date-time", "description": "Envelope emission time. The body also carries a screening-completion timestamp under the same field name in older payloads." },
    "orgId": { "type": "string" },
    "crmRecordId": { "type": ["string", "null"] },
    "caseId": { "type": "string" },
    "screened": { "type": "integer", "minimum": 0, "description": "Total subjects screened (company plus directors and shareholders)." },
    "summary": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": true,
        "required": ["name", "role", "status"],
        "properties": {
          "name": { "type": "string" },
          "role": { "type": ["string", "null"], "description": "e.g. \"director\", \"shareholder\". Null for the company subject (the company row has no person-role)." },
          "status": { "type": "string", "enum": ["clear", "match", "pep", "sanctioned"] }
        }
      }
    }
  }
}
