{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/usemektup-com/json-schema/usemektup-com-message-detail-schema.json",
  "title": "MessageDetail",
  "x-generated": "2026-11-27",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/usemektup-com-openapi.yaml#/components/schemas/MessageDetail",
  "allOf": [
    {
      "$ref": "#/$defs/MessageBase"
    },
    {
      "type": "object",
      "properties": {
        "thread_key": {
          "type": "string"
        },
        "text": {
          "type": [
            "string",
            "null"
          ]
        },
        "html": {
          "type": [
            "string",
            "null"
          ],
          "description": "Attacker-controlled content - sanitize and isolate before rendering, never render directly"
        },
        "attachments": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "filename": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "contentType": {
                "type": "string"
              },
              "size": {
                "type": "integer"
              }
            }
          }
        }
      }
    }
  ],
  "$defs": {
    "MessageBase": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "format": "uuid"
        },
        "direction": {
          "type": "string",
          "enum": [
            "inbound",
            "outbound"
          ]
        },
        "from_address": {
          "type": [
            "string",
            "null"
          ]
        },
        "to_address": {
          "type": [
            "string",
            "null"
          ]
        },
        "subject": {
          "type": [
            "string",
            "null"
          ]
        },
        "size_bytes": {
          "type": "integer"
        },
        "received_at": {
          "type": "string",
          "format": "date-time"
        },
        "read_at": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time"
        },
        "deleted_at": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time"
        },
        "flagged_at": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time"
        },
        "folder_id": {
          "type": [
            "string",
            "null"
          ],
          "format": "uuid"
        },
        "delivery_status": {
          "type": [
            "string",
            "null"
          ],
          "enum": [
            "sent",
            "deferred",
            "bounced",
            null
          ],
          "description": "Only ever populated for direction=outbound. null means either too recent to have a result yet, or delivered locally to another Mektup mailbox rather than over external SMTP."
        },
        "delivery_detail": {
          "type": [
            "string",
            "null"
          ],
          "description": "The real SMTP response text from the recipient's mail server (Mektup has no relayhost, so its own MTA does the delivery attempt directly) - not a synthesized summary."
        },
        "delivery_checked_at": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time"
        }
      }
    }
  }
}