{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://www.healthexport.dev/schemas/webhook/v1/common.json",
  "title": "MetricBridge webhook: shared definitions",
  "$defs": {
    "isoDay": {
      "type": "string",
      "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
      "description": "Local calendar day, YYYY-MM-DD."
    },
    "localDateTime": {
      "type": "string",
      "format": "date-time",
      "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(Z|[+-]\\d{2}:\\d{2})$",
      "description": "RFC 3339 instant WITH the UTC offset of the zone it was recorded in."
    },
    "haeDate": {
      "type": "string",
      "pattern": "^\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2} [+-]\\d{4}$",
      "description": "Health Auto Export date format: yyyy-MM-dd HH:mm:ss Z (device zone)."
    },
    "ianaZone": {
      "type": "string",
      "minLength": 1,
      "description": "IANA time zone identifier, e.g. Europe/London."
    },
    "typedDocument": {
      "type": "object",
      "description": "Top level shared by every typed document. data.metrics is always an empty array so a receiver written for the metrics envelope reads it as an empty update.",
      "required": ["type", "schema", "id", "app", "sentAt", "data"],
      "properties": {
        "type": { "type": "string" },
        "schema": { "const": 1 },
        "id": { "type": "string", "pattern": "^msg_", "description": "Same value as the webhook-id header." },
        "app": { "type": "string", "description": "App version that sent it." },
        "sentAt": { "type": "string", "format": "date-time" },
        "replay": { "type": "string", "pattern": "^rpl_", "description": "Present on a Resend; same as the X-MetricBridge-Replay header." },
        "data": {
          "type": "object",
          "required": ["metrics"],
          "properties": { "metrics": { "type": "array", "maxItems": 0 } }
        }
      }
    }
  }
}
