{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/cherami-to/json-schema/cherami-to-create-draft-schema.json",
  "title": "CreateDraft",
  "x-generated": "2026-11-03",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/cherami-to-openapi.yml#/components/schemas/CreateDraft",
  "type": "object",
  "properties": {
    "to": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/Mailbox"
      },
      "maxItems": 50
    },
    "cc": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/Mailbox"
      },
      "maxItems": 50
    },
    "bcc": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/Mailbox"
      },
      "maxItems": 50
    },
    "subject": {
      "type": "string",
      "description": "No control characters; at most 998 UTF-8 bytes.",
      "x-max-utf8-bytes": 998
    },
    "text": {
      "type": "string",
      "description": "Plain-text body."
    },
    "html": {
      "anyOf": [
        {
          "type": "string",
          "description": "HTML alternative, sent as supplied."
        },
        {
          "type": "null"
        }
      ],
      "description": "HTML alternative, sent as supplied; null means none."
    },
    "attachments": {
      "anyOf": [
        {
          "type": "array",
          "items": {
            "$ref": "#/$defs/AttachmentInput"
          },
          "maxItems": 32
        },
        {
          "type": "null"
        }
      ],
      "description": "Omitted, null or [] means no attachments."
    },
    "in_reply_to": {
      "anyOf": [
        {
          "type": "string",
          "description": "ID of a ready received message or an accepted sent message in this inbox that has a Message-ID header.",
          "pattern": "^[a-f0-9-]{36}$"
        },
        {
          "type": "null"
        }
      ],
      "description": "ID of a ready received message or an accepted sent message in this inbox that has a Message-ID header; null means none."
    },
    "labels": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/Label"
      },
      "maxItems": 32,
      "description": "Label names, case-sensitive; order and duplicates don't matter."
    },
    "idempotency_key": {
      "type": "string",
      "description": "Your unique value for this one operation. Save it with the exact request before sending; repeating that request with the same key within 24 hours returns what the first one did instead of acting again.",
      "pattern": "^[A-Za-z0-9_-]{1,128}$"
    },
    "source": {
      "oneOf": [
        {
          "type": "object",
          "properties": {
            "action": {
              "type": "string",
              "enum": [
                "reply",
                "reply-all"
              ]
            },
            "message_id": {
              "type": "string",
              "description": "ID of a ready received message or an accepted sent message in this inbox.",
              "pattern": "^[a-f0-9-]{36}$"
            }
          },
          "required": [
            "action",
            "message_id"
          ],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "action": {
              "const": "forward"
            },
            "message_id": {
              "type": "string",
              "description": "ID of a ready received message or an accepted sent message in this inbox.",
              "pattern": "^[a-f0-9-]{36}$"
            },
            "include_attachments": {
              "type": "boolean",
              "default": true,
              "description": "false leaves out every original file, embedded images included."
            }
          },
          "required": [
            "action",
            "message_id"
          ],
          "additionalProperties": false
        }
      ],
      "description": "Fills in the draft once, at creation, as a reply, reply-all or forward of message_id."
    }
  },
  "required": [],
  "additionalProperties": false,
  "$defs": {
    "AttachmentInput": {
      "type": "object",
      "properties": {
        "filename": {
          "type": "string",
          "description": "At most 255 UTF-8 bytes, without control characters, slashes or backslashes.",
          "minLength": 1,
          "x-max-utf8-bytes": 255
        },
        "type": {
          "type": "string",
          "description": "MIME type without parameters.",
          "maxLength": 127,
          "pattern": "^[A-Za-z0-9!#$&^_.+-]+/[A-Za-z0-9!#$&^_.+-]+$"
        },
        "content": {
          "type": "string",
          "description": "The file's bytes as padded base64, without line breaks.",
          "contentEncoding": "base64",
          "pattern": "^[A-Za-z0-9+/]*={0,2}$"
        }
      },
      "required": [
        "filename",
        "type",
        "content"
      ],
      "additionalProperties": false
    },
    "Label": {
      "type": "string",
      "description": "1–128 UTF-8 bytes after trimming, without control characters; case-sensitive.",
      "x-max-utf8-bytes": 128
    },
    "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
    }
  }
}