{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/mailfixture-com/json-schema/mailfixture-com-message-detail-schema.json",
  "title": "MessageDetail",
  "x-generated": "2026-11-17",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/mailfixture-com-openapi.json#/components/schemas/MessageDetail",
  "properties": {
    "attachments": {
      "items": {
        "$ref": "#/$defs/AttachmentMeta"
      },
      "type": "array"
    },
    "expires_at": {
      "description": "Retention expiry (plan retention from receipt).",
      "format": "date-time",
      "type": "string"
    },
    "extracted": {
      "$ref": "#/$defs/Extracted"
    },
    "from_addr": {
      "type": "string"
    },
    "headers": {
      "description": "All headers in source order, folding unfolded.",
      "items": {
        "$ref": "#/$defs/MessageHeader"
      },
      "type": "array"
    },
    "html_body": {
      "type": [
        "string",
        "null"
      ]
    },
    "id": {
      "format": "uuid",
      "type": "string"
    },
    "inbox_id": {
      "format": "uuid",
      "type": "string"
    },
    "raw_size": {
      "description": "Size of the raw MIME in bytes.",
      "type": "integer"
    },
    "received_at": {
      "format": "date-time",
      "type": "string"
    },
    "subject": {
      "type": [
        "string",
        "null"
      ]
    },
    "text_body": {
      "type": [
        "string",
        "null"
      ]
    },
    "tls": {
      "type": "boolean"
    },
    "to_addrs": {
      "items": {
        "type": "string"
      },
      "type": "array"
    }
  },
  "required": [
    "id",
    "inbox_id",
    "received_at",
    "from_addr",
    "to_addrs",
    "subject",
    "tls",
    "text_body",
    "html_body",
    "headers",
    "extracted",
    "attachments",
    "raw_size",
    "expires_at"
  ],
  "type": "object",
  "$defs": {
    "AttachmentMeta": {
      "properties": {
        "content_type": {
          "description": "Declared MIME type; defaults to application/octet-stream.",
          "type": "string"
        },
        "filename": {
          "type": [
            "string",
            "null"
          ]
        },
        "inline": {
          "description": "True for cid-referenced inline parts (e.g. embedded images).",
          "type": "boolean"
        },
        "size": {
          "description": "Decoded byte length.",
          "type": "integer"
        }
      },
      "required": [
        "filename",
        "content_type",
        "size",
        "inline"
      ],
      "type": "object"
    },
    "AuthResult": {
      "description": "RFC 8601 result vocabulary. DNS trouble degrades to `temperror`.",
      "enum": [
        "pass",
        "fail",
        "softfail",
        "neutral",
        "none",
        "temperror",
        "permerror"
      ],
      "type": "string"
    },
    "DkimAuth": {
      "properties": {
        "domain": {
          "type": "string"
        },
        "error": {
          "description": "Present only for non-pass results — e.g. a body-hash mismatch reports `neutral` with the reason here (RFC 6376 §6.1).",
          "type": "string"
        },
        "result": {
          "$ref": "#/$defs/AuthResult"
        },
        "selector": {
          "type": "string"
        }
      },
      "required": [
        "result",
        "domain",
        "selector"
      ],
      "type": "object"
    },
    "DmarcAuth": {
      "properties": {
        "domain": {
          "description": "RFC5322.From domain; present only when non-empty.",
          "type": "string"
        },
        "policy": {
          "description": "Present only when a DMARC record exists.",
          "enum": [
            "none",
            "quarantine",
            "reject"
          ],
          "type": "string"
        },
        "result": {
          "$ref": "#/$defs/AuthResult"
        }
      },
      "required": [
        "result"
      ],
      "type": "object"
    },
    "Extracted": {
      "description": "Extraction results computed at receipt. `text`, `auth`, and `spam` are conditionally present keys — see their descriptions.",
      "properties": {
        "auth": {
          "$ref": "#/$defs/ExtractedAuth"
        },
        "links": {
          "items": {
            "$ref": "#/$defs/ExtractedLink"
          },
          "type": "array"
        },
        "otp": {
          "$ref": "#/$defs/ExtractedOtp"
        },
        "spam": {
          "$ref": "#/$defs/ExtractedSpam"
        },
        "text": {
          "description": "Plain-text rendering of the HTML part; present only when the message had no text/plain part.",
          "type": "string"
        }
      },
      "required": [
        "otp",
        "links"
      ],
      "type": "object"
    },
    "ExtractedAuth": {
      "description": "Receive-side SPF/DKIM/DMARC verdicts (RFC 8601 vocabulary). The whole key is absent when verification is disabled on the deployment — absence means \"not verified\", never \"failed\". Observation only: verdicts never affect acceptance.",
      "properties": {
        "dkim": {
          "description": "One entry per DKIM signature; unsigned mail is an empty array.",
          "items": {
            "$ref": "#/$defs/DkimAuth"
          },
          "type": "array"
        },
        "dmarc": {
          "$ref": "#/$defs/DmarcAuth"
        },
        "spf": {
          "$ref": "#/$defs/SpfAuth"
        }
      },
      "required": [
        "spf",
        "dkim",
        "dmarc"
      ],
      "type": "object"
    },
    "ExtractedLink": {
      "properties": {
        "class": {
          "description": "Class guess from URL path + anchor keywords; magic-link/login URLs class as `verify`.",
          "enum": [
            "verify",
            "reset",
            "unsubscribe",
            "other"
          ],
          "type": "string"
        },
        "text": {
          "description": "Anchor text; null for bare-text URLs.",
          "type": [
            "string",
            "null"
          ]
        },
        "url": {
          "type": "string"
        }
      },
      "required": [
        "url",
        "text",
        "class"
      ],
      "type": "object"
    },
    "ExtractedOtp": {
      "properties": {
        "best": {
          "description": "Top-ranked code, or null when no candidate scores above the confidence threshold.",
          "type": [
            "string",
            "null"
          ]
        },
        "candidates": {
          "description": "At most 5, sorted by descending score.",
          "items": {
            "$ref": "#/$defs/OtpCandidate"
          },
          "type": "array"
        }
      },
      "required": [
        "best",
        "candidates"
      ],
      "type": "object"
    },
    "ExtractedSpam": {
      "description": "SpamAssassin content analysis (local rules only — no network/RBL tests, so scores are deterministic). The whole key is absent when scoring is disabled, the daemon was unreachable, or the message exceeded the scoring size cap — absence means \"not scored\", never \"failed\". Observation only: the verdict never affects acceptance.",
      "properties": {
        "rules": {
          "description": "The rules that fired, with their individual score contributions; empty when nothing matched.",
          "items": {
            "$ref": "#/$defs/SpamRule"
          },
          "type": "array"
        },
        "score": {
          "description": "Total SpamAssassin score; higher is spammier. May be negative.",
          "type": "number"
        },
        "threshold": {
          "description": "The score at or above which the message is classed spam (default 5.0).",
          "type": "number"
        },
        "verdict": {
          "description": "SpamAssassin's own decision (its `Spam: True/False`), not a client-side threshold recomputation.",
          "enum": [
            "spam",
            "ham"
          ],
          "type": "string"
        }
      },
      "required": [
        "score",
        "threshold",
        "verdict",
        "rules"
      ],
      "type": "object"
    },
    "MessageHeader": {
      "properties": {
        "name": {
          "type": "string"
        },
        "value": {
          "type": "string"
        }
      },
      "required": [
        "name",
        "value"
      ],
      "type": "object"
    },
    "OtpCandidate": {
      "properties": {
        "score": {
          "description": "Keyword-proximity score, one decimal.",
          "type": "number"
        },
        "value": {
          "description": "The digit sequence.",
          "type": "string"
        }
      },
      "required": [
        "value",
        "score"
      ],
      "type": "object"
    },
    "SpamRule": {
      "properties": {
        "description": {
          "description": "Human-readable rule description, when spamd supplied one.",
          "type": [
            "string",
            "null"
          ]
        },
        "name": {
          "description": "SpamAssassin rule symbol, e.g. `MISSING_HEADERS`.",
          "type": "string"
        },
        "score": {
          "description": "This rule's contribution to the total; may be negative.",
          "type": "number"
        }
      },
      "required": [
        "name",
        "score"
      ],
      "type": "object"
    },
    "SpfAuth": {
      "properties": {
        "domain": {
          "description": "The identity checked (MAIL FROM, falling back to HELO); may be empty.",
          "type": "string"
        },
        "result": {
          "$ref": "#/$defs/AuthResult"
        }
      },
      "required": [
        "result",
        "domain"
      ],
      "type": "object"
    }
  }
}