{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/hmcts/json-schema/hmcts-case-event-trigger-schema.json",
  "title": "CaseEventTrigger",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/hmcts-caseworkers-api-openapi.yml#/components/schemas/CaseEventTrigger",
  "type": "object",
  "properties": {
    "id": {
      "type": "string"
    },
    "name": {
      "type": "string"
    },
    "description": {
      "type": "string"
    },
    "case_id": {
      "type": "string"
    },
    "case_fields": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/CaseEventTriggerField"
      }
    }
  },
  "$defs": {
    "CaseEventTriggerField": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "description": "The id of the case field"
        },
        "label": {
          "type": "string"
        },
        "hint_text": {
          "type": "string"
        },
        "field_type": {
          "$ref": "#/$defs/FieldType"
        },
        "security_label": {
          "type": "string",
          "description": "Gov security level of the data (official, top secret etc)"
        },
        "display_context": {
          "$ref": "#/$defs/DisplayContextEnum"
        },
        "order": {
          "type": "integer",
          "format": "int32"
        },
        "value": {
          "type": "object",
          "description": "Value of the field, type and structure depends on the field type\n"
        }
      }
    },
    "CaseViewField": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "description": "The id of the case field"
        },
        "label": {
          "type": "string"
        },
        "hint_text": {
          "type": "string"
        },
        "field_type": {
          "$ref": "#/$defs/FieldType"
        },
        "hidden": {
          "type": "boolean"
        },
        "validation_expr": {
          "type": "string"
        },
        "security_label": {
          "type": "string",
          "description": "Gov security level of the data (official, top secret etc)"
        },
        "order": {
          "type": "integer",
          "format": "int32"
        },
        "value": {
          "type": "object",
          "description": "Value of the field, type and structure depends on the field type\n"
        }
      },
      "required": [
        "id",
        "label",
        "field_type"
      ]
    },
    "DisplayContextEnum": {
      "type": "string",
      "description": "Supported values of case event field display context",
      "enum": [
        "READONLY",
        "OPTIONAL",
        "MANDATORY"
      ]
    },
    "FieldType": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "description": "Same as `type` for simple types, or custom type name for complex types\n"
        },
        "type": {
          "$ref": "#/$defs/FieldTypeEnum"
        },
        "min": {
          "type": "integer",
          "format": "int32",
          "description": "Minimum number or string length, when applicable"
        },
        "max": {
          "type": "integer",
          "format": "int32",
          "description": "Maximum number or string length, when applicable"
        },
        "regular_expression": {
          "type": "string",
          "description": "Regular expression to conform to, applicable to string"
        },
        "fixed_list_items": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/FixedListItem"
          },
          "description": "Applicable to `FixedList` type"
        },
        "complex_fields": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/CaseViewField"
          },
          "description": "Applicable to `ComplexType` type"
        }
      },
      "required": [
        "id",
        "type"
      ]
    },
    "FieldTypeEnum": {
      "type": "string",
      "description": "Supported values of field types' type",
      "enum": [
        "Text",
        "Number",
        "YesOrNo",
        "Date",
        "Email",
        "PhoneUK",
        "FixedList",
        "MoneyGBP",
        "TextArea",
        "RichTextArea",
        "ComplexType",
        "Collection",
        "MultiSelectList"
      ]
    },
    "FixedListItem": {
      "type": "object",
      "properties": {
        "code": {
          "type": "string",
          "description": "Value of the list item, to be saved in case data"
        },
        "label": {
          "type": "string",
          "description": "Label of the list item, for display only"
        }
      },
      "required": [
        "label"
      ]
    }
  }
}