{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://developers.impel.ai/specs/partner-data-share/v1/message.schema.json",
  "title": "message event",
  "description": "One SMS or email exchanged between a dealer and a consumer, in either direction.",
  "type": "object",
  "required": [
    "event_type",
    "event_timestamp",
    "event_id",
    "client_key",
    "consumer_key",
    "message",
    "metadata"
  ],
  "properties": {
    "event_type": {
      "description": "Always `message` for this event.",
      "type": "string",
      "const": "message"
    },
    "event_timestamp": {
      "description": "When the message was sent or received, in UTC with second precision.",
      "type": "string",
      "format": "date-time",
      "examples": [
        "2026-09-14T15:02:11Z"
      ]
    },
    "event_id": {
      "description": "Stable identifier for this event. It never changes across retries or the history file, so use it to deduplicate.",
      "type": "string",
      "format": "uuid",
      "examples": [
        "7f6efcd5-3151-5c6f-a502-bd56256b6527"
      ]
    },
    "client_key": {
      "description": "Impel's identifier for the dealer.",
      "type": "string",
      "examples": [
        "EXAMPLEDEALER"
      ]
    },
    "consumer_key": {
      "description": "Impel's identifier for the consumer. Unique within a dealer only, so key consumers on `client_key` plus `consumer_key`.",
      "type": "string",
      "examples": [
        "CONSUMER-001"
      ]
    },
    "message": {
      "description": "The message itself.",
      "type": "object",
      "required": [
        "direction"
      ],
      "properties": {
        "conversation_id": {
          "description": "Identifies the conversation thread. Present on every inbound message; can be absent on an outbound one.",
          "type": "string",
          "examples": [
            "6cac7467-7e3b-42ba-83bc-dc163a95bb36"
          ]
        },
        "opportunity_id": {
          "description": "Impel's identifier for the lead the conversation belongs to.",
          "type": "string",
          "examples": [
            "9dca0816-4fd7-4a80-a238-3d5c5b928c50"
          ]
        },
        "source_system": {
          "description": "The Impel product the message belongs to. On an outbound message, it's the product that sent it; on an inbound reply, it's the product whose conversation the consumer is replying to. Current values are `lead_nurture` and `voice_ai`; more products can be enabled later, so expect new values.",
          "type": "string",
          "examples": [
            "lead_nurture"
          ]
        },
        "direction": {
          "description": "`outbound` is dealer to consumer; `inbound` is the consumer's reply.",
          "type": "string",
          "enum": [
            "outbound",
            "inbound"
          ],
          "examples": [
            "outbound"
          ]
        },
        "channel": {
          "description": "Delivery channel, lowercase. Today this is `sms` or `email`.",
          "type": "string",
          "examples": [
            "sms"
          ]
        },
        "sent_by": {
          "description": "Who wrote the message. Outbound: `AI`, `Human` (dealer staff) or `System`, and absent when unknown. Inbound: always `Consumer`. New values can appear.",
          "type": "string",
          "examples": [
            "AI"
          ]
        },
        "sender_contact": {
          "description": "Phone number or email address the message was sent from: the dealer's on outbound, the consumer's on inbound.",
          "type": "string",
          "examples": [
            "+15555550100"
          ]
        },
        "receiver_contact": {
          "description": "Phone number or email address the message was sent to.",
          "type": "string",
          "examples": [
            "+15555550123"
          ]
        },
        "subject": {
          "description": "Email subject line. Absent on SMS.",
          "type": "string",
          "examples": [
            "Your test drive at Example Motors"
          ]
        },
        "body": {
          "description": "Message content as sent: plain text for SMS, usually HTML for email.",
          "type": "string",
          "examples": [
            "Hi, thanks for your interest in the vehicle you asked about. Would Saturday morning work for a test drive?"
          ]
        },
        "body_text": {
          "description": "Plain-text version of the content, with no markup. Identical to `body` for SMS; can be absent on inbound email.",
          "type": "string",
          "examples": [
            "Hi, thanks for your interest in the vehicle you asked about. Would Saturday morning work for a test drive?"
          ]
        }
      }
    },
    "metadata": {
      "description": "Identifiers on your side.",
      "type": "object",
      "required": [
        "source_client_key"
      ],
      "properties": {
        "source_client_key": {
          "description": "Your dealer code for this dealer, as registered with Impel during onboarding.",
          "type": "string",
          "examples": [
            "DEALER-001"
          ]
        }
      }
    }
  }
}
