{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://massaccess.net/contracts/message.inbound.v1.schema.json",
  "title": "MassAccess message.inbound v1",
  "description": "Text message received from a confirmed client through an active company bot.",
  "type": "object",
  "additionalProperties": false,
  "required": ["event", "event_version", "event_id", "timestamp", "data"],
  "properties": {
    "event": {"const": "message.inbound"},
    "event_version": {"type": "integer", "const": 1},
    "event_id": {
      "type": "string",
      "format": "uuid",
      "description": "Stable UUID idempotency key derived from the internal ingress identity."
    },
    "timestamp": {
      "type": "string",
      "format": "date-time",
      "description": "UTC time at which MassAccess created the customer event."
    },
    "data": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "service",
        "bot_name",
        "phone_number",
        "text"
      ],
      "properties": {
        "service": {"type": "string", "enum": ["telegram", "max"]},
        "bot_name": {"type": "string", "minLength": 1},
        "phone_number": {"type": "string", "minLength": 1},
        "text": {
          "type": "string",
          "minLength": 1,
          "maxLength": 4096,
          "description": "Original UTF-8 text, counted as Unicode scalar values and never silently truncated."
        }
      }
    }
  }
}
