{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/doorloop/json-schema/doorloop-communication-schema.json",
  "title": "communication",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/doorloop-communications-api-openapi.yml#/components/schemas/communication",
  "x-stoplight": {
    "id": "uzdwlgssgn5lz"
  },
  "type": "object",
  "properties": {
    "id": {
      "$ref": "#/$defs/mongoId"
    },
    "subject": {
      "type": "string",
      "maxLength": 255
    },
    "bodyHtml": {
      "type": "string",
      "description": "For performance reasons, bodyHtml will only be returned when retrieving a single communication"
    },
    "bodyPreview": {
      "type": "string",
      "maxLength": 255
    },
    "from": {
      "$ref": "#/$defs/communicationParticipant"
    },
    "to": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/communicationParticipant"
      }
    },
    "cc": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/communicationParticipant"
      }
    },
    "bcc": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/communicationParticipant"
      }
    },
    "sentAt": {
      "type": "number"
    },
    "type": {
      "type": "string",
      "enum": [
        "EMAIL",
        "PHONE",
        "TEXT"
      ]
    },
    "threadId": {
      "type": "string",
      "maxLength": 255
    },
    "externalId": {
      "type": "string",
      "maxLength": 255
    },
    "openedAt": {
      "type": "array",
      "items": {
        "type": "number"
      }
    },
    "clickedAt": {
      "type": "array",
      "items": {
        "type": "number"
      }
    },
    "bouncedAt": {
      "type": "array",
      "items": {
        "type": "number"
      }
    },
    "status": {
      "type": "string",
      "enum": [
        "DRAFT",
        "FAILED",
        "BOUNCED",
        "COMPLAINT",
        "SENT",
        "DELIVERED",
        "OPENED",
        "CLICKED"
      ]
    },
    "announcement": {
      "$ref": "#/$defs/mongoId"
    }
  },
  "required": [
    "subject",
    "from",
    "sentAt",
    "type",
    "status"
  ],
  "$defs": {
    "communicationParticipant": {
      "title": "communicationParticipant",
      "x-stoplight": {
        "id": "r0qslo7h1ax6g"
      },
      "type": "object",
      "properties": {
        "displayName": {
          "type": "string"
        },
        "address": {
          "type": "string"
        },
        "linkedToType": {
          "type": "string",
          "enum": [
            "USER",
            "TENANT",
            "OWNER",
            "VENDOR",
            "SYSTEM"
          ]
        },
        "linkedToId": {
          "$ref": "#/$defs/mongoId"
        }
      },
      "required": [
        "address",
        "linkedToType",
        "linkedToId"
      ]
    },
    "mongoId": {
      "type": "string",
      "title": "mongoId",
      "x-stoplight": {
        "id": "40j7qlmpihfdj"
      },
      "pattern": "/^[a-f\\d]{24}$/i"
    }
  }
}