{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/agentline-nz/json-schema/agentline-nz-email-schema.json",
  "title": "Email",
  "x-generated": "2026-11-01",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/_original/agentline-nz-api-openapi.json#/components/schemas/Email",
  "allOf": [
    {
      "$ref": "#/$defs/EmailSummary"
    },
    {
      "type": "object",
      "required": [
        "text",
        "html",
        "messageId",
        "inReplyTo",
        "attachments"
      ],
      "properties": {
        "text": {
          "type": [
            "string",
            "null"
          ]
        },
        "html": {
          "type": [
            "string",
            "null"
          ]
        },
        "messageId": {
          "type": [
            "string",
            "null"
          ]
        },
        "inReplyTo": {
          "type": [
            "string",
            "null"
          ]
        },
        "attachments": {
          "type": "array",
          "items": {
            "type": "object",
            "required": [
              "filename",
              "mimeType",
              "size"
            ],
            "properties": {
              "filename": {
                "type": "string"
              },
              "mimeType": {
                "type": "string"
              },
              "size": {
                "type": "integer"
              }
            }
          }
        }
      }
    }
  ],
  "$defs": {
    "EmailSummary": {
      "type": "object",
      "required": [
        "id",
        "direction",
        "from",
        "to",
        "subject",
        "snippet",
        "code",
        "status",
        "read",
        "hasAttachments",
        "createdAt"
      ],
      "properties": {
        "id": {
          "type": "string"
        },
        "direction": {
          "type": "string",
          "enum": [
            "in",
            "out"
          ]
        },
        "from": {
          "type": "string"
        },
        "to": {
          "type": "string"
        },
        "subject": {
          "type": [
            "string",
            "null"
          ]
        },
        "snippet": {
          "type": [
            "string",
            "null"
          ],
          "description": "First 280 characters of the text body."
        },
        "code": {
          "type": [
            "string",
            "null"
          ],
          "description": "One-time code detected in the email, if any."
        },
        "status": {
          "type": "string"
        },
        "read": {
          "type": "boolean"
        },
        "hasAttachments": {
          "type": "boolean"
        },
        "createdAt": {
          "type": "string",
          "format": "date-time"
        }
      }
    }
  }
}