{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://www.firstmilelabs.com/schemas/webhooks/case.data_package.delivered.v1.json",
  "title": "FirstMileLabs Outbound Webhook — case.data_package.delivered (v1)",
  "description": "The consolidated decision-time full-parity data package — everything FirstMileLabs holds about a case: company profile, the COMPLETE ownership roster (directors + UBOs, each with ownership %, nationality and date of birth), every extracted document field (decrypted), and the decision/risk/screening summary. Emitted ONCE at decision time and ONLY for tenants that have opted into full-parity egress (double-gated: an FML-unlocked `full_parity_egress` entitlement AND a tenant compliance-admin toggle). This event carries special-category personal data by design — the deliberate opposite of `case.onboarding_progress.changed`, which strips all PII. Its successful (2xx) delivery is also the Zero-Retention purge precondition for full-parity tenants. See https://www.firstmilelabs.com/docs/webhooks and docs/full-parity-egress.md.",
  "type": "object",
  "additionalProperties": true,
  "required": [
    "event",
    "eventId",
    "eventVersion",
    "timestamp",
    "orgId",
    "caseId",
    "decidedAt",
    "outcome",
    "fullParity"
  ],
  "properties": {
    "event": { "type": "string", "const": "case.data_package.delivered" },
    "eventId": { "type": "string", "format": "uuid" },
    "eventVersion": { "type": "integer", "const": 1 },
    "timestamp": { "type": "string", "format": "date-time" },
    "orgId": { "type": "string" },
    "crmRecordId": { "type": ["string", "null"], "description": "The CRM record id supplied when the case was created, echoed back so the receiver can correlate." },
    "crmSource": { "type": ["string", "null"], "description": "The CRM the case originated from (e.g. \"salesforce\"), so a multi-CRM receiver can route." },
    "caseId": { "type": "string" },
    "decidedAt": { "type": "string", "format": "date-time", "description": "The decision timestamp this package corresponds to. Stable across redelivery; used by the Zero-Retention gate to correlate delivery to the final decision." },
    "outcome": { "type": ["string", "null"], "description": "The case decision outcome at package time (e.g. \"approved\", \"declined\")." },
    "fullParity": {
      "type": "object",
      "additionalProperties": true,
      "description": "The complete case projection. Identical in shape to the `fullParity` slice attached to lifecycle webhooks and the Pull API case detail when full-parity egress is enabled.",
      "required": ["caseId", "orgId", "status", "companyProfile", "ownership", "documents", "screeningSummary"],
      "properties": {
        "caseId": { "type": "string" },
        "orgId": { "type": "string" },
        "status": { "type": ["string", "null"] },
        "crmRecordId": { "type": ["string", "null"] },
        "crmSource": { "type": ["string", "null"] },
        "companyProfile": {
          "type": "object",
          "additionalProperties": true,
          "description": "The full company profile FML holds (KYB). For individual (KYC) cases, company fields may be null.",
          "properties": {
            "companyName": { "type": ["string", "null"] },
            "registrationNumber": { "type": ["string", "null"] },
            "country": { "type": ["string", "null"] },
            "entityType": { "type": ["string", "null"] },
            "incorporationDate": { "type": ["string", "null"] },
            "registeredAddress": { "type": ["string", "null"] },
            "tradingAddress": { "type": ["string", "null"] },
            "taxId": { "type": ["string", "null"] },
            "vatNumber": { "type": ["string", "null"] },
            "businessActivity": { "type": ["string", "null"] },
            "businessDescription": { "type": ["string", "null"] },
            "industrySector": { "type": ["string", "null"] },
            "annualRevenue": { "type": ["string", "null"] },
            "website": { "type": ["string", "null"] },
            "customerEmail": { "type": ["string", "null"] },
            "sourceOfFunds": { "type": ["string", "null"] },
            "transactsInternationally": { "type": ["boolean", "null"] },
            "internationalCountries": { "type": "array", "items": { "type": "string" } },
            "customAnswers": { "type": "object", "additionalProperties": true }
          }
        },
        "ownership": {
          "type": "object",
          "additionalProperties": true,
          "required": ["directors", "ubos"],
          "description": "The complete ownership roster. Each person carries ownership %, nationality and date of birth — the special-category fields the sales-safe onboarding-progress projection strips.",
          "properties": {
            "directors": { "type": "array", "items": { "$ref": "#/$defs/rosterPerson" } },
            "ubos": { "type": "array", "items": { "$ref": "#/$defs/rosterPerson" } }
          }
        },
        "documents": {
          "type": "array",
          "description": "Every uploaded document with its full, decrypted extracted-data payload.",
          "items": {
            "type": "object",
            "additionalProperties": true,
            "properties": {
              "id": { "type": ["integer", "string"] },
              "documentType": { "type": ["string", "null"] },
              "filename": { "type": ["string", "null"] },
              "mimeType": { "type": ["string", "null"] },
              "sizeBytes": { "type": ["integer", "null"] },
              "status": { "type": ["string", "null"] },
              "confidence": { "type": ["string", "null"] },
              "uploadedAt": { "type": ["string", "null"], "format": "date-time" },
              "warnings": { "type": "array" },
              "notes": { "type": ["string", "null"] },
              "extractedData": { "type": ["object", "null"], "additionalProperties": true, "description": "Every AI-extracted field, decrypted." }
            }
          }
        },
        "decision": {
          "type": ["object", "null"],
          "additionalProperties": true,
          "properties": {
            "outcome": { "type": ["string", "null"] },
            "notes": { "type": ["string", "null"] },
            "analystEmail": { "type": ["string", "null"] },
            "decidedAt": { "type": ["string", "null"], "format": "date-time" }
          }
        },
        "risk": {
          "type": ["object", "null"],
          "additionalProperties": true,
          "properties": {
            "compositeScore": { "type": ["number", "null"] },
            "band": { "type": ["string", "null"] },
            "assessedAt": { "type": ["string", "null"], "format": "date-time" }
          }
        },
        "screeningSummary": {
          "type": "object",
          "additionalProperties": true,
          "required": ["totalHits", "sanctionedHits", "pepHits"],
          "properties": {
            "totalHits": { "type": "integer", "minimum": 0 },
            "sanctionedHits": { "type": "integer", "minimum": 0 },
            "pepHits": { "type": "integer", "minimum": 0 }
          }
        }
      }
    }
  },
  "$defs": {
    "rosterPerson": {
      "type": "object",
      "additionalProperties": true,
      "properties": {
        "name": { "type": ["string", "null"] },
        "email": { "type": ["string", "null"] },
        "roles": { "type": "array", "items": { "type": "string" } },
        "ownershipPercent": { "type": ["number", "null"], "description": "Beneficial ownership percentage. Special-category-adjacent — only ever egressed under full-parity." },
        "nationality": { "type": ["string", "null"] },
        "dateOfBirth": { "type": ["string", "null"], "description": "Special-category PII — only ever egressed under full-parity." },
        "idNumber": { "type": ["string", "null"] },
        "idCountry": { "type": ["string", "null"] },
        "countryOfResidence": { "type": ["string", "null"] },
        "source": { "type": ["string", "null"] }
      }
    }
  }
}
