{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/postfleet-ai/json-schema/postfleet-ai-message-detail-schema.json",
  "title": "MessageDetail",
  "x-generated": "2026-11-21",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/postfleet-ai-openapi.json#/components/schemas/MessageDetail",
  "type": "object",
  "properties": {
    "id": {
      "type": "string"
    },
    "mailbox_id": {
      "type": "string"
    },
    "direction": {
      "type": "string",
      "enum": [
        "in",
        "out"
      ]
    },
    "provider_message_id": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ]
    },
    "rfc_message_id": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ]
    },
    "thread_id": {
      "type": "string"
    },
    "in_reply_to": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ]
    },
    "from_addr": {
      "type": "string"
    },
    "to_addr": {
      "type": "string"
    },
    "subject": {
      "type": "string",
      "description": "The sanitized subject (invisible/bidi characters stripped) — the value every delivery surface serves."
    },
    "subject_raw": {
      "description": "Pre-sanitization subject original. Purged on the same TTL as body_raw; null on messages that predate subject sanitization. Stripped from MCP reads, like body_raw.",
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ]
    },
    "body_raw": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ]
    },
    "body_clean": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ]
    },
    "truncated": {
      "type": "boolean"
    },
    "created_at": {
      "type": "string"
    },
    "comprehension": {
      "anyOf": [
        {
          "type": "object",
          "propertyNames": {
            "type": "string"
          },
          "additionalProperties": {}
        },
        {
          "type": "null"
        }
      ]
    },
    "attachments": {
      "type": "array",
      "items": {
        "type": "object",
        "propertyNames": {
          "type": "string"
        },
        "additionalProperties": {}
      }
    },
    "auth_results": {
      "anyOf": [
        {
          "type": "object",
          "properties": {
            "spf": {
              "type": "string",
              "enum": [
                "pass",
                "fail",
                "softfail",
                "neutral",
                "none",
                "temperror",
                "permerror"
              ]
            },
            "dkim": {
              "type": "string",
              "enum": [
                "pass",
                "fail",
                "softfail",
                "neutral",
                "none",
                "temperror",
                "permerror"
              ]
            },
            "dmarc": {
              "type": "string",
              "enum": [
                "pass",
                "fail",
                "softfail",
                "neutral",
                "none",
                "temperror",
                "permerror"
              ]
            }
          },
          "required": [
            "spf",
            "dkim",
            "dmarc"
          ],
          "additionalProperties": false
        },
        {
          "type": "null"
        }
      ],
      "description": "SPF/DKIM/DMARC verdicts from the inbound Authentication-Results header; null if none was forwarded."
    },
    "spam_risk": {
      "anyOf": [
        {
          "type": "string",
          "enum": [
            "low",
            "high",
            "error"
          ]
        },
        {
          "type": "null"
        }
      ],
      "description": "The layered spam verdict: 'high' from either the free SES x-ses-spam-verdict gate or the Haiku classifier reaching the same conclusion on SES-pass mail; 'low' cleared both; 'error' means the classifier failed and the message proceeded un-quarantined (availability over false quarantine). null when spam scoring never ran for this message."
    },
    "virus_risk": {
      "anyOf": [
        {
          "type": "string",
          "enum": [
            "low",
            "high"
          ]
        },
        {
          "type": "null"
        }
      ],
      "description": "The SES virus verdict from the free x-ses-virus-verdict gate: 'high' means SES flagged the message as malware — it is stored but never delivered (no deliver-toggle exists for malware); 'low' means SES cleared it; null when no verdict was forwarded."
    }
  },
  "required": [
    "id",
    "mailbox_id",
    "direction",
    "thread_id",
    "from_addr",
    "to_addr",
    "subject",
    "created_at",
    "auth_results",
    "spam_risk",
    "virus_risk"
  ],
  "additionalProperties": false
}