{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://www.firstmilelabs.com/schemas/webhooks/case.status.changed.v1.json",
  "title": "FirstMileLabs Outbound Webhook — case.status.changed (v1)",
  "description": "Emitted on case lifecycle transitions — initial submission, decision, escalation to senior, return from senior review.",
  "type": "object",
  "additionalProperties": true,
  "required": [
    "event",
    "eventId",
    "eventVersion",
    "timestamp",
    "orgId",
    "caseId",
    "status",
    "previousStatus"
  ],
  "properties": {
    "event": { "type": "string", "const": "case.status.changed" },
    "eventId": { "type": "string", "format": "uuid" },
    "eventVersion": { "type": "integer", "const": 1 },
    "timestamp": { "type": "string", "format": "date-time" },
    "orgId": { "type": "string" },
    "crmRecordId": { "type": ["string", "null"] },
    "caseId": { "type": "string" },
    "companyName": { "type": ["string", "null"] },
    "status": { "type": "string", "description": "New status (e.g. \"approved\", \"declined\", \"pending_senior\", \"returned\")." },
    "previousStatus": { "type": ["string", "null"] },
    "changedBy": { "type": ["string", "null"], "description": "Email of the actor (analyst or customer)." },
    "recommendation": { "type": "string", "enum": ["approve", "decline", "refer"], "description": "Senior reviewer recommendation — only on returns from senior review." }
  }
}
