{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/openmail-sh/json-schema/openmail-sh-message-schema.json",
  "title": "Message",
  "x-generated": "2026-10-31",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/openmail-sh-openapi.json#/components/schemas/Message",
  "type": "object",
  "additionalProperties": true,
  "properties": {
    "id": {
      "type": "string"
    },
    "threadId": {
      "type": "string"
    },
    "direction": {
      "$ref": "#/$defs/MessageDirection"
    },
    "fromAddr": {
      "type": "string"
    },
    "toAddr": {
      "type": "string",
      "description": "Your OpenMail inbox address for inbound messages. For outbound sends, the primary recipient."
    },
    "headerTo": {
      "type": [
        "string",
        "null"
      ],
      "description": "Inbound only. The address the sender wrote to (comma-separated if multiple). When deliveryRole is cc, reply to this address — not fromAddr."
    },
    "deliveryRole": {
      "type": [
        "string",
        "null"
      ],
      "enum": [
        "to",
        "cc",
        null
      ],
      "description": "Inbound only. to if your inbox was the main recipient; cc if you were copied on the email."
    },
    "cc": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "Email addresses copied on the message."
    },
    "addressNames": {
      "type": [
        "object",
        "null"
      ],
      "additionalProperties": {
        "type": "string"
      },
      "description": "Inbound only. Display names the sender's mail client put on From, To and Cc, keyed by lower-cased address, e.g. `{\"alice@example.com\": \"Alice Smith\"}`. Address fields stay bare so you can match on them. Null when the headers carried no names."
    },
    "bcc": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "Blind-copy recipients on outbound mail sent from this inbox. Empty on inbound. Not included in the copy delivered to To or Cc."
    },
    "subject": {
      "type": "string"
    },
    "bodyText": {
      "type": "string"
    },
    "bodyHtml": {
      "type": "string"
    },
    "attachments": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": true,
        "properties": {
          "filename": {
            "type": "string"
          },
          "contentType": {
            "type": "string"
          },
          "sizeBytes": {
            "type": "integer"
          },
          "url": {
            "type": "string",
            "description": "Signed URL for download"
          }
        }
      }
    },
    "rawUrl": {
      "type": [
        "string",
        "null"
      ],
      "description": "URL of the original RFC 822 message (GET /v1/messages/{id}/raw). null when the bytes weren't kept."
    },
    "status": {
      "type": "string",
      "enum": [
        "pending",
        "sent",
        "received",
        "failed"
      ]
    },
    "createdAt": {
      "type": "string",
      "format": "date-time"
    }
  },
  "$defs": {
    "MessageDirection": {
      "type": "string",
      "enum": [
        "inbound",
        "outbound"
      ]
    }
  }
}