{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/insuremo-com/json-schema/insuremo-com-comm-definition-save-request-schema.json",
  "title": "CommDefinitionSaveRequest",
  "description": "Create or save a disabled communication definition. Existing saves clear omitted optional role/preference/retry overrides to inherit defaults. A retry override requires all four fields.",
  "x-generated": "2026-12-02",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/insuremo-com-connecthub-openapi.yml#/components/schemas/CommDefinitionSaveRequest",
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "Attachments": {
      "type": "array",
      "description": "Declared logical FileKey slots with optional labels; no source file identities.",
      "items": {
        "$ref": "#/$defs/CommDefinitionAttachmentInput"
      }
    },
    "ContextDefinitionId": {
      "type": "integer",
      "format": "int64",
      "description": "Optional on a disabled save; required when enabling. Identifies the context supplying task variables."
    },
    "DefinitionCode": {
      "type": "string",
      "description": "Unique task code used by send requests; immutable after creation.",
      "maxLength": 60,
      "pattern": "[A-Z][A-Z0-9_]{2,59}",
      "writeOnly": true
    },
    "DefinitionId": {
      "type": "integer",
      "format": "int64",
      "description": "Omit or send null to create disabled. Supply the existing identifier to save; enabled definitions must remain executable."
    },
    "DefinitionName": {
      "type": "string",
      "description": "Display name of the business task definition.",
      "writeOnly": true
    },
    "DeliveryStrategy": {
      "type": "string",
      "description": "ALL sends eligible rules independently and does not guarantee delivery order. FALLBACK tries channels by positive OrderNo within each recipient role and stops later candidates after success.",
      "enum": [
        "ALL",
        "FALLBACK"
      ],
      "writeOnly": true
    },
    "Description": {
      "type": "string",
      "description": "Optional description of the business task.",
      "writeOnly": true
    },
    "ExpectedRevision": {
      "type": "integer",
      "format": "int64",
      "description": "Last read Revision; required when changing an existing resource. Bindings use the owning Definition Revision."
    },
    "GroupId": {
      "type": "integer",
      "format": "int64",
      "description": "Required DataIO publication group identifier; rows of a locked group cannot be published.",
      "writeOnly": true
    },
    "MaxAttempts": {
      "type": "integer",
      "format": "int32",
      "description": "Automatic delivery attempts including the first send.",
      "minimum": 1,
      "writeOnly": true
    },
    "PreferencePolicy": {
      "type": "string",
      "description": "Definition default for recipient preference enforcement. RESPECT checks preference and BYPASS explicitly skips it.",
      "enum": [
        "RESPECT",
        "BYPASS",
        "RESPECT",
        "BYPASS"
      ],
      "writeOnly": true
    },
    "RetryBackoffMultiplier": {
      "type": "number",
      "description": "JSON number from 1 to 100 with at most four fractional digits; applied to each later retry delay.",
      "maximum": 100,
      "minimum": 1,
      "multipleOf": 0.0001,
      "writeOnly": true
    },
    "RetryInitialDelaySeconds": {
      "type": "integer",
      "format": "int32",
      "description": "Initial automatic retry delay after the first failed physical attempt, in seconds.",
      "minimum": 1,
      "writeOnly": true
    },
    "RetryMaxDelaySeconds": {
      "type": "integer",
      "format": "int32",
      "description": "Maximum automatic retry delay, in seconds.",
      "minimum": 1,
      "writeOnly": true
    },
    "RoleDeliveryStrategyOverrides": {
      "type": "object",
      "additionalProperties": {
        "type": "string",
        "description": "Optional canonical recipient-role map to ALL or FALLBACK. A missing role inherits DeliveryStrategy.",
        "enum": [
          "ALL",
          "FALLBACK"
        ]
      },
      "description": "Optional canonical recipient-role map to ALL or FALLBACK. A missing role inherits DeliveryStrategy.",
      "writeOnly": true
    }
  },
  "required": [
    "DefinitionCode",
    "GroupId"
  ],
  "$defs": {
    "CommDefinitionAttachmentInput": {
      "type": "object",
      "additionalProperties": false,
      "description": "Declared logical FileKey slots with optional labels; no source file identities.",
      "properties": {
        "Cardinality": {
          "type": "string",
          "default": "SINGLE",
          "description": "Slot cardinality. Omission defaults to SINGLE for a new/legacy slot; existing MULTIPLE slots require an explicit value when saved.",
          "enum": [
            "SINGLE",
            "MULTIPLE"
          ]
        },
        "FileKey": {
          "type": "string",
          "maxLength": 60,
          "pattern": "[A-Za-z][A-Za-z0-9_]{0,59}"
        },
        "Name": {
          "type": "string",
          "description": "Optional display label; no source or requiredness.",
          "maxLength": 200
        }
      },
      "required": [
        "FileKey"
      ]
    }
  }
}