{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://raw.githubusercontent.com/api-evangelist/emailconnect/main/json-schema/emailconnect-email-log-schema.json",
  "title": "EmailLog",
  "x-generated": "2026-10-16",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/emailconnect-openapi.json#/components/schemas/EmailLog",
  "type": "object",
  "properties": {
    "id": {
      "type": "string"
    },
    "messageId": {
      "type": "string",
      "description": "The RFC 5322 Message-ID chosen by the sender, as stored."
    },
    "fromAddress": {
      "type": "string"
    },
    "toAddresses": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "subject": {
      "type": [
        "string",
        "null"
      ]
    },
    "deliveryStatus": {
      "type": "string",
      "enum": [
        "PENDING",
        "DELIVERED",
        "FAILED",
        "RETRYING",
        "EXPIRED",
        "REJECTED"
      ]
    },
    "deliveryAttempts": {
      "type": "integer"
    },
    "lastAttemptAt": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "deliveredAt": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "errorMessage": {
      "type": [
        "string",
        "null"
      ]
    },
    "createdAt": {
      "type": "string",
      "format": "date-time"
    },
    "expiresAt": {
      "type": "string",
      "format": "date-time"
    },
    "isTestWebhook": {
      "type": "boolean"
    },
    "webhookPayload": {
      "type": [
        "object",
        "null"
      ],
      "additionalProperties": true,
      "description": "The payload as stored at ingest, in the shape of that time. Null when none was stored. For rejected mail it is the parsed message with internal `_rejection*` fields, before the alias filters and the payload template were applied. A replay re-sends it as stored. Data-residency messages hold a marker payload without the body."
    },
    "httpStatus": {
      "type": [
        "integer",
        "null"
      ],
      "description": "HTTP response status from webhook delivery"
    },
    "domain": {
      "type": [
        "object",
        "null"
      ],
      "properties": {
        "id": {
          "type": "string"
        },
        "domain": {
          "type": "string"
        }
      }
    },
    "alias": {
      "type": [
        "object",
        "null"
      ],
      "properties": {
        "id": {
          "type": "string"
        },
        "email": {
          "type": "string"
        },
        "webhook": {
          "type": [
            "object",
            "null"
          ],
          "properties": {
            "id": {
              "type": "string"
            },
            "name": {
              "type": "string"
            },
            "url": {
              "type": "string",
              "format": "uri"
            }
          }
        }
      }
    },
    "webhook": {
      "type": [
        "object",
        "null"
      ],
      "description": "Direct webhook relationship for test webhooks",
      "properties": {
        "id": {
          "type": "string"
        },
        "name": {
          "type": "string"
        },
        "url": {
          "type": "string",
          "format": "uri"
        }
      }
    }
  },
  "required": [
    "id",
    "messageId",
    "fromAddress",
    "toAddresses",
    "deliveryStatus",
    "deliveryAttempts",
    "createdAt",
    "expiresAt"
  ]
}