{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/cherami-to/json-schema/cherami-to-trash-entry-schema.json",
  "title": "TrashEntry",
  "description": "A deleted message that can still be restored; kind picks the restore endpoint. from is null for a received message that never became ready.",
  "x-generated": "2026-11-03",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/cherami-to-openapi.yml#/components/schemas/TrashEntry",
  "oneOf": [
    {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "description": "Cherami resource ID."
        },
        "kind": {
          "const": "received"
        },
        "inbox_id": {
          "type": "string",
          "description": "Cherami resource ID."
        },
        "subject": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "from": {
          "anyOf": [
            {
              "$ref": "#/$defs/ParsedAddress"
            },
            {
              "type": "null"
            }
          ]
        },
        "envelope_from": {
          "type": "string",
          "description": "SMTP sender; can be a bounce address."
        },
        "deleted_at": {
          "type": "string",
          "description": "UTC timestamp with milliseconds.",
          "format": "date-time",
          "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{3}Z$"
        },
        "restorable_until": {
          "type": "string",
          "description": "Seven days after deleted_at; the message can't be restored after it.",
          "format": "date-time",
          "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{3}Z$"
        }
      },
      "required": [
        "id",
        "kind",
        "inbox_id",
        "subject",
        "from",
        "envelope_from",
        "deleted_at",
        "restorable_until"
      ]
    },
    {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "description": "Cherami resource ID."
        },
        "kind": {
          "const": "sent"
        },
        "inbox_id": {
          "type": "string",
          "description": "Cherami resource ID."
        },
        "subject": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "to": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/Mailbox"
          }
        },
        "deleted_at": {
          "type": "string",
          "description": "UTC timestamp with milliseconds.",
          "format": "date-time",
          "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{3}Z$"
        },
        "restorable_until": {
          "type": "string",
          "description": "Seven days after deleted_at; the message can't be restored after it.",
          "format": "date-time",
          "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{3}Z$"
        }
      },
      "required": [
        "id",
        "kind",
        "inbox_id",
        "subject",
        "to",
        "deleted_at",
        "restorable_until"
      ]
    }
  ],
  "$defs": {
    "Mailbox": {
      "type": "object",
      "properties": {
        "address": {
          "type": "string",
          "description": "Bare address such as alex@example.com: ASCII, at most 254 characters and 64 before the @.",
          "maxLength": 254
        },
        "name": {
          "type": "string",
          "description": "Optional name; blank means none. At most 256 UTF-8 bytes after trimming, without control characters.",
          "x-max-utf8-bytes": 256
        }
      },
      "required": [
        "address"
      ],
      "additionalProperties": false
    },
    "ParsedAddress": {
      "oneOf": [
        {
          "type": "object",
          "properties": {
            "name": {
              "type": "string"
            },
            "address": {
              "type": "string"
            }
          },
          "required": [
            "name",
            "address"
          ]
        },
        {
          "type": "object",
          "properties": {
            "name": {
              "type": "string"
            },
            "group": {
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string"
                  },
                  "address": {
                    "type": "string"
                  }
                },
                "required": [
                  "name",
                  "address"
                ]
              }
            }
          },
          "required": [
            "name",
            "group"
          ]
        }
      ],
      "description": "Mailbox or group from the message headers, written by the sender and not verified."
    }
  }
}