{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/lexifina/json-schema/lexifina-matter-schema.json",
  "title": "Matter",
  "x-generated": "2026-11-11",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/lexifina-openapi.json#/components/schemas/Matter",
  "properties": {
    "id": {
      "title": "Id",
      "type": "string"
    },
    "object": {
      "const": "matter",
      "default": "matter",
      "title": "Object",
      "type": "string"
    },
    "matter_name": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Matter Name"
    },
    "matter_number": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Matter Number"
    },
    "client_id": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Client Id"
    },
    "client_info": {
      "anyOf": [
        {
          "additionalProperties": true,
          "type": "object"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "The client contact: name, email, phone, role.",
      "title": "Client Info"
    },
    "attorney_info": {
      "anyOf": [
        {
          "additionalProperties": true,
          "type": "object"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Attorney Info"
    },
    "template_id": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Template Id"
    },
    "template_name": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Template Name"
    },
    "owner": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Owner"
    },
    "org_id": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Org Id"
    },
    "status": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Questionnaire status: draft, submitted or closed.",
      "title": "Status"
    },
    "lifecycle_status": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "open or closed.",
      "title": "Lifecycle Status"
    },
    "retention_status": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Retention Status"
    },
    "enhanced_status": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Enhanced Status"
    },
    "legal_hold": {
      "anyOf": [
        {
          "type": "boolean"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Legal Hold"
    },
    "effective_permission": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Effective Permission"
    },
    "created_at": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Created At"
    },
    "updated_at": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Updated At"
    },
    "last_activity_at": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Last Activity At"
    },
    "submitted_at": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Submitted At"
    },
    "closed_at": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Closed At"
    },
    "closed_by": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Closed By"
    },
    "closure_notes": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Closure Notes"
    },
    "reopen_notes": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Reopen Notes"
    },
    "deletion_scheduled_at": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Deletion Scheduled At"
    },
    "share_expires_at": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Share Expires At"
    },
    "attached_documents": {
      "default": [],
      "items": {
        "$ref": "#/$defs/MatterAttachedDocument"
      },
      "title": "Attached Documents",
      "type": "array"
    },
    "answers": {
      "default": [],
      "items": {
        "$ref": "#/$defs/QuestionnaireAnswer"
      },
      "title": "Answers",
      "type": "array"
    },
    "custom_fields": {
      "additionalProperties": true,
      "default": {},
      "title": "Custom Fields",
      "type": "object"
    },
    "questionnaire_count": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Questionnaire Count"
    },
    "questionnaires": {
      "default": [],
      "items": {
        "$ref": "#/$defs/MatterQuestionnaireRef"
      },
      "title": "Questionnaires",
      "type": "array"
    },
    "avg_completion_percent": {
      "anyOf": [
        {
          "type": "number"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Avg Completion Percent"
    },
    "has_answers": {
      "anyOf": [
        {
          "type": "boolean"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Has Answers"
    },
    "answered_questions": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Answered Questions"
    },
    "total_answers": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Total Answers"
    },
    "total_questions": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Total Questions"
    },
    "task_rollup": {
      "anyOf": [
        {
          "$ref": "#/$defs/TaskRollup"
        },
        {
          "type": "null"
        }
      ],
      "default": null
    },
    "document_count": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Document Count"
    },
    "attachment_id": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "On questionnaire saves and submissions: the questionnaire written.",
      "title": "Attachment Id"
    },
    "first_submission": {
      "anyOf": [
        {
          "type": "boolean"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "First Submission"
    },
    "external_reference": {
      "anyOf": [
        {
          "$ref": "#/$defs/ExternalReferenceValue"
        },
        {
          "type": "null"
        }
      ],
      "default": null
    }
  },
  "required": [
    "id",
    "object",
    "matter_name",
    "matter_number",
    "client_id",
    "client_info",
    "attorney_info",
    "template_id",
    "template_name",
    "owner",
    "org_id",
    "status",
    "lifecycle_status",
    "retention_status",
    "enhanced_status",
    "legal_hold",
    "effective_permission",
    "created_at",
    "updated_at",
    "last_activity_at",
    "submitted_at",
    "closed_at",
    "closed_by",
    "closure_notes",
    "reopen_notes",
    "deletion_scheduled_at",
    "share_expires_at",
    "attached_documents",
    "answers",
    "custom_fields",
    "questionnaire_count",
    "questionnaires",
    "avg_completion_percent",
    "has_answers",
    "answered_questions",
    "total_answers",
    "total_questions",
    "task_rollup",
    "document_count",
    "attachment_id",
    "first_submission",
    "external_reference"
  ],
  "type": "object",
  "$defs": {
    "ExternalReferenceValue": {
      "properties": {
        "external_id": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "External Id"
        },
        "metadata": {
          "additionalProperties": {
            "type": "string"
          },
          "default": {},
          "title": "Metadata",
          "type": "object"
        }
      },
      "title": "ExternalReferenceValue",
      "type": "object",
      "required": [
        "external_id",
        "metadata"
      ]
    },
    "MatterAttachedDocument": {
      "properties": {
        "document_id": {
          "title": "Document Id",
          "type": "string"
        },
        "filename": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Filename"
        },
        "attached_at": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Attached At"
        },
        "attached_by": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Attached By"
        },
        "source_type": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Source Type"
        },
        "source_label": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Source Label"
        },
        "source_id": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Source Id"
        }
      },
      "required": [
        "document_id",
        "filename",
        "attached_at",
        "attached_by",
        "source_type",
        "source_label",
        "source_id"
      ],
      "title": "MatterAttachedDocument",
      "type": "object"
    },
    "MatterQuestionnaireRef": {
      "properties": {
        "id": {
          "title": "Id",
          "type": "string"
        },
        "template_id": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Template Id"
        },
        "template_name": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Template Name"
        },
        "is_primary": {
          "anyOf": [
            {
              "type": "boolean"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Is Primary"
        },
        "status": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Status"
        }
      },
      "required": [
        "id",
        "template_id",
        "template_name",
        "is_primary",
        "status"
      ],
      "title": "MatterQuestionnaireRef",
      "type": "object"
    },
    "QuestionnaireAnswer": {
      "properties": {
        "question_id": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Question Id"
        },
        "section_id": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Section Id"
        },
        "type": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Type"
        },
        "value": {
          "default": null,
          "title": "Value"
        },
        "updated_at": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Updated At"
        },
        "template_id": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Template Id"
        }
      },
      "title": "QuestionnaireAnswer",
      "type": "object",
      "required": [
        "question_id",
        "section_id",
        "type",
        "value",
        "updated_at",
        "template_id"
      ]
    },
    "TaskRollup": {
      "properties": {
        "open_count": {
          "default": 0,
          "title": "Open Count",
          "type": "integer"
        },
        "in_progress_count": {
          "default": 0,
          "title": "In Progress Count",
          "type": "integer"
        },
        "blocked_count": {
          "default": 0,
          "title": "Blocked Count",
          "type": "integer"
        },
        "completed_count": {
          "default": 0,
          "title": "Completed Count",
          "type": "integer"
        },
        "cancelled_count": {
          "default": 0,
          "title": "Cancelled Count",
          "type": "integer"
        },
        "overdue_count": {
          "default": 0,
          "title": "Overdue Count",
          "type": "integer"
        },
        "due_today_count": {
          "default": 0,
          "title": "Due Today Count",
          "type": "integer"
        },
        "upcoming_count": {
          "default": 0,
          "title": "Upcoming Count",
          "type": "integer"
        },
        "deadline_count": {
          "default": 0,
          "title": "Deadline Count",
          "type": "integer"
        },
        "task_count": {
          "default": 0,
          "title": "Task Count",
          "type": "integer"
        },
        "next_due_at": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Next Due At"
        },
        "next_due_task_id": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Next Due Task Id"
        },
        "counts_by_status": {
          "additionalProperties": {
            "type": "integer"
          },
          "default": {},
          "title": "Counts By Status",
          "type": "object"
        },
        "counts_by_type": {
          "additionalProperties": {
            "type": "integer"
          },
          "default": {},
          "title": "Counts By Type",
          "type": "object"
        }
      },
      "title": "TaskRollup",
      "type": "object",
      "required": [
        "open_count",
        "in_progress_count",
        "blocked_count",
        "completed_count",
        "cancelled_count",
        "overdue_count",
        "due_today_count",
        "upcoming_count",
        "deadline_count",
        "task_count",
        "next_due_at",
        "next_due_task_id",
        "counts_by_status",
        "counts_by_type"
      ]
    }
  }
}