{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/conduyt-com/json-schema/conduyt-com-message-schema.json",
  "title": "Message",
  "description": "The persisted message row. The database record carries additional bookkeeping columns beyond those listed here.",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/conduyt-com-email-api-openapi.yml#/components/schemas/Message",
  "type": "object",
  "properties": {
    "id": {
      "type": "string",
      "format": "uuid"
    },
    "accountId": {
      "type": "string",
      "format": "uuid"
    },
    "contactId": {
      "type": "string",
      "format": "uuid"
    },
    "direction": {
      "type": "string",
      "enum": [
        "inbound",
        "outbound"
      ]
    },
    "channel": {
      "type": "string",
      "enum": [
        "sms",
        "email"
      ]
    },
    "subject": {
      "type": [
        "string",
        "null"
      ]
    },
    "body": {
      "type": "string"
    },
    "bodyHtml": {
      "type": [
        "string",
        "null"
      ]
    },
    "fromNumber": {
      "type": [
        "string",
        "null"
      ]
    },
    "toNumber": {
      "type": [
        "string",
        "null"
      ]
    },
    "fromEmail": {
      "type": [
        "string",
        "null"
      ]
    },
    "toEmail": {
      "type": [
        "string",
        "null"
      ]
    },
    "replyTo": {
      "type": [
        "string",
        "null"
      ],
      "description": "The Reply-To address used for this send (email only)."
    },
    "provider": {
      "type": [
        "string",
        "null"
      ],
      "description": "The delivery provider, e.g. \"resend\"."
    },
    "providerId": {
      "type": [
        "string",
        "null"
      ],
      "description": "The provider's id for this send, once accepted."
    },
    "sentBy": {
      "type": [
        "string",
        "null"
      ],
      "format": "uuid",
      "description": "The user who sent this message, when sent by a human/API caller rather than an automation."
    },
    "status": {
      "type": "string"
    },
    "deliveredAt": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "openedAt": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "clickedAt": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "openCount": {
      "type": "integer"
    },
    "clickCount": {
      "type": "integer"
    },
    "scheduledAt": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time",
      "description": "Always null for this endpoint — POST /email/send has no scheduling field and never sets it."
    },
    "createdAt": {
      "type": "string",
      "format": "date-time"
    },
    "updatedAt": {
      "type": "string",
      "format": "date-time"
    }
  }
}