{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://www.firstmilelabs.com/schemas/webhooks/case.created.v1.json",
  "title": "FirstMileLabs Outbound Webhook — case.created (v1)",
  "description": "Emitted when a new case is opened (manual analyst creation, customer document upload, or application form submission). See https://www.firstmilelabs.com/docs/webhooks#events for context.",
  "type": "object",
  "additionalProperties": true,
  "required": [
    "event",
    "eventId",
    "eventVersion",
    "timestamp",
    "orgId",
    "caseId",
    "source"
  ],
  "properties": {
    "event": { "type": "string", "const": "case.created" },
    "eventId": { "type": "string", "format": "uuid", "description": "Stable across retries and manual redelivery — use as your idempotency key." },
    "eventVersion": { "type": "integer", "const": 1 },
    "timestamp": { "type": "string", "format": "date-time" },
    "orgId": { "type": "string" },
    "crmRecordId": { "type": ["string", "null"], "description": "Echoes back whatever your CRM stored on the case via POST /api/cases/:caseId/crm-record-id." },
    "caseId": { "type": "string", "description": "First Mile Labs case identifier (e.g. CS-2026-00471)." },
    "companyName": { "type": ["string", "null"] },
    "companyNumber": { "type": ["string", "null"], "description": "Registry number when collected." },
    "country": { "type": ["string", "null"], "description": "ISO country / jurisdiction of the subject company." },
    "customerEmail": { "type": ["string", "null"] },
    "source": { "type": "string", "enum": ["manual", "doc_upload", "application_form"] },
    "createdBy": { "type": "string", "description": "Analyst email — only present on manual creation." }
  }
}
