{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/insuremo-com/json-schema/insuremo-com-comm-task-submit-request-schema.json",
  "title": "CommTaskSubmitRequest",
  "description": "Submit envelope with caller-defined business Payload and typed attachment inputs. TraceId is captured from the request context, not supplied in this body.",
  "x-generated": "2026-12-02",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/insuremo-com-connecthub-openapi.yml#/components/schemas/CommTaskSubmitRequest",
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "Attachments": {
      "type": "array",
      "description": "Uploaded FileIds or authorized typed DMS references, total count limited by comm-hub.attachment.max-files (default 5). SlotKey selects the declared group; unique FileKey identifies each member. A required slot needs at least one eligible authorized member. Required attachments of enabled, condition-matched Bindings must be available before Task acceptance; missing required inputs reject submission without creating a Task or Execution. WithFiles accepts Files[FileKey] binary parts in place of FileId. CLOUD_DISK is declared but fails closed until native object authorization is connected.",
      "items": {
        "$ref": "#/$defs/CommAttachmentInput"
      }
    },
    "CustomerId": {
      "type": "string",
      "description": "Optional explicit customer timeline anchor, distinct from RecipientId.",
      "maxLength": 64
    },
    "DefinitionCode": {
      "type": "string",
      "description": "Code of an enabled communication definition.",
      "maxLength": 60
    },
    "ExecuteAt": {
      "type": "string",
      "description": "Optional tenant-local date-time without offset or zone. Midnight may use the platform date-only form. Messages materialize immediately but stay SCHEDULED until this time; past times dispatch immediately. DST gaps and overlaps are rejected. The resolved UTC deadline is frozen at acceptance. Offset-free local date/time. The platform wire format can use yyyy-MM-dd at midnight, yyyy-MM-ddTHH:mm or yyyy-MM-ddTHH:mm:ss[.fraction]; no offset is embedded. Apply the field-specific time-zone semantics. Offset-free local date/time. The platform wire format can use yyyy-MM-dd at midnight, yyyy-MM-ddTHH:mm or yyyy-MM-ddTHH:mm:ss[.fraction]; no offset is embedded. Apply the field-specific time-zone semantics."
    },
    "ExpiresAt": {
      "type": "string",
      "description": "Optional ISO-8601 TTL deadline with the same local-time and DST rules as ExecuteAt. Messages not yet dispatched past this time become EXPIRED and are never sent; must be later than ExecuteAt when both are supplied. Offset-free local date/time. The platform wire format can use yyyy-MM-dd at midnight, yyyy-MM-ddTHH:mm or yyyy-MM-ddTHH:mm:ss[.fraction]; no offset is embedded. Apply the field-specific time-zone semantics. Offset-free local date/time. The platform wire format can use yyyy-MM-dd at midnight, yyyy-MM-ddTHH:mm or yyyy-MM-ddTHH:mm:ss[.fraction]; no offset is embedded. Apply the field-specific time-zone semantics."
    },
    "InputFiles": {
      "type": "array",
      "description": "Existing authorized DMS input files for ARCHIVE-only DOCUMENT services. Inapplicable to DELIVERY and DOCUMENT services that generate new output. Maximum 20; no file bytes or URLs.",
      "items": {
        "$ref": "#/$defs/CommDocumentInputFile"
      }
    },
    "OriginalTaskId": {
      "type": "integer",
      "format": "int64",
      "description": "Optional tenant-local original task for a new business submission. Supply fresh Payload and a new RequestId; this link does not retry or copy the original task.",
      "minimum": 1
    },
    "Payload": {
      "type": "object",
      "additionalProperties": true,
      "description": "Arbitrary business JSON object, at most 64 KiB when serialized. Multiple caller-defined root keys are allowed; no strict product schema is imposed. Context selectors extract shared typed variables. System routing fields, recipients and attachment references belong in the envelope. Omitted/null is treated as an empty object."
    },
    "Recipients": {
      "type": "array",
      "description": "Optional explicit recipients for REQUEST rules. Omitted/null is an empty list; CONTEXT rules resolve their recipients from declared variables.",
      "items": {
        "$ref": "#/$defs/CommTaskRecipient"
      }
    },
    "RefNumber": {
      "type": "string",
      "description": "Optional caller-defined business reference number.",
      "maxLength": 60
    },
    "RefType": {
      "type": "string",
      "description": "Optional caller-defined business reference type.",
      "maxLength": 30
    },
    "RequestId": {
      "type": "string",
      "description": "Tenant-local idempotency key. Repeating the same key and equivalent content replays the result; changing content conflicts.",
      "maxLength": 64
    },
    "SenderApp": {
      "type": "string",
      "description": "Optional name of the calling application for traceability.",
      "maxLength": 60
    }
  },
  "required": [
    "DefinitionCode",
    "RequestId"
  ],
  "$defs": {
    "CommAttachmentInput": {
      "type": "object",
      "additionalProperties": false,
      "description": "FileKey and Source plus exactly its matching descriptor. External references select current bytes when a new delivery Attempt is prepared.",
      "properties": {
        "CloudDisk": {
          "$ref": "#/$defs/CommCloudDiskAttachmentReference"
        },
        "Dms": {
          "$ref": "#/$defs/CommDmsAttachmentReference"
        },
        "FileId": {
          "type": "integer",
          "format": "int64",
          "description": "UPLOAD only: READY immutable file owned by the submitting caller. WithFiles may instead provide Files[FileKey].",
          "minimum": 1
        },
        "FileKey": {
          "type": "string",
          "maxLength": 60,
          "pattern": "[A-Za-z][A-Za-z0-9_]{0,59}"
        },
        "FileName": {
          "type": "string",
          "description": "Optional effective attachment file name override.",
          "maxLength": 300
        },
        "RoleFilter": {
          "type": "string",
          "description": "Optional comma-separated recipient roles; blank applies to all roles.",
          "maxLength": 200
        },
        "SlotKey": {
          "type": [
            "string",
            "null"
          ],
          "description": "Declared slot membership. Omission or null uses FileKey; FileKey remains the unique per-file identity for multipart and downloads.",
          "maxLength": 60,
          "pattern": "[A-Za-z][A-Za-z0-9_]{0,59}"
        },
        "Source": {
          "type": "string",
          "enum": [
            "UPLOAD",
            "DMS",
            "CLOUD_DISK"
          ]
        }
      },
      "required": [
        "FileKey",
        "Source"
      ]
    },
    "CommCloudDiskAttachmentReference": {
      "type": "object",
      "additionalProperties": false,
      "description": "Reserved native CLOUD_DISK descriptor. This deployment rejects it until caller/object authorization is connected; no privileged fallback.",
      "properties": {
        "Bucket": {
          "type": "string",
          "description": "Native bucket name: lower-case letters/digits/_/-, starts with a letter, ends with a letter/digit, excludes mo- prefix.",
          "maxLength": 63,
          "minLength": 6
        },
        "Key": {
          "type": "string",
          "description": "Exact case-sensitive UTF-8 object key, 1 to 1024 encoded bytes; not a download URL."
        }
      },
      "required": [
        "Bucket",
        "Key"
      ]
    },
    "CommDmsAttachmentReference": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "DocId": {
          "type": "integer",
          "format": "int64",
          "minimum": 1
        }
      },
      "required": [
        "DocId"
      ]
    },
    "CommDocumentInputFile": {
      "type": "object",
      "additionalProperties": false,
      "description": "Existing authorized DMS input files for ARCHIVE-only DOCUMENT services. Inapplicable to DELIVERY and DOCUMENT services that generate new output. Maximum 20; no file bytes or URLs.",
      "properties": {
        "DocId": {
          "type": "integer",
          "format": "int64",
          "minimum": 1
        },
        "FileKey": {
          "type": "string",
          "maxLength": 60
        },
        "Role": {
          "type": "string",
          "maxLength": 60
        }
      },
      "required": [
        "DocId",
        "FileKey",
        "Role"
      ]
    },
    "CommTaskRecipient": {
      "type": "object",
      "additionalProperties": false,
      "description": "One address group per Channel and optional legacy Role. EMAIL Role may be omitted. Duplicate group/channel pairs are rejected; put multiple EMAIL To addresses in Addresses. Nonblank RecipientId values of eligible, nonsuppressed FALLBACK candidates within one role must agree.",
      "properties": {
        "Address": {
          "type": "string",
          "description": "Single channel destination. EMAIL accepts one plain email address here or a native Addresses array; do not supply both. Other channels retain a single address."
        },
        "Addresses": {
          "type": "array",
          "description": "EMAIL To destinations as a nonempty JSON array of plain email addresses, at most 512 characters per item. Use Address or Addresses, never both. One preference subject, Execution and retry apply to the entire email; no per-address customer mapping.",
          "items": {
            "type": "string",
            "description": "EMAIL To destinations as a nonempty JSON array of plain email addresses, at most 512 characters per item. Use Address or Addresses, never both. One preference subject, Execution and retry apply to the entire email; no per-address customer mapping."
          }
        },
        "Channel": {
          "type": "string",
          "description": "Delivery channel associated with this recipient address.",
          "maxLength": 40
        },
        "RecipientId": {
          "type": "string",
          "description": "Preference subject identifier. Needed when the matching rule is not preference-exempt. If needed but missing, the matching message is suppressed.",
          "maxLength": 64
        },
        "Role": {
          "type": "string",
          "description": "Optional for EMAIL; omission uses the default email address group. Explicit legacy roles remain supported. Other channels require a role, normalized by trimming and uppercasing.",
          "maxLength": 40
        }
      },
      "required": [
        "Channel"
      ]
    }
  }
}